3357 lines
200 KiB
C
3357 lines
200 KiB
C
/* Generated by zi2c from compiler_parse.zi. */
|
|
#include <stdbool.h>
|
|
#include "zir_bounds.h"
|
|
#include "zir_string.h"
|
|
#define ZIRAN_COMPILER_PARSE_H_PRIVATE 1
|
|
#include "compiler_parse.h"
|
|
#undef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
#ifndef ZIRAN_MAYBE_UNUSED
|
|
#if defined(__GNUC__) || defined(__clang__)
|
|
#define ZIRAN_MAYBE_UNUSED __attribute__((unused))
|
|
#else
|
|
#define ZIRAN_MAYBE_UNUSED
|
|
#endif
|
|
#endif
|
|
static String compiler_parse_Token(Parser* p) ZIRAN_MAYBE_UNUSED;
|
|
static void compiler_parse_Advance(Parser* p) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_Take(Parser* p, String wanted) ZIRAN_MAYBE_UNUSED;
|
|
static void compiler_parse_Expect(Parser* p, String wanted) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_Following(Parser* p, int32_t distance) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_TypeRange(Parser* p, int64_t start) ZIRAN_MAYBE_UNUSED;
|
|
static void compiler_parse_JaiSyntax(Parser* p, String message) ZIRAN_MAYBE_UNUSED;
|
|
static ZirSourceSpan compiler_parse_SpanAt(Parser* p, int64_t offset) ZIRAN_MAYBE_UNUSED;
|
|
static int32_t compiler_parse_Node(Parser* p, ZirExprKind kind, int64_t start, String name, String op, int32_t left, int32_t right) ZIRAN_MAYBE_UNUSED;
|
|
static uint8_t* compiler_parse_Name(String text) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_Cut(String text) ZIRAN_MAYBE_UNUSED;
|
|
static void compiler_parse_Link(Parser* p, int32_t* first, int32_t* last, int32_t child) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_ScalarName(String name) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_IsType(Parser* p, String name) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_IsRecord(Parser* p, String name) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_IsArray(String name) ZIRAN_MAYBE_UNUSED;
|
|
static int32_t compiler_parse_ParseBinary(Parser* p, int32_t minimum) ZIRAN_MAYBE_UNUSED;
|
|
static int32_t compiler_parse_ParsePostfix(Parser* p, int64_t start, int32_t initial) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_FieldType(Parser* p, String type_name, String field_name, int32_t ordinal) ZIRAN_MAYBE_UNUSED;
|
|
static int32_t compiler_parse_ParseInitializer(Parser* p, int64_t start, String type, String open, String close) ZIRAN_MAYBE_UNUSED;
|
|
static int32_t compiler_parse_TypedArray(Parser* p, int64_t start, String element_name) ZIRAN_MAYBE_UNUSED;
|
|
static uint8_t* compiler_parse_ArrayName(int64_t count, String element) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t compiler_parse_Decimal(Slice output, int64_t value) ZIRAN_MAYBE_UNUSED;
|
|
static int32_t compiler_parse_ParsePrefix(Parser* p) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_ArrayLiteralAhead(Parser* p) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_UnarySpelling(String operator) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_QualifiedName(Slice output, String first, String second, int64_t limit) ZIRAN_MAYBE_UNUSED;
|
|
static bool compiler_parse_NameStart(String text) ZIRAN_MAYBE_UNUSED;
|
|
static String compiler_parse_Trim(String source) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t compiler_parse_FindByte(String source, uint8_t wanted) ZIRAN_MAYBE_UNUSED;
|
|
|
|
int32_t
|
|
compiler_parse_ParseExpression(ZirFunction* fn, ZirModule* module, String text, ZirSourceSpan span, String expected_type, int32_t stmt_index, bool expand_defaults)
|
|
{
|
|
int64_t value_0 = compiler_text_SkipSpace(text, 0LL, false);
|
|
int64_t value_1 = (int64_t)(text).length;
|
|
if (value_0 == value_1) {
|
|
return -1;
|
|
}
|
|
Parser p = {.fn = fn, .module = module, .span = span, .source = text, .expected_type = expected_type, .stmt_index = stmt_index, .expand_defaults = expand_defaults, .span_cursor = span};
|
|
int32_t initial = fn->expr_count;
|
|
Parser* value_2 = &(p);
|
|
{
|
|
Parser* p = value_2;
|
|
Scan* value_4 = &(p->token);
|
|
Scan value_5 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_4) = value_5;
|
|
int64_t value_6 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_6 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_7 = &(p->failed);
|
|
(*value_7) = true;
|
|
}
|
|
}
|
|
int32_t result = compiler_parse_ParseBinary(&(p), 1);
|
|
Parser* value_8 = &(p);
|
|
String value_9 = StringLiteral(";");
|
|
bool value_10 = false;
|
|
{
|
|
Parser* p = value_8;
|
|
String wanted = value_9;
|
|
Parser* value_12 = p;
|
|
String value_13 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_12;
|
|
String value_15 = p->source;
|
|
value_13 = StringRange(value_15, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_13, wanted)) {
|
|
value_10 = false;
|
|
goto value_11;
|
|
}
|
|
Parser* value_16 = p;
|
|
{
|
|
Parser* p = value_16;
|
|
Scan* value_18 = &(p->token);
|
|
Scan value_19 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_18) = value_19;
|
|
int64_t value_20 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_20 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_21 = &(p->failed);
|
|
(*value_21) = true;
|
|
}
|
|
}
|
|
value_10 = true;
|
|
value_11: ;
|
|
}
|
|
(void)value_10;
|
|
if (!p.failed && ((TokenKind)(p.token.kind)) == ((TokenKind)(0)) && result >= 0) {
|
|
return result;
|
|
}
|
|
int32_t* value_22 = &(fn->expr_count);
|
|
(*value_22) = initial;
|
|
ZirExpr* value_23 = compiler_services_AddExpr(fn, (ZirExprKind)(0), text, span);
|
|
if (value_23 == ((void *)0)) {
|
|
return -1;
|
|
}
|
|
return (int32_t)((uint32_t)(fn->expr_count) - 1u);
|
|
}
|
|
|
|
static String
|
|
compiler_parse_Token(Parser* p)
|
|
{
|
|
String value_0 = p->source;
|
|
return StringRange(value_0, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
|
|
static void
|
|
compiler_parse_Advance(Parser* p)
|
|
{
|
|
Scan* value_0 = &(p->token);
|
|
Scan value_1 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_0) = value_1;
|
|
int64_t value_2 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_2 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_3 = &(p->failed);
|
|
(*value_3) = true;
|
|
}
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_Take(Parser* p, String wanted)
|
|
{
|
|
Parser* value_0 = p;
|
|
String value_1 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_0;
|
|
String value_3 = p->source;
|
|
value_1 = StringRange(value_3, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_1, wanted)) {
|
|
return false;
|
|
}
|
|
Parser* value_4 = p;
|
|
{
|
|
Parser* p = value_4;
|
|
Scan* value_6 = &(p->token);
|
|
Scan value_7 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_6) = value_7;
|
|
int64_t value_8 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_8 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_9 = &(p->failed);
|
|
(*value_9) = true;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static void
|
|
compiler_parse_Expect(Parser* p, String wanted)
|
|
{
|
|
Parser* value_0 = p;
|
|
String value_1 = wanted;
|
|
bool value_2 = false;
|
|
{
|
|
Parser* p = value_0;
|
|
String wanted = value_1;
|
|
Parser* value_4 = p;
|
|
String value_5 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_4;
|
|
String value_7 = p->source;
|
|
value_5 = StringRange(value_7, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_5, wanted)) {
|
|
value_2 = false;
|
|
goto value_3;
|
|
}
|
|
Parser* value_8 = p;
|
|
{
|
|
Parser* p = value_8;
|
|
Scan* value_10 = &(p->token);
|
|
Scan value_11 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_10) = value_11;
|
|
int64_t value_12 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_12 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_13 = &(p->failed);
|
|
(*value_13) = true;
|
|
}
|
|
}
|
|
value_2 = true;
|
|
value_3: ;
|
|
}
|
|
if (!value_2) {
|
|
bool* value_14 = &(p->failed);
|
|
(*value_14) = true;
|
|
}
|
|
}
|
|
|
|
static String
|
|
compiler_parse_Following(Parser* p, int32_t distance)
|
|
{
|
|
int64_t at = p->token.end;
|
|
Scan following = {0};
|
|
{
|
|
int32_t range_first_2 = 1;
|
|
int32_t range_last_2 = distance;
|
|
int32_t index = range_first_2;
|
|
if (index <= range_last_2) for (;;) {
|
|
following = compiler_scan_NextToken(p->source, at, 1, 1);
|
|
at = following.end;
|
|
if (index == range_last_2) {
|
|
break;
|
|
}
|
|
index = (int32_t)((uint32_t)index + 1u);
|
|
}
|
|
}
|
|
String value_0 = p->source;
|
|
return StringRange(value_0, (int64_t)following.begin, (int64_t)following.end);
|
|
}
|
|
|
|
static String
|
|
compiler_parse_TypeRange(Parser* p, int64_t start)
|
|
{
|
|
int64_t end = p->token.begin;
|
|
if (start < 0LL || end < start || (int64_t)((uint64_t)end - (uint64_t)start) >= 128LL) {
|
|
bool* value_0 = &(p->failed);
|
|
(*value_0) = true;
|
|
return StringLiteral("");
|
|
}
|
|
String value_1 = p->source;
|
|
String value_2 = StringRange(value_1, (int64_t)start, (int64_t)end);
|
|
String value_3 = StringView(NULL, 0);
|
|
{
|
|
String source = value_2;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_3 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
return value_3;
|
|
}
|
|
|
|
static void
|
|
compiler_parse_JaiSyntax(Parser* p, String message)
|
|
{
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
|
|
static ZirSourceSpan
|
|
compiler_parse_SpanAt(Parser* p, int64_t offset)
|
|
{
|
|
int64_t at = p->span_offset;
|
|
ZirSourceSpan span = p->span_cursor;
|
|
if (offset < at) {
|
|
{
|
|
int64_t range_first_3 = offset;
|
|
int64_t range_last_3 = (int64_t)((uint64_t)at - UINT64_C(1));
|
|
int64_t i = range_first_3;
|
|
if (i <= range_last_3) for (;;) {
|
|
if ((uint8_t)ZIRAN_INDEX(p->source.data, p->source.length, i) == 10) {
|
|
int32_t* value_0 = &(span.line);
|
|
(*value_0) = (int32_t)((uint32_t)((*value_0)) - 1u);
|
|
}
|
|
if (i == range_last_3) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
int64_t line_start = offset;
|
|
while (line_start > 0LL && (uint8_t)ZIRAN_INDEX(p->source.data, p->source.length, ((int64_t)((uint64_t)line_start - UINT64_C(1)))) != 10) {
|
|
line_start = (int64_t)((uint64_t)line_start - UINT64_C(1));
|
|
}
|
|
if (line_start == 0LL) {
|
|
int32_t* value_1 = &(span.column);
|
|
(*value_1) = (int32_t)((uint32_t)(p->span.column) + (uint32_t)(offset));
|
|
} else {
|
|
int32_t* value_2 = &(span.column);
|
|
(*value_2) = (int32_t)((uint32_t)(((int64_t)((uint64_t)offset - (uint64_t)line_start))) + 1u);
|
|
}
|
|
} else {
|
|
{
|
|
int64_t range_first_20 = at;
|
|
int64_t range_last_20 = (int64_t)((uint64_t)offset - UINT64_C(1));
|
|
int64_t i = range_first_20;
|
|
if (i <= range_last_20) for (;;) {
|
|
if ((uint8_t)ZIRAN_INDEX(p->source.data, p->source.length, i) == 10) {
|
|
int32_t* value_3 = &(span.line);
|
|
(*value_3) = (int32_t)((uint32_t)((*value_3)) + 1u);
|
|
int32_t* value_4 = &(span.column);
|
|
(*value_4) = 1;
|
|
} else {
|
|
int32_t* value_5 = &(span.column);
|
|
(*value_5) = (int32_t)((uint32_t)((*value_5)) + 1u);
|
|
}
|
|
if (i == range_last_20) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
int64_t* value_6 = &(p->span_offset);
|
|
(*value_6) = offset;
|
|
ZirSourceSpan* value_7 = &(p->span_cursor);
|
|
(*value_7) = span;
|
|
return span;
|
|
}
|
|
|
|
static int32_t
|
|
compiler_parse_Node(Parser* p, ZirExprKind kind, int64_t start, String name, String op, int32_t left, int32_t right)
|
|
{
|
|
int64_t end = p->token.begin;
|
|
if (end < start) {
|
|
end = start;
|
|
}
|
|
ZirSourceSpan span = compiler_parse_SpanAt(p, start);
|
|
ZirFunction* value_0 = p->fn;
|
|
ZirExprKind value_1 = (ZirExprKind)(kind);
|
|
String value_2 = p->source;
|
|
String value_3 = StringRange(value_2, (int64_t)start, (int64_t)end);
|
|
String value_4 = StringView(NULL, 0);
|
|
{
|
|
String source = value_3;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_4 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
ZirExpr* node = compiler_services_AddExpr(value_0, value_1, value_4, span);
|
|
if (node == ((void *)0)) {
|
|
bool* value_6 = &(p->failed);
|
|
(*value_6) = true;
|
|
return -1;
|
|
}
|
|
const char ** value_7 = &(node->name);
|
|
uint8_t* value_8 = (void *)0;
|
|
{
|
|
String text = name;
|
|
String value_10 = text;
|
|
String value_11 = StringView(NULL, 0);
|
|
{
|
|
String text = value_10;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_11 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_12;
|
|
}
|
|
value_11 = text;
|
|
value_12: ;
|
|
}
|
|
value_8 = compiler_services_KeepName(value_11);
|
|
}
|
|
(*value_7) = (const char *)(value_8);
|
|
Slice value_13 = {node->op, 8};
|
|
compiler_ir_CopyText(value_13, op);
|
|
int32_t* value_14 = &(node->left);
|
|
(*value_14) = left;
|
|
int32_t* value_15 = &(node->right);
|
|
(*value_15) = right;
|
|
return (int32_t)((uint32_t)(p->fn->expr_count) - 1u);
|
|
}
|
|
|
|
static uint8_t*
|
|
compiler_parse_Name(String text)
|
|
{
|
|
String value_0 = text;
|
|
String value_1 = StringView(NULL, 0);
|
|
{
|
|
String text = value_0;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_1 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_2;
|
|
}
|
|
value_1 = text;
|
|
value_2: ;
|
|
}
|
|
return compiler_services_KeepName(value_1);
|
|
}
|
|
|
|
static String
|
|
compiler_parse_Cut(String text)
|
|
{
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
return StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
}
|
|
return text;
|
|
}
|
|
|
|
static void
|
|
compiler_parse_Link(Parser* p, int32_t* first, int32_t* last, int32_t child)
|
|
{
|
|
if (*(last) >= 0) {
|
|
int32_t* value_0 = &((p->fn->exprs[*(last)]).next_sibling);
|
|
(*value_0) = child;
|
|
} else {
|
|
int32_t* value_1 = &((*(first)));
|
|
(*value_1) = child;
|
|
}
|
|
int32_t* value_2 = &((*(last)));
|
|
(*value_2) = child;
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_ScalarName(String name)
|
|
{
|
|
bool value_0 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
return value_0 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_IsType(Parser* p, String name)
|
|
{
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
return false;
|
|
}
|
|
String value_0 = name;
|
|
bool value_1 = false;
|
|
{
|
|
String name = value_0;
|
|
bool value_3 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_1 = value_3 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_4 = value_1;
|
|
if (!value_4) {
|
|
bool value_5 = p->module != ((void *)0);
|
|
bool value_6 = value_5;
|
|
if (value_6) {
|
|
ZirType* value_7 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_6 = (value_7 != ((void *)0));
|
|
}
|
|
value_4 = value_6;
|
|
}
|
|
return value_4;
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_IsRecord(Parser* p, String name)
|
|
{
|
|
if ((int64_t)(name).length >= 128LL || p->module == ((void *)0)) {
|
|
return false;
|
|
}
|
|
ZirType* record = compiler_services_FindType(p->module, name, (void *)0);
|
|
return record != ((void *)0) && record->is_enum == 0;
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_IsArray(String name)
|
|
{
|
|
String value_0 = StringView(NULL, 0);
|
|
{
|
|
String text = name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_0 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_1;
|
|
}
|
|
value_0 = text;
|
|
value_1: ;
|
|
}
|
|
ElementType value_2 = compiler_type_ArrayElement(value_0);
|
|
return value_2.valid;
|
|
}
|
|
|
|
static int32_t
|
|
compiler_parse_ParseBinary(Parser* p, int32_t minimum)
|
|
{
|
|
int64_t start = p->token.begin;
|
|
int32_t left = compiler_parse_ParsePrefix(p);
|
|
int32_t* value_0 = &(p->depth);
|
|
(*value_0) = (int32_t)((uint32_t)((*value_0)) + 1u);
|
|
if (p->depth > 128) {
|
|
bool* value_1 = &(p->failed);
|
|
(*value_1) = true;
|
|
int32_t* value_2 = &(p->depth);
|
|
(*value_2) = (int32_t)((uint32_t)((*value_2)) - 1u);
|
|
return -1;
|
|
}
|
|
while (!p->failed) {
|
|
Parser* value_3 = p;
|
|
String value_4 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_3;
|
|
String value_6 = p->source;
|
|
value_4 = StringRange(value_6, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String operator = value_4;
|
|
int32_t precedence = compiler_expression_BinaryPrecedence(operator);
|
|
if (precedence == 0 || precedence < minimum) {
|
|
break;
|
|
}
|
|
Parser* value_7 = p;
|
|
{
|
|
Parser* p = value_7;
|
|
Scan* value_9 = &(p->token);
|
|
Scan value_10 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_9) = value_10;
|
|
int64_t value_11 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_11 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_12 = &(p->failed);
|
|
(*value_12) = true;
|
|
}
|
|
}
|
|
int32_t right = compiler_parse_ParseBinary(p, (int32_t)((uint32_t)precedence + 1u));
|
|
left = compiler_parse_Node(p, (ZirExprKind)(6), start, StringLiteral(""), operator, left, right);
|
|
}
|
|
Parser* value_13 = p;
|
|
String value_14 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_13;
|
|
String value_16 = p->source;
|
|
value_14 = StringRange(value_16, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_14, StringLiteral("\?"))) {
|
|
Parser* value_17 = p;
|
|
String value_18 = StringLiteral("C-style conditional is not valid Jai syntax; use ifx ... then ... else ...");
|
|
{
|
|
Parser* p = value_17;
|
|
String message = value_18;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
int32_t* value_20 = &(p->depth);
|
|
(*value_20) = (int32_t)((uint32_t)((*value_20)) - 1u);
|
|
return left;
|
|
}
|
|
|
|
static int32_t
|
|
compiler_parse_ParsePostfix(Parser* p, int64_t start, int32_t initial)
|
|
{
|
|
int32_t result = initial;
|
|
while (!p->failed) {
|
|
Parser* value_0 = p;
|
|
String value_1 = StringLiteral("[");
|
|
bool value_2 = false;
|
|
{
|
|
Parser* p = value_0;
|
|
String wanted = value_1;
|
|
Parser* value_4 = p;
|
|
String value_5 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_4;
|
|
String value_7 = p->source;
|
|
value_5 = StringRange(value_7, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_5, wanted)) {
|
|
value_2 = false;
|
|
goto value_3;
|
|
}
|
|
Parser* value_8 = p;
|
|
{
|
|
Parser* p = value_8;
|
|
Scan* value_10 = &(p->token);
|
|
Scan value_11 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_10) = value_11;
|
|
int64_t value_12 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_12 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_13 = &(p->failed);
|
|
(*value_13) = true;
|
|
}
|
|
}
|
|
value_2 = true;
|
|
value_3: ;
|
|
}
|
|
if (value_2) {
|
|
int32_t low = -1;
|
|
Parser* value_14 = p;
|
|
String value_15 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_14;
|
|
String value_17 = p->source;
|
|
value_15 = StringRange(value_17, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_15, StringLiteral(":"))) {
|
|
low = compiler_parse_ParseBinary(p, 1);
|
|
}
|
|
Parser* value_18 = p;
|
|
String value_19 = StringLiteral(":");
|
|
bool value_20 = false;
|
|
{
|
|
Parser* p = value_18;
|
|
String wanted = value_19;
|
|
Parser* value_22 = p;
|
|
String value_23 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_22;
|
|
String value_25 = p->source;
|
|
value_23 = StringRange(value_25, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_23, wanted)) {
|
|
value_20 = false;
|
|
goto value_21;
|
|
}
|
|
Parser* value_26 = p;
|
|
{
|
|
Parser* p = value_26;
|
|
Scan* value_28 = &(p->token);
|
|
Scan value_29 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_28) = value_29;
|
|
int64_t value_30 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_30 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_31 = &(p->failed);
|
|
(*value_31) = true;
|
|
}
|
|
}
|
|
value_20 = true;
|
|
value_21: ;
|
|
}
|
|
if (value_20) {
|
|
int32_t high = -1;
|
|
Parser* value_32 = p;
|
|
String value_33 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_32;
|
|
String value_35 = p->source;
|
|
value_33 = StringRange(value_35, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_33, StringLiteral("]"))) {
|
|
high = compiler_parse_ParseBinary(p, 1);
|
|
}
|
|
Parser* value_36 = p;
|
|
String value_37 = StringLiteral("]");
|
|
{
|
|
Parser* p = value_36;
|
|
String wanted = value_37;
|
|
Parser* value_39 = p;
|
|
String value_40 = wanted;
|
|
bool value_41 = false;
|
|
{
|
|
Parser* p = value_39;
|
|
String wanted = value_40;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_41 = false;
|
|
goto value_42;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_41 = true;
|
|
value_42: ;
|
|
}
|
|
if (!value_41) {
|
|
bool* value_43 = &(p->failed);
|
|
(*value_43) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(16), start, StringLiteral(""), StringLiteral(""), result, low);
|
|
if (result >= 0) {
|
|
int32_t* value_44 = &((p->fn->exprs[result]).third);
|
|
(*value_44) = high;
|
|
}
|
|
} else {
|
|
Parser* value_45 = p;
|
|
String value_46 = StringLiteral("]");
|
|
{
|
|
Parser* p = value_45;
|
|
String wanted = value_46;
|
|
Parser* value_48 = p;
|
|
String value_49 = wanted;
|
|
bool value_50 = false;
|
|
{
|
|
Parser* p = value_48;
|
|
String wanted = value_49;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_50 = false;
|
|
goto value_51;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_50 = true;
|
|
value_51: ;
|
|
}
|
|
if (!value_50) {
|
|
bool* value_52 = &(p->failed);
|
|
(*value_52) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(10), start, StringLiteral(""), StringLiteral(""), result, low);
|
|
}
|
|
} else {
|
|
Parser* value_53 = p;
|
|
String value_54 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_53;
|
|
String value_56 = p->source;
|
|
value_54 = StringRange(value_56, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_54, StringLiteral("->"))) {
|
|
Parser* value_57 = p;
|
|
String value_58 = StringLiteral("C-style pointer member access is not valid Jai syntax; use .field");
|
|
{
|
|
Parser* p = value_57;
|
|
String message = value_58;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_60 = p;
|
|
String value_61 = StringLiteral(".");
|
|
bool value_62 = false;
|
|
{
|
|
Parser* p = value_60;
|
|
String wanted = value_61;
|
|
Parser* value_64 = p;
|
|
String value_65 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_64;
|
|
String value_67 = p->source;
|
|
value_65 = StringRange(value_67, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_65, wanted)) {
|
|
value_62 = false;
|
|
goto value_63;
|
|
}
|
|
Parser* value_68 = p;
|
|
{
|
|
Parser* p = value_68;
|
|
Scan* value_70 = &(p->token);
|
|
Scan value_71 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_70) = value_71;
|
|
int64_t value_72 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_72 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_73 = &(p->failed);
|
|
(*value_73) = true;
|
|
}
|
|
}
|
|
value_62 = true;
|
|
value_63: ;
|
|
}
|
|
if (value_62) {
|
|
Parser* value_74 = p;
|
|
String value_75 = StringLiteral("*");
|
|
bool value_76 = false;
|
|
{
|
|
Parser* p = value_74;
|
|
String wanted = value_75;
|
|
Parser* value_78 = p;
|
|
String value_79 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_78;
|
|
String value_81 = p->source;
|
|
value_79 = StringRange(value_81, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_79, wanted)) {
|
|
value_76 = false;
|
|
goto value_77;
|
|
}
|
|
Parser* value_82 = p;
|
|
{
|
|
Parser* p = value_82;
|
|
Scan* value_84 = &(p->token);
|
|
Scan value_85 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_84) = value_85;
|
|
int64_t value_86 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_86 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_87 = &(p->failed);
|
|
(*value_87) = true;
|
|
}
|
|
}
|
|
value_76 = true;
|
|
value_77: ;
|
|
}
|
|
if (value_76) {
|
|
result = compiler_parse_Node(p, (ZirExprKind)(7), start, StringLiteral(""), StringLiteral("*"), -1, result);
|
|
} else {
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
bool* value_88 = &(p->failed);
|
|
(*value_88) = true;
|
|
}
|
|
Parser* value_89 = p;
|
|
String value_90 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_89;
|
|
String value_92 = p->source;
|
|
value_90 = StringRange(value_92, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String name = value_90;
|
|
Parser* value_93 = p;
|
|
{
|
|
Parser* p = value_93;
|
|
Scan* value_95 = &(p->token);
|
|
Scan value_96 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_95) = value_96;
|
|
int64_t value_97 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_97 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_98 = &(p->failed);
|
|
(*value_98) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(8), start, name, StringLiteral("."), result, -1);
|
|
}
|
|
} else {
|
|
Parser* value_99 = p;
|
|
String value_100 = StringLiteral("(");
|
|
bool value_101 = false;
|
|
{
|
|
Parser* p = value_99;
|
|
String wanted = value_100;
|
|
Parser* value_103 = p;
|
|
String value_104 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_103;
|
|
String value_106 = p->source;
|
|
value_104 = StringRange(value_106, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_104, wanted)) {
|
|
value_101 = false;
|
|
goto value_102;
|
|
}
|
|
Parser* value_107 = p;
|
|
{
|
|
Parser* p = value_107;
|
|
Scan* value_109 = &(p->token);
|
|
Scan value_110 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_109) = value_110;
|
|
int64_t value_111 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_111 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_112 = &(p->failed);
|
|
(*value_112) = true;
|
|
}
|
|
}
|
|
value_101 = true;
|
|
value_102: ;
|
|
}
|
|
if (value_101) {
|
|
int32_t first = -1;
|
|
int32_t last = -1;
|
|
int32_t callee = result;
|
|
String name = StringLiteral("");
|
|
if (callee >= 0 && ((ZirExprKind)((p->fn->exprs[callee]).kind)) == ((ZirExprKind)(1))) {
|
|
name = compiler_ir_CText((uint8_t*)(p->fn->exprs[callee]).name);
|
|
}
|
|
Parser* value_113 = p;
|
|
String value_114 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_113;
|
|
String value_116 = p->source;
|
|
value_114 = StringRange(value_116, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if ((!StringEqual(value_114, StringLiteral(")")))) {
|
|
while (true) {
|
|
String argument = StringLiteral("");
|
|
bool value_117 = ((TokenKind)(p->token.kind)) == ((TokenKind)(1));
|
|
if (value_117 && StringEqual(compiler_parse_Following(p, 1), StringLiteral("="))) {
|
|
Parser* value_118 = p;
|
|
String value_119 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_118;
|
|
String value_121 = p->source;
|
|
value_119 = StringRange(value_121, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
argument = value_119;
|
|
Parser* value_122 = p;
|
|
{
|
|
Parser* p = value_122;
|
|
Scan* value_124 = &(p->token);
|
|
Scan value_125 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_124) = value_125;
|
|
int64_t value_126 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_126 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_127 = &(p->failed);
|
|
(*value_127) = true;
|
|
}
|
|
}
|
|
Parser* value_128 = p;
|
|
String value_129 = StringLiteral("=");
|
|
{
|
|
Parser* p = value_128;
|
|
String wanted = value_129;
|
|
Parser* value_131 = p;
|
|
String value_132 = wanted;
|
|
bool value_133 = false;
|
|
{
|
|
Parser* p = value_131;
|
|
String wanted = value_132;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_133 = false;
|
|
goto value_134;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_133 = true;
|
|
value_134: ;
|
|
}
|
|
if (!value_133) {
|
|
bool* value_135 = &(p->failed);
|
|
(*value_135) = true;
|
|
}
|
|
}
|
|
}
|
|
int32_t child = compiler_parse_ParseBinary(p, 1);
|
|
if (child < 0) {
|
|
bool* value_136 = &(p->failed);
|
|
(*value_136) = true;
|
|
break;
|
|
}
|
|
const char ** value_137 = &((p->fn->exprs[child]).argument_name);
|
|
uint8_t* value_138 = (void *)0;
|
|
{
|
|
String text = argument;
|
|
String value_140 = text;
|
|
String value_141 = StringView(NULL, 0);
|
|
{
|
|
String text = value_140;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_141 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_142;
|
|
}
|
|
value_141 = text;
|
|
value_142: ;
|
|
}
|
|
value_138 = compiler_services_KeepName(value_141);
|
|
}
|
|
(*value_137) = (const char *)(value_138);
|
|
Parser* value_143 = p;
|
|
int32_t* value_144 = &(first);
|
|
int32_t* value_145 = &(last);
|
|
int32_t value_146 = child;
|
|
{
|
|
Parser* p = value_143;
|
|
int32_t* first = value_144;
|
|
int32_t* last = value_145;
|
|
int32_t child = value_146;
|
|
if (*(last) >= 0) {
|
|
int32_t* value_148 = &((p->fn->exprs[*(last)]).next_sibling);
|
|
(*value_148) = child;
|
|
} else {
|
|
int32_t* value_149 = &((*(first)));
|
|
(*value_149) = child;
|
|
}
|
|
int32_t* value_150 = &((*(last)));
|
|
(*value_150) = child;
|
|
}
|
|
Parser* value_151 = p;
|
|
String value_152 = StringLiteral(",");
|
|
bool value_153 = false;
|
|
{
|
|
Parser* p = value_151;
|
|
String wanted = value_152;
|
|
Parser* value_155 = p;
|
|
String value_156 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_155;
|
|
String value_158 = p->source;
|
|
value_156 = StringRange(value_158, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_156, wanted)) {
|
|
value_153 = false;
|
|
goto value_154;
|
|
}
|
|
Parser* value_159 = p;
|
|
{
|
|
Parser* p = value_159;
|
|
Scan* value_161 = &(p->token);
|
|
Scan value_162 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_161) = value_162;
|
|
int64_t value_163 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_163 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_164 = &(p->failed);
|
|
(*value_164) = true;
|
|
}
|
|
}
|
|
value_153 = true;
|
|
value_154: ;
|
|
}
|
|
if (!value_153) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_165 = p;
|
|
String value_166 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_165;
|
|
String wanted = value_166;
|
|
Parser* value_168 = p;
|
|
String value_169 = wanted;
|
|
bool value_170 = false;
|
|
{
|
|
Parser* p = value_168;
|
|
String wanted = value_169;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_170 = false;
|
|
goto value_171;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_170 = true;
|
|
value_171: ;
|
|
}
|
|
if (!value_170) {
|
|
bool* value_172 = &(p->failed);
|
|
(*value_172) = true;
|
|
}
|
|
}
|
|
bool value_173 = !p->failed && p->expand_defaults;
|
|
bool value_174 = value_173;
|
|
if (value_174) {
|
|
bool value_175 = compiler_services_ExpandDefaults(p->fn, p->module, p->span, p->stmt_index, callee, &(first), &(last));
|
|
value_174 = !value_175;
|
|
}
|
|
if (value_174) {
|
|
bool* value_176 = &(p->failed);
|
|
(*value_176) = true;
|
|
}
|
|
int32_t left = callee;
|
|
if ((int64_t)(name).length > 0LL) {
|
|
left = -1;
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(5), start, name, StringLiteral(""), left, -1);
|
|
if (result >= 0) {
|
|
ZirExpr* call = &(p->fn->exprs[result]);
|
|
int32_t* value_177 = &(call->first_child);
|
|
(*value_177) = first;
|
|
if (callee >= 0 && (p->fn->exprs[callee]).is_this != 0) {
|
|
int32_t* value_178 = &(call->is_this);
|
|
(*value_178) = 1;
|
|
}
|
|
}
|
|
} else {
|
|
Parser* value_179 = p;
|
|
String value_180 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_179;
|
|
String value_182 = p->source;
|
|
value_180 = StringRange(value_182, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_183 = StringEqual(value_180, StringLiteral("++"));
|
|
if (!value_183) {
|
|
Parser* value_184 = p;
|
|
String value_185 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_184;
|
|
String value_187 = p->source;
|
|
value_185 = StringRange(value_187, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_183 = (StringEqual(value_185, StringLiteral("--")));
|
|
}
|
|
if (value_183) {
|
|
Parser* value_188 = p;
|
|
String value_189 = StringLiteral("Jai has no increment or decrement operators; use += 1 or -= 1");
|
|
{
|
|
Parser* p = value_188;
|
|
String message = value_189;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_191 = p;
|
|
String value_192 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_191;
|
|
String value_194 = p->source;
|
|
value_192 = StringRange(value_194, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_195 = StringEqual(value_192, StringLiteral("\?"));
|
|
if (value_195) {
|
|
int64_t value_196 = p->token.begin;
|
|
value_195 = (value_196 > 0LL);
|
|
}
|
|
bool value_197 = value_195;
|
|
bool value_198 = value_197;
|
|
if (value_198) {
|
|
bool value_199 = compiler_text_SpaceByte((uint8_t)ZIRAN_INDEX(p->source.data, p->source.length, ((int64_t)((uint64_t)(p->token.begin) - UINT64_C(1)))));
|
|
value_198 = !value_199;
|
|
}
|
|
if (value_198) {
|
|
Parser* value_200 = p;
|
|
String value_201 = StringLiteral("postfix \? is not Jai syntax; handle the result explicitly");
|
|
{
|
|
Parser* p = value_200;
|
|
String message = value_201;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static String
|
|
compiler_parse_FieldType(Parser* p, String type_name, String field_name, int32_t ordinal)
|
|
{
|
|
String value_0 = StringView(NULL, 0);
|
|
{
|
|
String text = type_name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_0 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_1;
|
|
}
|
|
value_0 = text;
|
|
value_1: ;
|
|
}
|
|
String type = value_0;
|
|
String value_2 = StringView(NULL, 0);
|
|
{
|
|
String text = field_name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_2 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_3;
|
|
}
|
|
value_2 = text;
|
|
value_3: ;
|
|
}
|
|
String name = value_2;
|
|
ZirModule* owner = (void *)0;
|
|
ZirType* record = (void *)0;
|
|
if (p->module != ((void *)0)) {
|
|
record = compiler_services_FindType(p->module, type, &(owner));
|
|
}
|
|
ZirTypeField field = {0};
|
|
uint8_t qualified[256] = {0};
|
|
String field_type = StringLiteral("");
|
|
ElementType element = compiler_type_ArrayElement(type);
|
|
if (element.valid && (int64_t)(element.element).length < 128LL) {
|
|
field_type = element.element;
|
|
}
|
|
size_t offset = 0;
|
|
int32_t position = 0;
|
|
while (true) {
|
|
bool value_4 = record != ((void *)0);
|
|
if (!(value_4 && compiler_services_NextField(record, &(offset), &(field)) == 1)) { break; }
|
|
bool value_5 = (int64_t)(name).length > 0LL;
|
|
if (value_5) {
|
|
Slice value_6 = {field.name, 128};
|
|
bool value_7 = StringEqual(compiler_ir_BufferText(value_6), name);
|
|
value_5 = value_7;
|
|
}
|
|
if (value_5 || ((int64_t)(name).length == 0LL && position == ordinal)) {
|
|
Slice value_8 = {field.type, 128};
|
|
field_type = compiler_ir_BufferText(value_8);
|
|
break;
|
|
}
|
|
position = (int32_t)((uint32_t)position + 1u);
|
|
}
|
|
int64_t dot = compiler_parse_FindByte(type, 46);
|
|
if (owner != ((void *)0) && owner != p->module && dot >= 0LL) {
|
|
ZirType* declared = compiler_services_FindType(owner, field_type, (void *)0);
|
|
Slice value_9 = {qualified, 256};
|
|
String spelled = compiler_parse_QualifiedName(value_9, StringRange(type, (int64_t)0LL, (int64_t)dot), field_type, 128LL);
|
|
bool value_10 = declared != ((void *)0) && (int64_t)(spelled).length > 0LL;
|
|
if (value_10 && compiler_services_FindType(p->module, spelled, (void *)0) == declared) {
|
|
field_type = spelled;
|
|
}
|
|
}
|
|
return compiler_ir_CText(compiler_services_KeepName(field_type));
|
|
}
|
|
|
|
static int32_t
|
|
compiler_parse_ParseInitializer(Parser* p, int64_t start, String type, String open, String close)
|
|
{
|
|
int32_t first = -1;
|
|
int32_t last = -1;
|
|
int32_t ordinal = 0;
|
|
Parser* value_0 = p;
|
|
{
|
|
Parser* p = value_0;
|
|
String wanted = open;
|
|
Parser* value_2 = p;
|
|
String value_3 = wanted;
|
|
bool value_4 = false;
|
|
{
|
|
Parser* p = value_2;
|
|
String wanted = value_3;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_4 = false;
|
|
goto value_5;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_4 = true;
|
|
value_5: ;
|
|
}
|
|
if (!value_4) {
|
|
bool* value_6 = &(p->failed);
|
|
(*value_6) = true;
|
|
}
|
|
}
|
|
while (true) {
|
|
bool value_7 = !p->failed;
|
|
bool value_8 = value_7;
|
|
if (value_8) {
|
|
Parser* value_9 = p;
|
|
String value_10 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_9;
|
|
String value_12 = p->source;
|
|
value_10 = StringRange(value_12, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_8 = (!StringEqual(value_10, close));
|
|
}
|
|
if (!(value_8 && ((TokenKind)(p->token.kind)) != ((TokenKind)(0)))) { break; }
|
|
int64_t field_start = p->token.begin;
|
|
String name = StringLiteral("");
|
|
bool named = false;
|
|
Parser* value_13 = p;
|
|
String value_14 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_13;
|
|
String value_16 = p->source;
|
|
value_14 = StringRange(value_16, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_14, StringLiteral(".")) && StringEqual(compiler_parse_Following(p, 2), StringLiteral("="))) {
|
|
Scan value_17 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
if (((TokenKind)(value_17.kind)) == ((TokenKind)(1))) {
|
|
Parser* value_18 = p;
|
|
{
|
|
Parser* p = value_18;
|
|
Scan* value_20 = &(p->token);
|
|
Scan value_21 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_20) = value_21;
|
|
int64_t value_22 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_22 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_23 = &(p->failed);
|
|
(*value_23) = true;
|
|
}
|
|
}
|
|
named = true;
|
|
}
|
|
}
|
|
if (!named && ((TokenKind)(p->token.kind)) == ((TokenKind)(1))) {
|
|
named = StringEqual(compiler_parse_Following(p, 1), StringLiteral("="));
|
|
}
|
|
if (named) {
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
bool* value_24 = &(p->failed);
|
|
(*value_24) = true;
|
|
break;
|
|
}
|
|
Parser* value_25 = p;
|
|
String value_26 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_25;
|
|
String value_28 = p->source;
|
|
value_26 = StringRange(value_28, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
name = value_26;
|
|
Parser* value_29 = p;
|
|
{
|
|
Parser* p = value_29;
|
|
Scan* value_31 = &(p->token);
|
|
Scan value_32 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_31) = value_32;
|
|
int64_t value_33 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_33 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_34 = &(p->failed);
|
|
(*value_34) = true;
|
|
}
|
|
}
|
|
Parser* value_35 = p;
|
|
String value_36 = StringLiteral("=");
|
|
{
|
|
Parser* p = value_35;
|
|
String wanted = value_36;
|
|
Parser* value_38 = p;
|
|
String value_39 = wanted;
|
|
bool value_40 = false;
|
|
{
|
|
Parser* p = value_38;
|
|
String wanted = value_39;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_40 = false;
|
|
goto value_41;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_40 = true;
|
|
value_41: ;
|
|
}
|
|
if (!value_40) {
|
|
bool* value_42 = &(p->failed);
|
|
(*value_42) = true;
|
|
}
|
|
}
|
|
}
|
|
int32_t value = -1;
|
|
Parser* value_43 = p;
|
|
String value_44 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_43;
|
|
String value_46 = p->source;
|
|
value_44 = StringRange(value_46, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_44, StringLiteral("{"))) {
|
|
String nested_type = compiler_parse_FieldType(p, type, name, ordinal);
|
|
int32_t* value_47 = &(p->depth);
|
|
(*value_47) = (int32_t)((uint32_t)((*value_47)) + 1u);
|
|
if (p->depth > 128) {
|
|
bool* value_48 = &(p->failed);
|
|
(*value_48) = true;
|
|
int32_t* value_49 = &(p->depth);
|
|
(*value_49) = (int32_t)((uint32_t)((*value_49)) - 1u);
|
|
return -1;
|
|
}
|
|
value = compiler_parse_ParseInitializer(p, p->token.begin, nested_type, StringLiteral("{"), StringLiteral("}"));
|
|
int32_t* value_50 = &(p->depth);
|
|
(*value_50) = (int32_t)((uint32_t)((*value_50)) - 1u);
|
|
} else {
|
|
value = compiler_parse_ParseBinary(p, 1);
|
|
}
|
|
ordinal = (int32_t)((uint32_t)ordinal + 1u);
|
|
if (value < 0) {
|
|
bool* value_51 = &(p->failed);
|
|
(*value_51) = true;
|
|
break;
|
|
}
|
|
String op = StringLiteral("");
|
|
if (named) {
|
|
op = StringLiteral("=");
|
|
}
|
|
int32_t child = compiler_parse_Node(p, (ZirExprKind)(15), field_start, name, op, -1, value);
|
|
if (child < 0) {
|
|
break;
|
|
}
|
|
Parser* value_52 = p;
|
|
int32_t* value_53 = &(first);
|
|
int32_t* value_54 = &(last);
|
|
int32_t value_55 = child;
|
|
{
|
|
Parser* p = value_52;
|
|
int32_t* first = value_53;
|
|
int32_t* last = value_54;
|
|
int32_t child = value_55;
|
|
if (*(last) >= 0) {
|
|
int32_t* value_57 = &((p->fn->exprs[*(last)]).next_sibling);
|
|
(*value_57) = child;
|
|
} else {
|
|
int32_t* value_58 = &((*(first)));
|
|
(*value_58) = child;
|
|
}
|
|
int32_t* value_59 = &((*(last)));
|
|
(*value_59) = child;
|
|
}
|
|
Parser* value_60 = p;
|
|
String value_61 = StringLiteral(",");
|
|
bool value_62 = false;
|
|
{
|
|
Parser* p = value_60;
|
|
String wanted = value_61;
|
|
Parser* value_64 = p;
|
|
String value_65 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_64;
|
|
String value_67 = p->source;
|
|
value_65 = StringRange(value_67, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_65, wanted)) {
|
|
value_62 = false;
|
|
goto value_63;
|
|
}
|
|
Parser* value_68 = p;
|
|
{
|
|
Parser* p = value_68;
|
|
Scan* value_70 = &(p->token);
|
|
Scan value_71 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_70) = value_71;
|
|
int64_t value_72 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_72 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_73 = &(p->failed);
|
|
(*value_73) = true;
|
|
}
|
|
}
|
|
value_62 = true;
|
|
value_63: ;
|
|
}
|
|
if (!value_62) {
|
|
break;
|
|
}
|
|
}
|
|
Parser* value_74 = p;
|
|
{
|
|
Parser* p = value_74;
|
|
String wanted = close;
|
|
Parser* value_76 = p;
|
|
String value_77 = wanted;
|
|
bool value_78 = false;
|
|
{
|
|
Parser* p = value_76;
|
|
String wanted = value_77;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_78 = false;
|
|
goto value_79;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_78 = true;
|
|
value_79: ;
|
|
}
|
|
if (!value_78) {
|
|
bool* value_80 = &(p->failed);
|
|
(*value_80) = true;
|
|
}
|
|
}
|
|
int32_t result = compiler_parse_Node(p, (ZirExprKind)(12), start, type, StringLiteral(""), -1, -1);
|
|
if (result >= 0) {
|
|
int32_t* value_81 = &((p->fn->exprs[result]).first_child);
|
|
(*value_81) = first;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static int32_t
|
|
compiler_parse_TypedArray(Parser* p, int64_t start, String element_name)
|
|
{
|
|
String value_0 = StringView(NULL, 0);
|
|
{
|
|
String text = element_name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_0 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_1;
|
|
}
|
|
value_0 = text;
|
|
value_1: ;
|
|
}
|
|
String element = value_0;
|
|
uint8_t* single = compiler_parse_ArrayName(1LL, element);
|
|
if (single == ((void *)0)) {
|
|
bool* value_2 = &(p->failed);
|
|
(*value_2) = true;
|
|
return -1;
|
|
}
|
|
int32_t result = compiler_parse_ParseInitializer(p, start, compiler_ir_CText(single), StringLiteral("["), StringLiteral("]"));
|
|
if (result < 0 || p->failed) {
|
|
return result;
|
|
}
|
|
int64_t count = 0LL;
|
|
int32_t child = (p->fn->exprs[result]).first_child;
|
|
while (child >= 0) {
|
|
count = (int64_t)((uint64_t)count + UINT64_C(1));
|
|
child = (p->fn->exprs[child]).next_sibling;
|
|
}
|
|
uint8_t* named = compiler_parse_ArrayName(count, element);
|
|
if (named == ((void *)0)) {
|
|
bool* value_3 = &(p->failed);
|
|
(*value_3) = true;
|
|
} else {
|
|
const char ** value_4 = &((p->fn->exprs[result]).name);
|
|
(*value_4) = (const char *)(named);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static uint8_t*
|
|
compiler_parse_ArrayName(int64_t count, String element)
|
|
{
|
|
uint8_t buffer[256] = {0};
|
|
Slice value_0 = {buffer, 256};
|
|
int64_t digits = compiler_parse_Decimal(SliceRangeAt(value_0, (int64_t)1LL, (int64_t)value_0.length, sizeof(uint8_t)), count);
|
|
int64_t total = (int64_t)(((uint64_t)digits + UINT64_C(2)) + (uint64_t)((int64_t)(element).length));
|
|
if (total >= 128LL) {
|
|
return (void *)0;
|
|
}
|
|
uint8_t* value_1 = &(buffer[0]);
|
|
(*value_1) = 91;
|
|
uint8_t* value_2 = &(ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)((uint64_t)digits + UINT64_C(1)))));
|
|
(*value_2) = 93;
|
|
{
|
|
int64_t range_first_8 = 0LL;
|
|
int64_t range_last_8 = (int64_t)((uint64_t)((int64_t)(element).length) - UINT64_C(1));
|
|
int64_t i = range_first_8;
|
|
if (i <= range_last_8) for (;;) {
|
|
uint8_t* value_3 = &(ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)(((uint64_t)digits + UINT64_C(2)) + (uint64_t)i))));
|
|
(*value_3) = (uint8_t)element.data[i];
|
|
if (i == range_last_8) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
Slice value_4 = {buffer, 256};
|
|
Slice value_5 = SliceRange(value_4, (int64_t)0LL, (int64_t)total, sizeof(uint8_t));
|
|
return compiler_services_KeepName(StringView((const char *)(value_5).data, (size_t)(value_5).length));
|
|
}
|
|
|
|
static int64_t
|
|
compiler_parse_Decimal(Slice output, int64_t value)
|
|
{
|
|
int64_t used = 1LL;
|
|
int64_t rest = value / 10LL;
|
|
while (rest != 0LL) {
|
|
used = (int64_t)((uint64_t)used + UINT64_C(1));
|
|
rest = rest / 10LL;
|
|
}
|
|
rest = value;
|
|
{
|
|
int64_t range_first_7 = 0LL;
|
|
int64_t range_last_7 = (int64_t)((uint64_t)used - UINT64_C(1));
|
|
int64_t i = range_first_7;
|
|
if (i <= range_last_7) for (;;) {
|
|
uint8_t* value_0 = &(((uint8_t *)output.data)[SliceIndex(output, (int64_t)((int64_t)(((uint64_t)used - UINT64_C(1)) - (uint64_t)i)))]);
|
|
(*value_0) = (uint8_t)(((int64_t)(UINT64_C(48) + (uint64_t)((rest % 10LL)))));
|
|
rest = rest / 10LL;
|
|
if (i == range_last_7) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
return used;
|
|
}
|
|
|
|
static int32_t
|
|
compiler_parse_ParsePrefix(Parser* p)
|
|
{
|
|
int64_t start = p->token.begin;
|
|
Parser* value_0 = p;
|
|
String value_1 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_0;
|
|
String value_3 = p->source;
|
|
value_1 = StringRange(value_3, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String original = value_1;
|
|
TokenKind original_kind = (TokenKind)(p->token.kind);
|
|
Slice value_4 = {p->fn->name, 128};
|
|
String scope = compiler_ir_BufferText(value_4);
|
|
int32_t result = -1;
|
|
int32_t* value_5 = &(p->depth);
|
|
(*value_5) = (int32_t)((uint32_t)((*value_5)) + 1u);
|
|
if (p->depth > 128) {
|
|
bool* value_6 = &(p->failed);
|
|
(*value_6) = true;
|
|
int32_t* value_7 = &(p->depth);
|
|
(*value_7) = (int32_t)((uint32_t)((*value_7)) - 1u);
|
|
return -1;
|
|
}
|
|
Parser* value_8 = p;
|
|
String value_9 = StringLiteral("#this");
|
|
bool value_10 = false;
|
|
{
|
|
Parser* p = value_8;
|
|
String wanted = value_9;
|
|
Parser* value_12 = p;
|
|
String value_13 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_12;
|
|
String value_15 = p->source;
|
|
value_13 = StringRange(value_15, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_13, wanted)) {
|
|
value_10 = false;
|
|
goto value_11;
|
|
}
|
|
Parser* value_16 = p;
|
|
{
|
|
Parser* p = value_16;
|
|
Scan* value_18 = &(p->token);
|
|
Scan value_19 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_18) = value_19;
|
|
int64_t value_20 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_20 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_21 = &(p->failed);
|
|
(*value_21) = true;
|
|
}
|
|
}
|
|
value_10 = true;
|
|
value_11: ;
|
|
}
|
|
if (value_10) {
|
|
if ((int64_t)(scope).length == 0LL) {
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.this"), StringLiteral("#this requires a procedure or type scope"));
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(1), start, scope, StringLiteral(""), -1, -1);
|
|
if (result >= 0) {
|
|
int32_t* value_22 = &((p->fn->exprs[result]).is_this);
|
|
(*value_22) = 1;
|
|
}
|
|
} else {
|
|
Parser* value_23 = p;
|
|
String value_24 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_23;
|
|
String value_26 = p->source;
|
|
value_24 = StringRange(value_26, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_24, StringLiteral("#caller_location"))) {
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.caller_location"), StringLiteral("#caller_location is only valid as a parameter default"));
|
|
} else {
|
|
Parser* value_27 = p;
|
|
String value_28 = StringLiteral("#compile_time");
|
|
bool value_29 = false;
|
|
{
|
|
Parser* p = value_27;
|
|
String wanted = value_28;
|
|
Parser* value_31 = p;
|
|
String value_32 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_31;
|
|
String value_34 = p->source;
|
|
value_32 = StringRange(value_34, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_32, wanted)) {
|
|
value_29 = false;
|
|
goto value_30;
|
|
}
|
|
Parser* value_35 = p;
|
|
{
|
|
Parser* p = value_35;
|
|
Scan* value_37 = &(p->token);
|
|
Scan value_38 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_37) = value_38;
|
|
int64_t value_39 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_39 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_40 = &(p->failed);
|
|
(*value_40) = true;
|
|
}
|
|
}
|
|
value_29 = true;
|
|
value_30: ;
|
|
}
|
|
if (value_29) {
|
|
result = compiler_parse_Node(p, (ZirExprKind)(17), start, StringLiteral(""), StringLiteral(""), -1, -1);
|
|
} else {
|
|
Parser* value_41 = p;
|
|
String value_42 = StringLiteral("#procedure_name");
|
|
bool value_43 = false;
|
|
{
|
|
Parser* p = value_41;
|
|
String wanted = value_42;
|
|
Parser* value_45 = p;
|
|
String value_46 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_45;
|
|
String value_48 = p->source;
|
|
value_46 = StringRange(value_48, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_46, wanted)) {
|
|
value_43 = false;
|
|
goto value_44;
|
|
}
|
|
Parser* value_49 = p;
|
|
{
|
|
Parser* p = value_49;
|
|
Scan* value_51 = &(p->token);
|
|
Scan value_52 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_51) = value_52;
|
|
int64_t value_53 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_53 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_54 = &(p->failed);
|
|
(*value_54) = true;
|
|
}
|
|
}
|
|
value_43 = true;
|
|
value_44: ;
|
|
}
|
|
if (value_43) {
|
|
if ((int64_t)(scope).length == 0LL) {
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.procedure_name"), StringLiteral("#procedure_name() requires a procedure scope"));
|
|
}
|
|
Parser* value_55 = p;
|
|
String value_56 = StringLiteral("(");
|
|
{
|
|
Parser* p = value_55;
|
|
String wanted = value_56;
|
|
Parser* value_58 = p;
|
|
String value_59 = wanted;
|
|
bool value_60 = false;
|
|
{
|
|
Parser* p = value_58;
|
|
String wanted = value_59;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_60 = false;
|
|
goto value_61;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_60 = true;
|
|
value_61: ;
|
|
}
|
|
if (!value_60) {
|
|
bool* value_62 = &(p->failed);
|
|
(*value_62) = true;
|
|
}
|
|
}
|
|
Parser* value_63 = p;
|
|
String value_64 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_63;
|
|
String wanted = value_64;
|
|
Parser* value_66 = p;
|
|
String value_67 = wanted;
|
|
bool value_68 = false;
|
|
{
|
|
Parser* p = value_66;
|
|
String wanted = value_67;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_68 = false;
|
|
goto value_69;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_68 = true;
|
|
value_69: ;
|
|
}
|
|
if (!value_68) {
|
|
bool* value_70 = &(p->failed);
|
|
(*value_70) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(4), start, StringLiteral(""), StringLiteral(""), -1, -1);
|
|
uint8_t buffer[256] = {0};
|
|
uint8_t* value_71 = &(buffer[0]);
|
|
(*value_71) = 34;
|
|
{
|
|
int64_t range_first_35 = 0LL;
|
|
int64_t range_last_35 = (int64_t)((uint64_t)((int64_t)(scope).length) - UINT64_C(1));
|
|
int64_t i = range_first_35;
|
|
if (i <= range_last_35) for (;;) {
|
|
uint8_t* value_72 = &(ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)((uint64_t)i + UINT64_C(1)))));
|
|
(*value_72) = (uint8_t)scope.data[i];
|
|
if (i == range_last_35) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
uint8_t* value_73 = &(ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)((uint64_t)((int64_t)(scope).length) + UINT64_C(1)))));
|
|
(*value_73) = 34;
|
|
if (result >= 0) {
|
|
const char ** value_74 = &((p->fn->exprs[result]).text);
|
|
Slice value_75 = {buffer, 256};
|
|
Slice value_76 = SliceRange(value_75, (int64_t)0LL, (int64_t)((int64_t)((uint64_t)((int64_t)(scope).length) + UINT64_C(2))), sizeof(uint8_t));
|
|
Slice value_77 = value_76;
|
|
uint8_t* value_78 = compiler_services_Keep(StringView((const char *)(value_77).data, (size_t)(value_77).length));
|
|
(*value_74) = (const char *)(value_78);
|
|
}
|
|
} else {
|
|
Parser* value_79 = p;
|
|
String value_80 = StringLiteral("#char");
|
|
bool value_81 = false;
|
|
{
|
|
Parser* p = value_79;
|
|
String wanted = value_80;
|
|
Parser* value_83 = p;
|
|
String value_84 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_83;
|
|
String value_86 = p->source;
|
|
value_84 = StringRange(value_86, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_84, wanted)) {
|
|
value_81 = false;
|
|
goto value_82;
|
|
}
|
|
Parser* value_87 = p;
|
|
{
|
|
Parser* p = value_87;
|
|
Scan* value_89 = &(p->token);
|
|
Scan value_90 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_89) = value_90;
|
|
int64_t value_91 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_91 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_92 = &(p->failed);
|
|
(*value_92) = true;
|
|
}
|
|
}
|
|
value_81 = true;
|
|
value_82: ;
|
|
}
|
|
if (value_81) {
|
|
Parser* value_93 = p;
|
|
String value_94 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_93;
|
|
String value_96 = p->source;
|
|
value_94 = StringRange(value_96, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
int32_t byte = compiler_expression_CharacterByte(value_94);
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(4)) || byte < 0) {
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_char"), StringLiteral("#char requires a one-byte string literal"));
|
|
}
|
|
Parser* value_97 = p;
|
|
{
|
|
Parser* p = value_97;
|
|
Scan* value_99 = &(p->token);
|
|
Scan value_100 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_99) = value_100;
|
|
int64_t value_101 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_101 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_102 = &(p->failed);
|
|
(*value_102) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(2), start, StringLiteral(""), StringLiteral(""), -1, -1);
|
|
uint8_t digits[4] = {0};
|
|
if (result >= 0) {
|
|
const char ** value_103 = &((p->fn->exprs[result]).text);
|
|
Slice value_104 = {digits, 4};
|
|
Slice value_105 = {digits, 4};
|
|
int64_t value_106 = compiler_parse_Decimal(value_105, (int64_t)(byte));
|
|
Slice value_107 = SliceRange(value_104, (int64_t)0LL, (int64_t)value_106, sizeof(uint8_t));
|
|
uint8_t* value_108 = compiler_services_Keep(StringView((const char *)(value_107).data, (size_t)(value_107).length));
|
|
(*value_103) = (const char *)(value_108);
|
|
}
|
|
} else {
|
|
Parser* value_109 = p;
|
|
String value_110 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_109;
|
|
String value_112 = p->source;
|
|
value_110 = StringRange(value_112, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_113 = StringEqual(value_110, StringLiteral("ifx"));
|
|
if (!value_113) {
|
|
Parser* value_114 = p;
|
|
String value_115 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_114;
|
|
String value_117 = p->source;
|
|
value_115 = StringRange(value_117, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_113 = (StringEqual(value_115, StringLiteral("#ifx")));
|
|
}
|
|
if (value_113) {
|
|
String op = StringLiteral("ifx");
|
|
Parser* value_118 = p;
|
|
String value_119 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_118;
|
|
String value_121 = p->source;
|
|
value_119 = StringRange(value_121, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_119, StringLiteral("#ifx"))) {
|
|
op = StringLiteral("#ifx");
|
|
}
|
|
Parser* value_122 = p;
|
|
{
|
|
Parser* p = value_122;
|
|
Scan* value_124 = &(p->token);
|
|
Scan value_125 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_124) = value_125;
|
|
int64_t value_126 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_126 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_127 = &(p->failed);
|
|
(*value_127) = true;
|
|
}
|
|
}
|
|
int32_t condition = compiler_parse_ParseBinary(p, 2);
|
|
Parser* value_128 = p;
|
|
String value_129 = StringLiteral("then");
|
|
bool value_130 = false;
|
|
{
|
|
Parser* p = value_128;
|
|
String wanted = value_129;
|
|
Parser* value_132 = p;
|
|
String value_133 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_132;
|
|
String value_135 = p->source;
|
|
value_133 = StringRange(value_135, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_133, wanted)) {
|
|
value_130 = false;
|
|
goto value_131;
|
|
}
|
|
Parser* value_136 = p;
|
|
{
|
|
Parser* p = value_136;
|
|
Scan* value_138 = &(p->token);
|
|
Scan value_139 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_138) = value_139;
|
|
int64_t value_140 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_140 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_141 = &(p->failed);
|
|
(*value_141) = true;
|
|
}
|
|
}
|
|
value_130 = true;
|
|
value_131: ;
|
|
}
|
|
(void)value_130;
|
|
int32_t selected = compiler_parse_ParseBinary(p, 1);
|
|
Parser* value_142 = p;
|
|
String value_143 = StringLiteral(";");
|
|
bool value_144 = false;
|
|
{
|
|
Parser* p = value_142;
|
|
String wanted = value_143;
|
|
Parser* value_146 = p;
|
|
String value_147 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_146;
|
|
String value_149 = p->source;
|
|
value_147 = StringRange(value_149, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_147, wanted)) {
|
|
value_144 = false;
|
|
goto value_145;
|
|
}
|
|
Parser* value_150 = p;
|
|
{
|
|
Parser* p = value_150;
|
|
Scan* value_152 = &(p->token);
|
|
Scan value_153 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_152) = value_153;
|
|
int64_t value_154 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_154 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_155 = &(p->failed);
|
|
(*value_155) = true;
|
|
}
|
|
}
|
|
value_144 = true;
|
|
value_145: ;
|
|
}
|
|
(void)value_144;
|
|
Parser* value_156 = p;
|
|
String value_157 = StringLiteral("else");
|
|
{
|
|
Parser* p = value_156;
|
|
String wanted = value_157;
|
|
Parser* value_159 = p;
|
|
String value_160 = wanted;
|
|
bool value_161 = false;
|
|
{
|
|
Parser* p = value_159;
|
|
String wanted = value_160;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_161 = false;
|
|
goto value_162;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_161 = true;
|
|
value_162: ;
|
|
}
|
|
if (!value_161) {
|
|
bool* value_163 = &(p->failed);
|
|
(*value_163) = true;
|
|
}
|
|
}
|
|
int32_t alternative = compiler_parse_ParseBinary(p, 1);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(14), start, StringLiteral(""), op, condition, selected);
|
|
if (result >= 0) {
|
|
int32_t* value_164 = &((p->fn->exprs[result]).third);
|
|
(*value_164) = alternative;
|
|
}
|
|
} else {
|
|
Parser* value_165 = p;
|
|
String value_166 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_165;
|
|
String value_168 = p->source;
|
|
value_166 = StringRange(value_168, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_166, StringLiteral("sizeof"))) {
|
|
Parser* value_169 = p;
|
|
String value_170 = StringLiteral("sizeof is not Jai syntax; use size_of(Type)");
|
|
{
|
|
Parser* p = value_169;
|
|
String message = value_170;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_172 = p;
|
|
String value_173 = StringLiteral("size_of");
|
|
bool value_174 = false;
|
|
{
|
|
Parser* p = value_172;
|
|
String wanted = value_173;
|
|
Parser* value_176 = p;
|
|
String value_177 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_176;
|
|
String value_179 = p->source;
|
|
value_177 = StringRange(value_179, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_177, wanted)) {
|
|
value_174 = false;
|
|
goto value_175;
|
|
}
|
|
Parser* value_180 = p;
|
|
{
|
|
Parser* p = value_180;
|
|
Scan* value_182 = &(p->token);
|
|
Scan value_183 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_182) = value_183;
|
|
int64_t value_184 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_184 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_185 = &(p->failed);
|
|
(*value_185) = true;
|
|
}
|
|
}
|
|
value_174 = true;
|
|
value_175: ;
|
|
}
|
|
if (value_174) {
|
|
Parser* value_186 = p;
|
|
String value_187 = StringLiteral("(");
|
|
{
|
|
Parser* p = value_186;
|
|
String wanted = value_187;
|
|
Parser* value_189 = p;
|
|
String value_190 = wanted;
|
|
bool value_191 = false;
|
|
{
|
|
Parser* p = value_189;
|
|
String wanted = value_190;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_191 = false;
|
|
goto value_192;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_191 = true;
|
|
value_192: ;
|
|
}
|
|
if (!value_191) {
|
|
bool* value_193 = &(p->failed);
|
|
(*value_193) = true;
|
|
}
|
|
}
|
|
int64_t type_start = p->token.begin;
|
|
int32_t nested = 0;
|
|
while (((TokenKind)(p->token.kind)) != ((TokenKind)(0))) {
|
|
Parser* value_194 = p;
|
|
String value_195 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_194;
|
|
String value_197 = p->source;
|
|
value_195 = StringRange(value_197, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (((StringEqual(value_195, StringLiteral(")"))) && nested == 0)) {
|
|
break;
|
|
}
|
|
Parser* value_198 = p;
|
|
String value_199 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_198;
|
|
String value_201 = p->source;
|
|
value_199 = StringRange(value_201, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if ((StringEqual(value_199, StringLiteral("(")))) {
|
|
nested = (int32_t)((uint32_t)nested + 1u);
|
|
}
|
|
Parser* value_202 = p;
|
|
String value_203 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_202;
|
|
String value_205 = p->source;
|
|
value_203 = StringRange(value_205, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if ((StringEqual(value_203, StringLiteral(")")))) {
|
|
nested = (int32_t)((uint32_t)nested - 1u);
|
|
}
|
|
Parser* value_206 = p;
|
|
{
|
|
Parser* p = value_206;
|
|
Scan* value_208 = &(p->token);
|
|
Scan value_209 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_208) = value_209;
|
|
int64_t value_210 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_210 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_211 = &(p->failed);
|
|
(*value_211) = true;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_212 = p;
|
|
String value_213 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_212;
|
|
int64_t start = type_start;
|
|
int64_t end = p->token.begin;
|
|
if (start < 0LL || end < start || (int64_t)((uint64_t)end - (uint64_t)start) >= 128LL) {
|
|
bool* value_215 = &(p->failed);
|
|
(*value_215) = true;
|
|
value_213 = StringLiteral("");
|
|
goto value_214;
|
|
}
|
|
String value_216 = p->source;
|
|
String value_217 = StringRange(value_216, (int64_t)start, (int64_t)end);
|
|
String value_218 = StringView(NULL, 0);
|
|
{
|
|
String source = value_217;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_218 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
value_213 = value_218;
|
|
value_214: ;
|
|
}
|
|
String type = value_213;
|
|
Parser* value_220 = p;
|
|
String value_221 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_220;
|
|
String wanted = value_221;
|
|
Parser* value_223 = p;
|
|
String value_224 = wanted;
|
|
bool value_225 = false;
|
|
{
|
|
Parser* p = value_223;
|
|
String wanted = value_224;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_225 = false;
|
|
goto value_226;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_225 = true;
|
|
value_226: ;
|
|
}
|
|
if (!value_225) {
|
|
bool* value_227 = &(p->failed);
|
|
(*value_227) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(13), start, type, StringLiteral(""), -1, -1);
|
|
} else {
|
|
Parser* value_228 = p;
|
|
String value_229 = StringLiteral("cast");
|
|
bool value_230 = false;
|
|
{
|
|
Parser* p = value_228;
|
|
String wanted = value_229;
|
|
Parser* value_232 = p;
|
|
String value_233 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_232;
|
|
String value_235 = p->source;
|
|
value_233 = StringRange(value_235, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_233, wanted)) {
|
|
value_230 = false;
|
|
goto value_231;
|
|
}
|
|
Parser* value_236 = p;
|
|
{
|
|
Parser* p = value_236;
|
|
Scan* value_238 = &(p->token);
|
|
Scan value_239 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_238) = value_239;
|
|
int64_t value_240 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_240 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_241 = &(p->failed);
|
|
(*value_241) = true;
|
|
}
|
|
}
|
|
value_230 = true;
|
|
value_231: ;
|
|
}
|
|
if (value_230) {
|
|
Parser* value_242 = p;
|
|
String value_243 = StringLiteral("(");
|
|
{
|
|
Parser* p = value_242;
|
|
String wanted = value_243;
|
|
Parser* value_245 = p;
|
|
String value_246 = wanted;
|
|
bool value_247 = false;
|
|
{
|
|
Parser* p = value_245;
|
|
String wanted = value_246;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_247 = false;
|
|
goto value_248;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_247 = true;
|
|
value_248: ;
|
|
}
|
|
if (!value_247) {
|
|
bool* value_249 = &(p->failed);
|
|
(*value_249) = true;
|
|
}
|
|
}
|
|
int64_t type_start = p->token.begin;
|
|
Parser* value_250 = p;
|
|
String value_251 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_250;
|
|
String value_253 = p->source;
|
|
value_251 = StringRange(value_253, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_251, StringLiteral("char"))) {
|
|
Parser* value_254 = p;
|
|
String value_255 = StringLiteral("non-Jai primitive type spelling: char");
|
|
{
|
|
Parser* p = value_254;
|
|
String message = value_255;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
while (true) {
|
|
bool value_257 = ((TokenKind)(p->token.kind)) != ((TokenKind)(0));
|
|
bool value_258 = value_257;
|
|
if (value_258) {
|
|
Parser* value_259 = p;
|
|
String value_260 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_259;
|
|
String value_262 = p->source;
|
|
value_260 = StringRange(value_262, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_258 = (!StringEqual(value_260, StringLiteral(")")));
|
|
}
|
|
if (!value_258) { break; }
|
|
Parser* value_263 = p;
|
|
{
|
|
Parser* p = value_263;
|
|
Scan* value_265 = &(p->token);
|
|
Scan value_266 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_265) = value_266;
|
|
int64_t value_267 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_267 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_268 = &(p->failed);
|
|
(*value_268) = true;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_269 = p;
|
|
String value_270 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_269;
|
|
int64_t start = type_start;
|
|
int64_t end = p->token.begin;
|
|
if (start < 0LL || end < start || (int64_t)((uint64_t)end - (uint64_t)start) >= 128LL) {
|
|
bool* value_272 = &(p->failed);
|
|
(*value_272) = true;
|
|
value_270 = StringLiteral("");
|
|
goto value_271;
|
|
}
|
|
String value_273 = p->source;
|
|
String value_274 = StringRange(value_273, (int64_t)start, (int64_t)end);
|
|
String value_275 = StringView(NULL, 0);
|
|
{
|
|
String source = value_274;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_275 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
value_270 = value_275;
|
|
value_271: ;
|
|
}
|
|
String type = value_270;
|
|
Parser* value_277 = p;
|
|
bool value_278 = false;
|
|
{
|
|
Parser* p = value_277;
|
|
String name = type;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_278 = false;
|
|
goto value_279;
|
|
}
|
|
String value_280 = name;
|
|
bool value_281 = false;
|
|
{
|
|
String name = value_280;
|
|
bool value_283 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_281 = value_283 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_284 = value_281;
|
|
if (!value_284) {
|
|
bool value_285 = p->module != ((void *)0);
|
|
bool value_286 = value_285;
|
|
if (value_286) {
|
|
ZirType* value_287 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_286 = (value_287 != ((void *)0));
|
|
}
|
|
value_284 = value_286;
|
|
}
|
|
value_278 = value_284;
|
|
value_279: ;
|
|
}
|
|
if (!value_278 && ((int64_t)(type).length == 0LL || ((uint8_t)ZIRAN_INDEX(type.data, type.length, 0) != 91 && (uint8_t)ZIRAN_INDEX(type.data, type.length, 0) != 42))) {
|
|
bool* value_288 = &(p->failed);
|
|
(*value_288) = true;
|
|
}
|
|
Parser* value_289 = p;
|
|
String value_290 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_289;
|
|
String wanted = value_290;
|
|
Parser* value_292 = p;
|
|
String value_293 = wanted;
|
|
bool value_294 = false;
|
|
{
|
|
Parser* p = value_292;
|
|
String wanted = value_293;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_294 = false;
|
|
goto value_295;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_294 = true;
|
|
value_295: ;
|
|
}
|
|
if (!value_294) {
|
|
bool* value_296 = &(p->failed);
|
|
(*value_296) = true;
|
|
}
|
|
}
|
|
int32_t right = compiler_parse_ParsePrefix(p);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(11), start, type, StringLiteral(""), -1, right);
|
|
} else {
|
|
Parser* value_297 = p;
|
|
String value_298 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_297;
|
|
String value_300 = p->source;
|
|
value_298 = StringRange(value_300, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_301 = StringEqual(value_298, StringLiteral("++"));
|
|
if (!value_301) {
|
|
Parser* value_302 = p;
|
|
String value_303 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_302;
|
|
String value_305 = p->source;
|
|
value_303 = StringRange(value_305, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_301 = (StringEqual(value_303, StringLiteral("--")));
|
|
}
|
|
if (value_301) {
|
|
Parser* value_306 = p;
|
|
String value_307 = StringLiteral("Jai has no increment or decrement operators; use += 1 or -= 1");
|
|
{
|
|
Parser* p = value_306;
|
|
String message = value_307;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_309 = p;
|
|
String value_310 = StringLiteral("<<");
|
|
bool value_311 = false;
|
|
{
|
|
Parser* p = value_309;
|
|
String wanted = value_310;
|
|
Parser* value_313 = p;
|
|
String value_314 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_313;
|
|
String value_316 = p->source;
|
|
value_314 = StringRange(value_316, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_314, wanted)) {
|
|
value_311 = false;
|
|
goto value_312;
|
|
}
|
|
Parser* value_317 = p;
|
|
{
|
|
Parser* p = value_317;
|
|
Scan* value_319 = &(p->token);
|
|
Scan value_320 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_319) = value_320;
|
|
int64_t value_321 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_321 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_322 = &(p->failed);
|
|
(*value_322) = true;
|
|
}
|
|
}
|
|
value_311 = true;
|
|
value_312: ;
|
|
}
|
|
if (value_311) {
|
|
int32_t right = compiler_parse_ParsePrefix(p);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(7), start, StringLiteral(""), StringLiteral("*"), -1, right);
|
|
} else {
|
|
Parser* value_323 = p;
|
|
String value_324 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_323;
|
|
String value_326 = p->source;
|
|
value_324 = StringRange(value_326, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_327 = StringEqual(value_324, StringLiteral("+"));
|
|
if (!value_327) {
|
|
Parser* value_328 = p;
|
|
String value_329 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_328;
|
|
String value_331 = p->source;
|
|
value_329 = StringRange(value_331, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_327 = (StringEqual(value_329, StringLiteral("-")));
|
|
}
|
|
bool value_332 = value_327;
|
|
if (!value_332) {
|
|
Parser* value_333 = p;
|
|
String value_334 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_333;
|
|
String value_336 = p->source;
|
|
value_334 = StringRange(value_336, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_332 = (StringEqual(value_334, StringLiteral("!")));
|
|
}
|
|
bool value_337 = value_332;
|
|
if (!value_337) {
|
|
Parser* value_338 = p;
|
|
String value_339 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_338;
|
|
String value_341 = p->source;
|
|
value_339 = StringRange(value_341, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_337 = (StringEqual(value_339, StringLiteral("~")));
|
|
}
|
|
bool value_342 = value_337;
|
|
if (!value_342) {
|
|
Parser* value_343 = p;
|
|
String value_344 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_343;
|
|
String value_346 = p->source;
|
|
value_344 = StringRange(value_346, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_342 = (StringEqual(value_344, StringLiteral("*")));
|
|
}
|
|
if (value_342) {
|
|
Parser* value_347 = p;
|
|
String value_348 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_347;
|
|
String value_350 = p->source;
|
|
value_348 = StringRange(value_350, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String value_351 = StringView(NULL, 0);
|
|
{
|
|
String operator = value_348;
|
|
if (StringEqual(operator, StringLiteral("*"))) {
|
|
value_351 = StringLiteral("&");
|
|
goto value_352;
|
|
}
|
|
if (StringEqual(operator, StringLiteral("+"))) {
|
|
value_351 = StringLiteral("+");
|
|
goto value_352;
|
|
}
|
|
if (StringEqual(operator, StringLiteral("-"))) {
|
|
value_351 = StringLiteral("-");
|
|
goto value_352;
|
|
}
|
|
if (StringEqual(operator, StringLiteral("!"))) {
|
|
value_351 = StringLiteral("!");
|
|
goto value_352;
|
|
}
|
|
value_351 = StringLiteral("~");
|
|
value_352: ;
|
|
}
|
|
String op = value_351;
|
|
Parser* value_353 = p;
|
|
{
|
|
Parser* p = value_353;
|
|
Scan* value_355 = &(p->token);
|
|
Scan value_356 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_355) = value_356;
|
|
int64_t value_357 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_357 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_358 = &(p->failed);
|
|
(*value_358) = true;
|
|
}
|
|
}
|
|
int32_t right = compiler_parse_ParsePrefix(p);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(7), start, StringLiteral(""), op, -1, right);
|
|
} else {
|
|
Parser* value_359 = p;
|
|
String value_360 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_359;
|
|
String value_362 = p->source;
|
|
value_360 = StringRange(value_362, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_360, StringLiteral("&"))) {
|
|
Parser* value_363 = p;
|
|
String value_364 = StringLiteral("C-style address-of is not valid Jai syntax; use *value");
|
|
{
|
|
Parser* p = value_363;
|
|
String message = value_364;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_366 = p;
|
|
String value_367 = StringLiteral("(");
|
|
bool value_368 = false;
|
|
{
|
|
Parser* p = value_366;
|
|
String wanted = value_367;
|
|
Parser* value_370 = p;
|
|
String value_371 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_370;
|
|
String value_373 = p->source;
|
|
value_371 = StringRange(value_373, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_371, wanted)) {
|
|
value_368 = false;
|
|
goto value_369;
|
|
}
|
|
Parser* value_374 = p;
|
|
{
|
|
Parser* p = value_374;
|
|
Scan* value_376 = &(p->token);
|
|
Scan value_377 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_376) = value_377;
|
|
int64_t value_378 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_378 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_379 = &(p->failed);
|
|
(*value_379) = true;
|
|
}
|
|
}
|
|
value_368 = true;
|
|
value_369: ;
|
|
}
|
|
if (value_368) {
|
|
Parser* value_380 = p;
|
|
Parser* value_381 = p;
|
|
String value_382 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_381;
|
|
String value_384 = p->source;
|
|
value_382 = StringRange(value_384, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_385 = false;
|
|
{
|
|
Parser* p = value_380;
|
|
String name = value_382;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_385 = false;
|
|
goto value_386;
|
|
}
|
|
String value_387 = name;
|
|
bool value_388 = false;
|
|
{
|
|
String name = value_387;
|
|
bool value_390 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_388 = value_390 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_391 = value_388;
|
|
if (!value_391) {
|
|
bool value_392 = p->module != ((void *)0);
|
|
bool value_393 = value_392;
|
|
if (value_393) {
|
|
ZirType* value_394 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_393 = (value_394 != ((void *)0));
|
|
}
|
|
value_391 = value_393;
|
|
}
|
|
value_385 = value_391;
|
|
value_386: ;
|
|
}
|
|
bool value_395 = value_385;
|
|
if (!value_395) {
|
|
Parser* value_396 = p;
|
|
String value_397 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_396;
|
|
String value_399 = p->source;
|
|
value_397 = StringRange(value_399, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_395 = (StringEqual(value_397, StringLiteral("[")));
|
|
}
|
|
bool typed = value_395;
|
|
bool value_400 = typed;
|
|
bool value_401 = value_400;
|
|
if (value_401) {
|
|
Parser* value_402 = p;
|
|
String value_403 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_402;
|
|
String value_405 = p->source;
|
|
value_403 = StringRange(value_405, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_401 = (!StringEqual(value_403, StringLiteral(".")));
|
|
}
|
|
bool value_406 = value_401;
|
|
bool value_407 = value_406 && !StringEqual(compiler_parse_Following(p, 1), StringLiteral("."));
|
|
bool value_408 = value_407;
|
|
bool value_409 = value_408;
|
|
if (value_409) {
|
|
bool value_410 = compiler_parse_ArrayLiteralAhead(p);
|
|
value_409 = !value_410;
|
|
}
|
|
if (value_409) {
|
|
Parser* value_411 = p;
|
|
String value_412 = StringLiteral("C-style cast or literal is not valid Jai syntax; use cast(Type) value or Type.{...}");
|
|
{
|
|
Parser* p = value_411;
|
|
String message = value_412;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
result = compiler_parse_ParseBinary(p, 1);
|
|
Parser* value_414 = p;
|
|
String value_415 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_414;
|
|
String wanted = value_415;
|
|
Parser* value_417 = p;
|
|
String value_418 = wanted;
|
|
bool value_419 = false;
|
|
{
|
|
Parser* p = value_417;
|
|
String wanted = value_418;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_419 = false;
|
|
goto value_420;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_419 = true;
|
|
value_420: ;
|
|
}
|
|
if (!value_419) {
|
|
bool* value_421 = &(p->failed);
|
|
(*value_421) = true;
|
|
}
|
|
}
|
|
bool value_422 = !typed;
|
|
bool value_423 = value_422;
|
|
if (value_423) {
|
|
Parser* value_424 = p;
|
|
String value_425 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_424;
|
|
String value_427 = p->source;
|
|
value_425 = StringRange(value_427, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_423 = (StringEqual(value_425, StringLiteral("{")));
|
|
}
|
|
if (value_423) {
|
|
Parser* value_428 = p;
|
|
String value_429 = StringLiteral("C-style literal is not valid Jai syntax; use Type.{...}");
|
|
{
|
|
Parser* p = value_428;
|
|
String message = value_429;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
} else {
|
|
Parser* value_431 = p;
|
|
String value_432 = StringLiteral(".");
|
|
bool value_433 = false;
|
|
{
|
|
Parser* p = value_431;
|
|
String wanted = value_432;
|
|
Parser* value_435 = p;
|
|
String value_436 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_435;
|
|
String value_438 = p->source;
|
|
value_436 = StringRange(value_438, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_436, wanted)) {
|
|
value_433 = false;
|
|
goto value_434;
|
|
}
|
|
Parser* value_439 = p;
|
|
{
|
|
Parser* p = value_439;
|
|
Scan* value_441 = &(p->token);
|
|
Scan value_442 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_441) = value_442;
|
|
int64_t value_443 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_443 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_444 = &(p->failed);
|
|
(*value_444) = true;
|
|
}
|
|
}
|
|
value_433 = true;
|
|
value_434: ;
|
|
}
|
|
if (value_433) {
|
|
Parser* value_445 = p;
|
|
String value_446 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_445;
|
|
String value_448 = p->source;
|
|
value_446 = StringRange(value_448, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_446, StringLiteral("{"))) {
|
|
result = compiler_parse_ParseInitializer(p, start, StringLiteral(""), StringLiteral("{"), StringLiteral("}"));
|
|
} else {
|
|
Parser* value_449 = p;
|
|
String value_450 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_449;
|
|
String value_452 = p->source;
|
|
value_450 = StringRange(value_452, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_453 = StringEqual(value_450, StringLiteral("["));
|
|
if (value_453) {
|
|
String value_454 = p->expected_type;
|
|
bool value_455 = false;
|
|
{
|
|
String name = value_454;
|
|
String value_457 = StringView(NULL, 0);
|
|
{
|
|
String text = name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_457 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_458;
|
|
}
|
|
value_457 = text;
|
|
value_458: ;
|
|
}
|
|
ElementType value_459 = compiler_type_ArrayElement(value_457);
|
|
value_455 = value_459.valid;
|
|
}
|
|
value_453 = value_455;
|
|
}
|
|
if (value_453) {
|
|
result = compiler_parse_ParseInitializer(p, start, p->expected_type, StringLiteral("["), StringLiteral("]"));
|
|
} else if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
bool* value_460 = &(p->failed);
|
|
(*value_460) = true;
|
|
} else {
|
|
uint8_t buffer[256] = {0};
|
|
Slice value_461 = {buffer, 256};
|
|
Slice value_462 = value_461;
|
|
Parser* value_463 = p;
|
|
String value_464 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_463;
|
|
String value_466 = p->source;
|
|
value_464 = StringRange(value_466, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String name = compiler_parse_QualifiedName(value_462, StringLiteral(""), value_464, 128LL);
|
|
if ((int64_t)(name).length == 0LL) {
|
|
bool* value_467 = &(p->failed);
|
|
(*value_467) = true;
|
|
}
|
|
Parser* value_468 = p;
|
|
{
|
|
Parser* p = value_468;
|
|
Scan* value_470 = &(p->token);
|
|
Scan value_471 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_470) = value_471;
|
|
int64_t value_472 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_472 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_473 = &(p->failed);
|
|
(*value_473) = true;
|
|
}
|
|
}
|
|
if (!p->failed) {
|
|
result = compiler_parse_Node(p, (ZirExprKind)(1), start, name, StringLiteral(""), -1, -1);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
Parser* value_474 = p;
|
|
String value_475 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_474;
|
|
String value_477 = p->source;
|
|
value_475 = StringRange(value_477, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_475, StringLiteral("["))) {
|
|
int64_t type_start = p->token.begin;
|
|
while (true) {
|
|
Parser* value_478 = p;
|
|
String value_479 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_478;
|
|
String value_481 = p->source;
|
|
value_479 = StringRange(value_481, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!(StringEqual(value_479, StringLiteral("[")) && !p->failed)) { break; }
|
|
Parser* value_482 = p;
|
|
{
|
|
Parser* p = value_482;
|
|
Scan* value_484 = &(p->token);
|
|
Scan value_485 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_484) = value_485;
|
|
int64_t value_486 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_486 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_487 = &(p->failed);
|
|
(*value_487) = true;
|
|
}
|
|
}
|
|
Parser* value_488 = p;
|
|
String value_489 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_488;
|
|
String value_491 = p->source;
|
|
value_489 = StringRange(value_491, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_489, StringLiteral("]"))) {
|
|
bool* value_492 = &(p->failed);
|
|
(*value_492) = true;
|
|
}
|
|
Parser* value_493 = p;
|
|
{
|
|
Parser* p = value_493;
|
|
Scan* value_495 = &(p->token);
|
|
Scan value_496 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_495) = value_496;
|
|
int64_t value_497 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_497 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_498 = &(p->failed);
|
|
(*value_498) = true;
|
|
}
|
|
}
|
|
Parser* value_499 = p;
|
|
String value_500 = StringLiteral("]");
|
|
{
|
|
Parser* p = value_499;
|
|
String wanted = value_500;
|
|
Parser* value_502 = p;
|
|
String value_503 = wanted;
|
|
bool value_504 = false;
|
|
{
|
|
Parser* p = value_502;
|
|
String wanted = value_503;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_504 = false;
|
|
goto value_505;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_504 = true;
|
|
value_505: ;
|
|
}
|
|
if (!value_504) {
|
|
bool* value_506 = &(p->failed);
|
|
(*value_506) = true;
|
|
}
|
|
}
|
|
}
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
bool* value_507 = &(p->failed);
|
|
(*value_507) = true;
|
|
}
|
|
Parser* value_508 = p;
|
|
{
|
|
Parser* p = value_508;
|
|
Scan* value_510 = &(p->token);
|
|
Scan value_511 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_510) = value_511;
|
|
int64_t value_512 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_512 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_513 = &(p->failed);
|
|
(*value_513) = true;
|
|
}
|
|
}
|
|
Parser* value_514 = p;
|
|
String value_515 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_514;
|
|
String value_517 = p->source;
|
|
value_515 = StringRange(value_517, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_518 = StringEqual(value_515, StringLiteral(".")) && ((TokenKind)(p->token.kind)) != ((TokenKind)(0));
|
|
if (value_518 && !StringEqual(compiler_parse_Following(p, 1), StringLiteral("["))) {
|
|
Parser* value_519 = p;
|
|
{
|
|
Parser* p = value_519;
|
|
Scan* value_521 = &(p->token);
|
|
Scan value_522 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_521) = value_522;
|
|
int64_t value_523 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_523 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_524 = &(p->failed);
|
|
(*value_524) = true;
|
|
}
|
|
}
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
bool* value_525 = &(p->failed);
|
|
(*value_525) = true;
|
|
}
|
|
Parser* value_526 = p;
|
|
{
|
|
Parser* p = value_526;
|
|
Scan* value_528 = &(p->token);
|
|
Scan value_529 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_528) = value_529;
|
|
int64_t value_530 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_530 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_531 = &(p->failed);
|
|
(*value_531) = true;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_532 = p;
|
|
String value_533 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_532;
|
|
int64_t start = type_start;
|
|
int64_t end = p->token.begin;
|
|
if (start < 0LL || end < start || (int64_t)((uint64_t)end - (uint64_t)start) >= 128LL) {
|
|
bool* value_535 = &(p->failed);
|
|
(*value_535) = true;
|
|
value_533 = StringLiteral("");
|
|
goto value_534;
|
|
}
|
|
String value_536 = p->source;
|
|
String value_537 = StringRange(value_536, (int64_t)start, (int64_t)end);
|
|
String value_538 = StringView(NULL, 0);
|
|
{
|
|
String source = value_537;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_538 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
value_533 = value_538;
|
|
value_534: ;
|
|
}
|
|
String type = value_533;
|
|
bool value_540 = !p->failed;
|
|
bool value_541 = value_540;
|
|
if (value_541) {
|
|
Parser* value_542 = p;
|
|
String value_543 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_542;
|
|
String value_545 = p->source;
|
|
value_543 = StringRange(value_545, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_541 = (StringEqual(value_543, StringLiteral(".")));
|
|
}
|
|
bool value_546 = value_541;
|
|
bool value_547 = value_546 && StringEqual(compiler_parse_Following(p, 1), StringLiteral("["));
|
|
bool value_548 = value_547;
|
|
bool value_549 = value_548;
|
|
if (value_549) {
|
|
bool value_550 = false;
|
|
{
|
|
String name = type;
|
|
String value_552 = StringView(NULL, 0);
|
|
{
|
|
String text = name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_552 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_553;
|
|
}
|
|
value_552 = text;
|
|
value_553: ;
|
|
}
|
|
ElementType value_554 = compiler_type_ArrayElement(value_552);
|
|
value_550 = value_554.valid;
|
|
}
|
|
value_549 = value_550;
|
|
}
|
|
if (value_549) {
|
|
Parser* value_555 = p;
|
|
{
|
|
Parser* p = value_555;
|
|
Scan* value_557 = &(p->token);
|
|
Scan value_558 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_557) = value_558;
|
|
int64_t value_559 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_559 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_560 = &(p->failed);
|
|
(*value_560) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_TypedArray(p, start, type);
|
|
} else {
|
|
bool* value_561 = &(p->failed);
|
|
(*value_561) = true;
|
|
}
|
|
} else {
|
|
ZirExprKind kind = (ZirExprKind)((ZirExprKind)(1));
|
|
if (original_kind == ((TokenKind)(2))) {
|
|
kind = (ZirExprKind)(2);
|
|
} else if (original_kind == ((TokenKind)(3))) {
|
|
kind = (ZirExprKind)(3);
|
|
} else if (original_kind == ((TokenKind)(4))) {
|
|
kind = (ZirExprKind)(4);
|
|
} else if (original_kind == ((TokenKind)(5))) {
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_char"), StringLiteral("single-quoted character literals are not valid Jai syntax; use #char \"x\""));
|
|
} else if (original_kind != ((TokenKind)(1))) {
|
|
bool* value_562 = &(p->failed);
|
|
(*value_562) = true;
|
|
int32_t* value_563 = &(p->depth);
|
|
(*value_563) = (int32_t)((uint32_t)((*value_563)) - 1u);
|
|
return -1;
|
|
}
|
|
Parser* value_564 = p;
|
|
{
|
|
Parser* p = value_564;
|
|
Scan* value_566 = &(p->token);
|
|
Scan value_567 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_566) = value_567;
|
|
int64_t value_568 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_568 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_569 = &(p->failed);
|
|
(*value_569) = true;
|
|
}
|
|
}
|
|
bool value_570 = kind == ((ZirExprKind)(1));
|
|
bool value_571 = value_570;
|
|
if (value_571) {
|
|
Parser* value_572 = p;
|
|
String value_573 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_572;
|
|
String value_575 = p->source;
|
|
value_573 = StringRange(value_575, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_571 = (StringEqual(value_573, StringLiteral(".")));
|
|
}
|
|
if (value_571) {
|
|
String following = compiler_parse_Following(p, 1);
|
|
if (StringEqual(following, StringLiteral("{"))) {
|
|
Parser* value_576 = p;
|
|
bool value_577 = false;
|
|
{
|
|
Parser* p = value_576;
|
|
String name = original;
|
|
if ((int64_t)(name).length >= 128LL || p->module == ((void *)0)) {
|
|
value_577 = false;
|
|
goto value_578;
|
|
}
|
|
ZirType* record = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_577 = record != ((void *)0) && record->is_enum == 0;
|
|
value_578: ;
|
|
}
|
|
if (!value_577) {
|
|
bool* value_579 = &(p->failed);
|
|
(*value_579) = true;
|
|
}
|
|
Parser* value_580 = p;
|
|
{
|
|
Parser* p = value_580;
|
|
Scan* value_582 = &(p->token);
|
|
Scan value_583 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_582) = value_583;
|
|
int64_t value_584 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_584 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_585 = &(p->failed);
|
|
(*value_585) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_ParseInitializer(p, start, original, StringLiteral("{"), StringLiteral("}"));
|
|
} else {
|
|
bool value_586 = StringEqual(following, StringLiteral("["));
|
|
bool value_587 = value_586;
|
|
if (value_587) {
|
|
Parser* value_588 = p;
|
|
bool value_589 = false;
|
|
{
|
|
Parser* p = value_588;
|
|
String name = original;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_589 = false;
|
|
goto value_590;
|
|
}
|
|
String value_591 = name;
|
|
bool value_592 = false;
|
|
{
|
|
String name = value_591;
|
|
bool value_594 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_592 = value_594 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_595 = value_592;
|
|
if (!value_595) {
|
|
bool value_596 = p->module != ((void *)0);
|
|
bool value_597 = value_596;
|
|
if (value_597) {
|
|
ZirType* value_598 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_597 = (value_598 != ((void *)0));
|
|
}
|
|
value_595 = value_597;
|
|
}
|
|
value_589 = value_595;
|
|
value_590: ;
|
|
}
|
|
value_587 = value_589;
|
|
}
|
|
if (value_587) {
|
|
Parser* value_599 = p;
|
|
{
|
|
Parser* p = value_599;
|
|
Scan* value_601 = &(p->token);
|
|
Scan value_602 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_601) = value_602;
|
|
int64_t value_603 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_603 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_604 = &(p->failed);
|
|
(*value_604) = true;
|
|
}
|
|
}
|
|
result = compiler_parse_TypedArray(p, start, original);
|
|
} else {
|
|
Scan value_605 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
if (((TokenKind)(value_605.kind)) == ((TokenKind)(1)) && StringEqual(compiler_parse_Following(p, 2), StringLiteral("."))) {
|
|
uint8_t buffer[256] = {0};
|
|
Slice value_606 = {buffer, 256};
|
|
String qualified = compiler_parse_QualifiedName(value_606, original, following, 128LL);
|
|
String opener = compiler_parse_Following(p, 3);
|
|
bool value_607 = (int64_t)(qualified).length > 0LL;
|
|
bool value_608 = value_607;
|
|
if (value_608) {
|
|
Parser* value_609 = p;
|
|
bool value_610 = false;
|
|
{
|
|
Parser* p = value_609;
|
|
String name = qualified;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_610 = false;
|
|
goto value_611;
|
|
}
|
|
String value_612 = name;
|
|
bool value_613 = false;
|
|
{
|
|
String name = value_612;
|
|
bool value_615 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_613 = value_615 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_616 = value_613;
|
|
if (!value_616) {
|
|
bool value_617 = p->module != ((void *)0);
|
|
bool value_618 = value_617;
|
|
if (value_618) {
|
|
ZirType* value_619 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_618 = (value_619 != ((void *)0));
|
|
}
|
|
value_616 = value_618;
|
|
}
|
|
value_610 = value_616;
|
|
value_611: ;
|
|
}
|
|
value_608 = value_610;
|
|
}
|
|
if (value_608 && (StringEqual(opener, StringLiteral("[")) || StringEqual(opener, StringLiteral("{")))) {
|
|
Parser* value_620 = p;
|
|
{
|
|
Parser* p = value_620;
|
|
Scan* value_622 = &(p->token);
|
|
Scan value_623 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_622) = value_623;
|
|
int64_t value_624 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_624 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_625 = &(p->failed);
|
|
(*value_625) = true;
|
|
}
|
|
}
|
|
Parser* value_626 = p;
|
|
{
|
|
Parser* p = value_626;
|
|
Scan* value_628 = &(p->token);
|
|
Scan value_629 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_628) = value_629;
|
|
int64_t value_630 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_630 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_631 = &(p->failed);
|
|
(*value_631) = true;
|
|
}
|
|
}
|
|
Parser* value_632 = p;
|
|
{
|
|
Parser* p = value_632;
|
|
Scan* value_634 = &(p->token);
|
|
Scan value_635 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
(*value_634) = value_635;
|
|
int64_t value_636 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_636 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
bool* value_637 = &(p->failed);
|
|
(*value_637) = true;
|
|
}
|
|
}
|
|
if (StringEqual(opener, StringLiteral("["))) {
|
|
result = compiler_parse_TypedArray(p, start, qualified);
|
|
} else {
|
|
Parser* value_638 = p;
|
|
bool value_639 = false;
|
|
{
|
|
Parser* p = value_638;
|
|
String name = qualified;
|
|
if ((int64_t)(name).length >= 128LL || p->module == ((void *)0)) {
|
|
value_639 = false;
|
|
goto value_640;
|
|
}
|
|
ZirType* record = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_639 = record != ((void *)0) && record->is_enum == 0;
|
|
value_640: ;
|
|
}
|
|
if (!value_639) {
|
|
bool* value_641 = &(p->failed);
|
|
(*value_641) = true;
|
|
} else {
|
|
result = compiler_parse_ParseInitializer(p, start, qualified, StringLiteral("{"), StringLiteral("}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (result < 0 && !p->failed) {
|
|
String name = StringLiteral("");
|
|
if (kind == ((ZirExprKind)(1))) {
|
|
name = original;
|
|
}
|
|
result = compiler_parse_Node(p, kind, start, name, StringLiteral(""), -1, -1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
result = compiler_parse_ParsePostfix(p, start, result);
|
|
int32_t* value_642 = &(p->depth);
|
|
(*value_642) = (int32_t)((uint32_t)((*value_642)) - 1u);
|
|
return result;
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_ArrayLiteralAhead(Parser* p)
|
|
{
|
|
int32_t at = 0;
|
|
while (true) {
|
|
bool value_0 = at < 64;
|
|
if (value_0) {
|
|
bool value_1 = at == 0;
|
|
if (value_1) {
|
|
Parser* value_2 = p;
|
|
String value_3 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_2;
|
|
String value_5 = p->source;
|
|
value_3 = StringRange(value_5, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_1 = (StringEqual(value_3, StringLiteral("[")));
|
|
}
|
|
bool value_6 = value_1 || (at > 0 && StringEqual(compiler_parse_Following(p, at), StringLiteral("[")));
|
|
value_0 = value_6;
|
|
}
|
|
if (!value_0) { break; }
|
|
bool value_7 = StringEqual(compiler_parse_Following(p, (int32_t)((uint32_t)at + 1u)), StringLiteral("]"));
|
|
if (value_7 || !StringEqual(compiler_parse_Following(p, (int32_t)((uint32_t)at + 2u)), StringLiteral("]"))) {
|
|
return false;
|
|
}
|
|
at = (int32_t)((uint32_t)at + 3u);
|
|
}
|
|
bool value_8 = at == 0;
|
|
if (!value_8) {
|
|
String value_9 = compiler_parse_Following(p, at);
|
|
bool value_10 = false;
|
|
{
|
|
String text = value_9;
|
|
if ((int64_t)(text).length == 0LL) {
|
|
value_10 = false;
|
|
goto value_11;
|
|
}
|
|
uint8_t first = (uint8_t)text.data[0];
|
|
value_10 = first == 95 || (first >= 65 && first <= 90) || (first >= 97 && first <= 122);
|
|
value_11: ;
|
|
}
|
|
value_8 = !value_10;
|
|
}
|
|
if (value_8) {
|
|
return false;
|
|
}
|
|
bool value_12 = StringEqual(compiler_parse_Following(p, (int32_t)((uint32_t)at + 1u)), StringLiteral("."));
|
|
if (value_12 && !StringEqual(compiler_parse_Following(p, (int32_t)((uint32_t)at + 2u)), StringLiteral("["))) {
|
|
String value_13 = compiler_parse_Following(p, (int32_t)((uint32_t)at + 2u));
|
|
bool value_14 = false;
|
|
{
|
|
String text = value_13;
|
|
if ((int64_t)(text).length == 0LL) {
|
|
value_14 = false;
|
|
goto value_15;
|
|
}
|
|
uint8_t first = (uint8_t)text.data[0];
|
|
value_14 = first == 95 || (first >= 65 && first <= 90) || (first >= 97 && first <= 122);
|
|
value_15: ;
|
|
}
|
|
if (!value_14) {
|
|
return false;
|
|
}
|
|
at = (int32_t)((uint32_t)at + 2u);
|
|
}
|
|
bool value_16 = StringEqual(compiler_parse_Following(p, (int32_t)((uint32_t)at + 1u)), StringLiteral("."));
|
|
return value_16 && StringEqual(compiler_parse_Following(p, (int32_t)((uint32_t)at + 2u)), StringLiteral("["));
|
|
}
|
|
|
|
static String
|
|
compiler_parse_UnarySpelling(String operator)
|
|
{
|
|
if (StringEqual(operator, StringLiteral("*"))) {
|
|
return StringLiteral("&");
|
|
}
|
|
if (StringEqual(operator, StringLiteral("+"))) {
|
|
return StringLiteral("+");
|
|
}
|
|
if (StringEqual(operator, StringLiteral("-"))) {
|
|
return StringLiteral("-");
|
|
}
|
|
if (StringEqual(operator, StringLiteral("!"))) {
|
|
return StringLiteral("!");
|
|
}
|
|
return StringLiteral("~");
|
|
}
|
|
|
|
static String
|
|
compiler_parse_QualifiedName(Slice output, String first, String second, int64_t limit)
|
|
{
|
|
int64_t count = (int64_t)(((uint64_t)((int64_t)(first).length) + UINT64_C(1)) + (uint64_t)((int64_t)(second).length));
|
|
if (count >= limit || count > (int64_t)(output).length) {
|
|
return StringLiteral("");
|
|
}
|
|
{
|
|
int64_t range_first_4 = 0LL;
|
|
int64_t range_last_4 = (int64_t)((uint64_t)((int64_t)(first).length) - UINT64_C(1));
|
|
int64_t index = range_first_4;
|
|
if (index <= range_last_4) for (;;) {
|
|
uint8_t* value_0 = &(((uint8_t *)output.data)[SliceIndex(output, (int64_t)index)]);
|
|
(*value_0) = (uint8_t)first.data[index];
|
|
if (index == range_last_4) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
uint8_t* value_1 = &(((uint8_t *)output.data)[SliceIndex(output, (int64_t)(int64_t)(first).length)]);
|
|
(*value_1) = 46;
|
|
{
|
|
int64_t range_first_8 = 0LL;
|
|
int64_t range_last_8 = (int64_t)((uint64_t)((int64_t)(second).length) - UINT64_C(1));
|
|
int64_t index = range_first_8;
|
|
if (index <= range_last_8) for (;;) {
|
|
uint8_t* value_2 = &(((uint8_t *)output.data)[SliceIndex(output, (int64_t)((int64_t)(((uint64_t)((int64_t)(first).length) + UINT64_C(1)) + (uint64_t)index)))]);
|
|
(*value_2) = (uint8_t)second.data[index];
|
|
if (index == range_last_8) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
Slice value_3 = output;
|
|
Slice value_4 = SliceRange(value_3, (int64_t)0LL, (int64_t)count, sizeof(uint8_t));
|
|
return StringView((const char *)(value_4).data, (size_t)(value_4).length);
|
|
}
|
|
|
|
static bool
|
|
compiler_parse_NameStart(String text)
|
|
{
|
|
if ((int64_t)(text).length == 0LL) {
|
|
return false;
|
|
}
|
|
uint8_t first = (uint8_t)text.data[0];
|
|
return first == 95 || (first >= 65 && first <= 90) || (first >= 97 && first <= 122);
|
|
}
|
|
|
|
static String
|
|
compiler_parse_Trim(String source)
|
|
{
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
return StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
|
|
static int64_t
|
|
compiler_parse_FindByte(String source, uint8_t wanted)
|
|
{
|
|
{
|
|
int64_t range_first_0 = 0LL;
|
|
int64_t range_last_0 = (int64_t)((uint64_t)((int64_t)(source).length) - UINT64_C(1));
|
|
int64_t at = range_first_0;
|
|
if (at <= range_last_0) for (;;) {
|
|
if ((uint8_t)source.data[at] == wanted) {
|
|
return at;
|
|
}
|
|
if (at == range_last_0) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
return -1LL;
|
|
}
|