3171 lines
188 KiB
C
3171 lines
188 KiB
C
/* Generated by zi2c from compiler_parse.zi. */
|
|
#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 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_4;
|
|
int64_t value_5 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_5 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int32_t result = compiler_parse_ParseBinary(&(p), 1);
|
|
Parser* value_6 = &(p);
|
|
String value_7 = StringLiteral(";");
|
|
bool value_8 = false;
|
|
{
|
|
Parser* p = value_6;
|
|
String wanted = value_7;
|
|
Parser* value_10 = p;
|
|
String value_11 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_10;
|
|
String value_13 = p->source;
|
|
value_11 = StringRange(value_13, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_11, wanted)) {
|
|
value_8 = false;
|
|
goto value_9;
|
|
}
|
|
Parser* value_14 = p;
|
|
{
|
|
Parser* p = value_14;
|
|
Scan value_16 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_16;
|
|
int64_t value_17 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_17 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_8 = true;
|
|
value_9: ;
|
|
}
|
|
(void)value_8;
|
|
if (!p.failed && ((TokenKind)(p.token.kind)) == ((TokenKind)(0)) && result >= 0) {
|
|
return result;
|
|
}
|
|
fn->expr_count = initial;
|
|
ZirExpr* value_18 = compiler_services_AddExpr(fn, (ZirExprKind)(0), text, span);
|
|
if (value_18 == ((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 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_0;
|
|
int64_t value_1 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_1 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = 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 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_6;
|
|
int64_t value_7 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_7 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = 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 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = 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))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_2 = true;
|
|
value_3: ;
|
|
}
|
|
if (!value_2) {
|
|
p->failed = 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) {
|
|
p->failed = true;
|
|
return StringLiteral("");
|
|
}
|
|
String value_0 = p->source;
|
|
String value_1 = StringRange(value_0, (int64_t)start, (int64_t)end);
|
|
String value_2 = StringView(NULL, 0);
|
|
{
|
|
String source = value_1;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_2 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
return value_2;
|
|
}
|
|
|
|
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) {
|
|
span.line = (int32_t)((uint32_t)(span.line) - 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) {
|
|
span.column = (int32_t)((uint32_t)(p->span.column) + (uint32_t)(offset));
|
|
} else {
|
|
span.column = (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) {
|
|
span.line = (int32_t)((uint32_t)(span.line) + 1u);
|
|
span.column = 1;
|
|
} else {
|
|
span.column = (int32_t)((uint32_t)(span.column) + 1u);
|
|
}
|
|
if (i == range_last_20) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
p->span_offset = offset;
|
|
p->span_cursor = 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)) {
|
|
p->failed = true;
|
|
return -1;
|
|
}
|
|
uint8_t* value_6 = (void *)0;
|
|
{
|
|
String text = name;
|
|
String value_8 = text;
|
|
String value_9 = StringView(NULL, 0);
|
|
{
|
|
String text = value_8;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_9 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_10;
|
|
}
|
|
value_9 = text;
|
|
value_10: ;
|
|
}
|
|
value_6 = compiler_services_KeepName(value_9);
|
|
}
|
|
node->name = (const char *)(value_6);
|
|
Slice value_11 = {node->op, 8};
|
|
compiler_ir_CopyText(value_11, op);
|
|
node->left = left;
|
|
node->right = 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) {
|
|
(p->fn->exprs[*(last)]).next_sibling = child;
|
|
} else {
|
|
(*(first)) = child;
|
|
}
|
|
(*(last)) = 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);
|
|
p->depth = (int32_t)((uint32_t)(p->depth) + 1u);
|
|
if (p->depth > 128) {
|
|
p->failed = true;
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 1u);
|
|
return -1;
|
|
}
|
|
while (!p->failed) {
|
|
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 operator = value_1;
|
|
int32_t precedence = compiler_expression_BinaryPrecedence(operator);
|
|
if (precedence == 0 || precedence < minimum) {
|
|
break;
|
|
}
|
|
Parser* value_4 = p;
|
|
{
|
|
Parser* p = value_4;
|
|
Scan value_6 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_6;
|
|
int64_t value_7 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_7 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = 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_8 = p;
|
|
String value_9 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_8;
|
|
String value_11 = p->source;
|
|
value_9 = StringRange(value_11, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_9, StringLiteral("\?"))) {
|
|
Parser* value_12 = p;
|
|
String value_13 = StringLiteral("C-style conditional is not valid Jai syntax; use ifx ... then ... else ...");
|
|
{
|
|
Parser* p = value_12;
|
|
String message = value_13;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 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 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = 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))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_2 = true;
|
|
value_3: ;
|
|
}
|
|
if (value_2) {
|
|
int32_t low = -1;
|
|
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, StringLiteral(":"))) {
|
|
low = compiler_parse_ParseBinary(p, 1);
|
|
}
|
|
Parser* value_16 = p;
|
|
String value_17 = StringLiteral(":");
|
|
bool value_18 = false;
|
|
{
|
|
Parser* p = value_16;
|
|
String wanted = value_17;
|
|
Parser* value_20 = p;
|
|
String value_21 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_20;
|
|
String value_23 = p->source;
|
|
value_21 = StringRange(value_23, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_21, wanted)) {
|
|
value_18 = false;
|
|
goto value_19;
|
|
}
|
|
Parser* value_24 = p;
|
|
{
|
|
Parser* p = value_24;
|
|
Scan value_26 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_26;
|
|
int64_t value_27 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_27 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_18 = true;
|
|
value_19: ;
|
|
}
|
|
if (value_18) {
|
|
int32_t high = -1;
|
|
Parser* value_28 = p;
|
|
String value_29 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_28;
|
|
String value_31 = p->source;
|
|
value_29 = StringRange(value_31, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_29, StringLiteral("]"))) {
|
|
high = compiler_parse_ParseBinary(p, 1);
|
|
}
|
|
Parser* value_32 = p;
|
|
String value_33 = StringLiteral("]");
|
|
{
|
|
Parser* p = value_32;
|
|
String wanted = value_33;
|
|
Parser* value_35 = p;
|
|
String value_36 = wanted;
|
|
bool value_37 = false;
|
|
{
|
|
Parser* p = value_35;
|
|
String wanted = value_36;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_37 = false;
|
|
goto value_38;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_37 = true;
|
|
value_38: ;
|
|
}
|
|
if (!value_37) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(16), start, StringLiteral(""), StringLiteral(""), result, low);
|
|
if (result >= 0) {
|
|
(p->fn->exprs[result]).third = high;
|
|
}
|
|
} else {
|
|
Parser* value_39 = p;
|
|
String value_40 = StringLiteral("]");
|
|
{
|
|
Parser* p = value_39;
|
|
String wanted = value_40;
|
|
Parser* value_42 = p;
|
|
String value_43 = wanted;
|
|
bool value_44 = false;
|
|
{
|
|
Parser* p = value_42;
|
|
String wanted = value_43;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_44 = false;
|
|
goto value_45;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_44 = true;
|
|
value_45: ;
|
|
}
|
|
if (!value_44) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(10), start, StringLiteral(""), StringLiteral(""), result, low);
|
|
}
|
|
} else {
|
|
Parser* value_46 = p;
|
|
String value_47 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_46;
|
|
String value_49 = p->source;
|
|
value_47 = StringRange(value_49, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_47, StringLiteral("->"))) {
|
|
Parser* value_50 = p;
|
|
String value_51 = StringLiteral("C-style pointer member access is not valid Jai syntax; use .field");
|
|
{
|
|
Parser* p = value_50;
|
|
String message = value_51;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_53 = p;
|
|
String value_54 = StringLiteral(".");
|
|
bool value_55 = false;
|
|
{
|
|
Parser* p = value_53;
|
|
String wanted = value_54;
|
|
Parser* value_57 = p;
|
|
String value_58 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_57;
|
|
String value_60 = p->source;
|
|
value_58 = StringRange(value_60, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_58, wanted)) {
|
|
value_55 = false;
|
|
goto value_56;
|
|
}
|
|
Parser* value_61 = p;
|
|
{
|
|
Parser* p = value_61;
|
|
Scan value_63 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_63;
|
|
int64_t value_64 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_64 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_55 = true;
|
|
value_56: ;
|
|
}
|
|
if (value_55) {
|
|
Parser* value_65 = p;
|
|
String value_66 = StringLiteral("*");
|
|
bool value_67 = false;
|
|
{
|
|
Parser* p = value_65;
|
|
String wanted = value_66;
|
|
Parser* value_69 = p;
|
|
String value_70 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_69;
|
|
String value_72 = p->source;
|
|
value_70 = StringRange(value_72, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_70, wanted)) {
|
|
value_67 = false;
|
|
goto value_68;
|
|
}
|
|
Parser* value_73 = p;
|
|
{
|
|
Parser* p = value_73;
|
|
Scan value_75 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_75;
|
|
int64_t value_76 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_76 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_67 = true;
|
|
value_68: ;
|
|
}
|
|
if (value_67) {
|
|
result = compiler_parse_Node(p, (ZirExprKind)(7), start, StringLiteral(""), StringLiteral("*"), -1, result);
|
|
} else {
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_77 = p;
|
|
String value_78 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_77;
|
|
String value_80 = p->source;
|
|
value_78 = StringRange(value_80, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String name = value_78;
|
|
Parser* value_81 = p;
|
|
{
|
|
Parser* p = value_81;
|
|
Scan value_83 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_83;
|
|
int64_t value_84 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_84 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(8), start, name, StringLiteral("."), result, -1);
|
|
}
|
|
} else {
|
|
Parser* value_85 = p;
|
|
String value_86 = StringLiteral("(");
|
|
bool value_87 = false;
|
|
{
|
|
Parser* p = value_85;
|
|
String wanted = value_86;
|
|
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);
|
|
}
|
|
if (!StringEqual(value_90, wanted)) {
|
|
value_87 = false;
|
|
goto value_88;
|
|
}
|
|
Parser* value_93 = p;
|
|
{
|
|
Parser* p = value_93;
|
|
Scan value_95 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_95;
|
|
int64_t value_96 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_96 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_87 = true;
|
|
value_88: ;
|
|
}
|
|
if (value_87) {
|
|
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_97 = p;
|
|
String value_98 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_97;
|
|
String value_100 = p->source;
|
|
value_98 = StringRange(value_100, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if ((!StringEqual(value_98, StringLiteral(")")))) {
|
|
while (true) {
|
|
String argument = StringLiteral("");
|
|
bool value_101 = ((TokenKind)(p->token.kind)) == ((TokenKind)(1));
|
|
if (value_101 && StringEqual(compiler_parse_Following(p, 1), StringLiteral("="))) {
|
|
Parser* value_102 = p;
|
|
String value_103 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_102;
|
|
String value_105 = p->source;
|
|
value_103 = StringRange(value_105, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
argument = value_103;
|
|
Parser* value_106 = p;
|
|
{
|
|
Parser* p = value_106;
|
|
Scan value_108 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_108;
|
|
int64_t value_109 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_109 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_110 = p;
|
|
String value_111 = StringLiteral("=");
|
|
{
|
|
Parser* p = value_110;
|
|
String wanted = value_111;
|
|
Parser* value_113 = p;
|
|
String value_114 = wanted;
|
|
bool value_115 = false;
|
|
{
|
|
Parser* p = value_113;
|
|
String wanted = value_114;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_115 = false;
|
|
goto value_116;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_115 = true;
|
|
value_116: ;
|
|
}
|
|
if (!value_115) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
}
|
|
int32_t child = compiler_parse_ParseBinary(p, 1);
|
|
if (child < 0) {
|
|
p->failed = true;
|
|
break;
|
|
}
|
|
uint8_t* value_117 = (void *)0;
|
|
{
|
|
String text = argument;
|
|
String value_119 = text;
|
|
String value_120 = StringView(NULL, 0);
|
|
{
|
|
String text = value_119;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_120 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_121;
|
|
}
|
|
value_120 = text;
|
|
value_121: ;
|
|
}
|
|
value_117 = compiler_services_KeepName(value_120);
|
|
}
|
|
(p->fn->exprs[child]).argument_name = (const char *)(value_117);
|
|
Parser* value_122 = p;
|
|
int32_t* value_123 = &(first);
|
|
int32_t* value_124 = &(last);
|
|
int32_t value_125 = child;
|
|
{
|
|
Parser* p = value_122;
|
|
int32_t* first = value_123;
|
|
int32_t* last = value_124;
|
|
int32_t child = value_125;
|
|
if (*(last) >= 0) {
|
|
(p->fn->exprs[*(last)]).next_sibling = child;
|
|
} else {
|
|
(*(first)) = child;
|
|
}
|
|
(*(last)) = child;
|
|
}
|
|
Parser* value_127 = p;
|
|
String value_128 = StringLiteral(",");
|
|
bool value_129 = false;
|
|
{
|
|
Parser* p = value_127;
|
|
String wanted = value_128;
|
|
Parser* value_131 = p;
|
|
String value_132 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_131;
|
|
String value_134 = p->source;
|
|
value_132 = StringRange(value_134, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_132, wanted)) {
|
|
value_129 = false;
|
|
goto value_130;
|
|
}
|
|
Parser* value_135 = p;
|
|
{
|
|
Parser* p = value_135;
|
|
Scan value_137 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_137;
|
|
int64_t value_138 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_138 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_129 = true;
|
|
value_130: ;
|
|
}
|
|
if (!value_129) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_139 = p;
|
|
String value_140 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_139;
|
|
String wanted = value_140;
|
|
Parser* value_142 = p;
|
|
String value_143 = wanted;
|
|
bool value_144 = false;
|
|
{
|
|
Parser* p = value_142;
|
|
String wanted = value_143;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_144 = false;
|
|
goto value_145;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_144 = true;
|
|
value_145: ;
|
|
}
|
|
if (!value_144) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
bool value_146 = !p->failed && p->expand_defaults;
|
|
bool value_147 = value_146;
|
|
if (value_147) {
|
|
bool value_148 = compiler_services_ExpandDefaults(p->fn, p->module, p->span, p->stmt_index, callee, &(first), &(last));
|
|
value_147 = !value_148;
|
|
}
|
|
if (value_147) {
|
|
p->failed = 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]);
|
|
call->first_child = first;
|
|
if (callee >= 0 && (p->fn->exprs[callee]).is_this != 0) {
|
|
call->is_this = 1;
|
|
}
|
|
}
|
|
} else {
|
|
Parser* value_149 = p;
|
|
String value_150 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_149;
|
|
String value_152 = p->source;
|
|
value_150 = StringRange(value_152, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_153 = StringEqual(value_150, StringLiteral("++"));
|
|
if (!value_153) {
|
|
Parser* value_154 = p;
|
|
String value_155 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_154;
|
|
String value_157 = p->source;
|
|
value_155 = StringRange(value_157, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_153 = (StringEqual(value_155, StringLiteral("--")));
|
|
}
|
|
if (value_153) {
|
|
Parser* value_158 = p;
|
|
String value_159 = StringLiteral("Jai has no increment or decrement operators; use += 1 or -= 1");
|
|
{
|
|
Parser* p = value_158;
|
|
String message = value_159;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_161 = p;
|
|
String value_162 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_161;
|
|
String value_164 = p->source;
|
|
value_162 = StringRange(value_164, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_165 = StringEqual(value_162, StringLiteral("\?"));
|
|
if (value_165) {
|
|
int64_t value_166 = p->token.begin;
|
|
value_165 = (value_166 > 0LL);
|
|
}
|
|
bool value_167 = value_165;
|
|
bool value_168 = value_167;
|
|
if (value_168) {
|
|
bool value_169 = compiler_text_SpaceByte((uint8_t)ZIRAN_INDEX(p->source.data, p->source.length, ((int64_t)((uint64_t)(p->token.begin) - UINT64_C(1)))));
|
|
value_168 = !value_169;
|
|
}
|
|
if (value_168) {
|
|
Parser* value_170 = p;
|
|
String value_171 = StringLiteral("postfix \? is not Jai syntax; handle the result explicitly");
|
|
{
|
|
Parser* p = value_170;
|
|
String message = value_171;
|
|
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;
|
|
}
|
|
uint64_t offset = 0ULL;
|
|
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) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
while (true) {
|
|
bool value_6 = !p->failed;
|
|
bool value_7 = value_6;
|
|
if (value_7) {
|
|
Parser* value_8 = p;
|
|
String value_9 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_8;
|
|
String value_11 = p->source;
|
|
value_9 = StringRange(value_11, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_7 = (!StringEqual(value_9, close));
|
|
}
|
|
if (!(value_7 && ((TokenKind)(p->token.kind)) != ((TokenKind)(0)))) { break; }
|
|
int64_t field_start = p->token.begin;
|
|
String name = StringLiteral("");
|
|
bool named = false;
|
|
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, StringLiteral(".")) && StringEqual(compiler_parse_Following(p, 2), StringLiteral("="))) {
|
|
Scan value_16 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
if (((TokenKind)(value_16.kind)) == ((TokenKind)(1))) {
|
|
Parser* value_17 = p;
|
|
{
|
|
Parser* p = value_17;
|
|
Scan value_19 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = 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))) {
|
|
p->failed = 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))) {
|
|
p->failed = true;
|
|
break;
|
|
}
|
|
Parser* value_21 = p;
|
|
String value_22 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_21;
|
|
String value_24 = p->source;
|
|
value_22 = StringRange(value_24, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
name = value_22;
|
|
Parser* value_25 = p;
|
|
{
|
|
Parser* p = value_25;
|
|
Scan value_27 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_27;
|
|
int64_t value_28 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_28 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_29 = p;
|
|
String value_30 = StringLiteral("=");
|
|
{
|
|
Parser* p = value_29;
|
|
String wanted = value_30;
|
|
Parser* value_32 = p;
|
|
String value_33 = wanted;
|
|
bool value_34 = false;
|
|
{
|
|
Parser* p = value_32;
|
|
String wanted = value_33;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_34 = false;
|
|
goto value_35;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_34 = true;
|
|
value_35: ;
|
|
}
|
|
if (!value_34) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
}
|
|
int32_t value = -1;
|
|
Parser* value_36 = p;
|
|
String value_37 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_36;
|
|
String value_39 = p->source;
|
|
value_37 = StringRange(value_39, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_37, StringLiteral("{"))) {
|
|
String nested_type = compiler_parse_FieldType(p, type, name, ordinal);
|
|
p->depth = (int32_t)((uint32_t)(p->depth) + 1u);
|
|
if (p->depth > 128) {
|
|
p->failed = true;
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 1u);
|
|
return -1;
|
|
}
|
|
value = compiler_parse_ParseInitializer(p, p->token.begin, nested_type, StringLiteral("{"), StringLiteral("}"));
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 1u);
|
|
} else {
|
|
value = compiler_parse_ParseBinary(p, 1);
|
|
}
|
|
ordinal = (int32_t)((uint32_t)ordinal + 1u);
|
|
if (value < 0) {
|
|
p->failed = 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_40 = p;
|
|
int32_t* value_41 = &(first);
|
|
int32_t* value_42 = &(last);
|
|
int32_t value_43 = child;
|
|
{
|
|
Parser* p = value_40;
|
|
int32_t* first = value_41;
|
|
int32_t* last = value_42;
|
|
int32_t child = value_43;
|
|
if (*(last) >= 0) {
|
|
(p->fn->exprs[*(last)]).next_sibling = child;
|
|
} else {
|
|
(*(first)) = child;
|
|
}
|
|
(*(last)) = child;
|
|
}
|
|
Parser* value_45 = p;
|
|
String value_46 = StringLiteral(",");
|
|
bool value_47 = false;
|
|
{
|
|
Parser* p = value_45;
|
|
String wanted = value_46;
|
|
Parser* value_49 = p;
|
|
String value_50 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_49;
|
|
String value_52 = p->source;
|
|
value_50 = StringRange(value_52, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_50, wanted)) {
|
|
value_47 = false;
|
|
goto value_48;
|
|
}
|
|
Parser* value_53 = p;
|
|
{
|
|
Parser* p = value_53;
|
|
Scan value_55 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_55;
|
|
int64_t value_56 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_56 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_47 = true;
|
|
value_48: ;
|
|
}
|
|
if (!value_47) {
|
|
break;
|
|
}
|
|
}
|
|
Parser* value_57 = p;
|
|
{
|
|
Parser* p = value_57;
|
|
String wanted = close;
|
|
Parser* value_59 = p;
|
|
String value_60 = wanted;
|
|
bool value_61 = false;
|
|
{
|
|
Parser* p = value_59;
|
|
String wanted = value_60;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_61 = false;
|
|
goto value_62;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_61 = true;
|
|
value_62: ;
|
|
}
|
|
if (!value_61) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int32_t result = compiler_parse_Node(p, (ZirExprKind)(12), start, type, StringLiteral(""), -1, -1);
|
|
if (result >= 0) {
|
|
(p->fn->exprs[result]).first_child = 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)) {
|
|
p->failed = 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)) {
|
|
p->failed = true;
|
|
} else {
|
|
(p->fn->exprs[result]).name = (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;
|
|
}
|
|
buffer[0] = 91;
|
|
ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)((uint64_t)digits + UINT64_C(1)))) = 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 (;;) {
|
|
ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)(((uint64_t)digits + UINT64_C(2)) + (uint64_t)i))) = (uint8_t)element.data[i];
|
|
if (i == range_last_8) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
Slice value_1 = {buffer, 256};
|
|
Slice value_2 = SliceRange(value_1, (int64_t)0LL, (int64_t)total, sizeof(uint8_t));
|
|
return compiler_services_KeepName(StringView((const char *)(value_2).data, (size_t)(value_2).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 *)output.data)[SliceIndex(output, (int64_t)((int64_t)(((uint64_t)used - UINT64_C(1)) - (uint64_t)i)))] = (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;
|
|
p->depth = (int32_t)((uint32_t)(p->depth) + 1u);
|
|
if (p->depth > 128) {
|
|
p->failed = true;
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 1u);
|
|
return -1;
|
|
}
|
|
Parser* value_5 = p;
|
|
String value_6 = StringLiteral("#this");
|
|
bool value_7 = false;
|
|
{
|
|
Parser* p = value_5;
|
|
String wanted = value_6;
|
|
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);
|
|
}
|
|
if (!StringEqual(value_10, wanted)) {
|
|
value_7 = false;
|
|
goto value_8;
|
|
}
|
|
Parser* value_13 = p;
|
|
{
|
|
Parser* p = value_13;
|
|
Scan value_15 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_15;
|
|
int64_t value_16 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_16 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_7 = true;
|
|
value_8: ;
|
|
}
|
|
if (value_7) {
|
|
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) {
|
|
(p->fn->exprs[result]).is_this = 1;
|
|
}
|
|
} else {
|
|
Parser* value_17 = p;
|
|
String value_18 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_17;
|
|
String value_20 = p->source;
|
|
value_18 = StringRange(value_20, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_18, 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_21 = p;
|
|
String value_22 = StringLiteral("#compile_time");
|
|
bool value_23 = false;
|
|
{
|
|
Parser* p = value_21;
|
|
String wanted = value_22;
|
|
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);
|
|
}
|
|
if (!StringEqual(value_26, wanted)) {
|
|
value_23 = false;
|
|
goto value_24;
|
|
}
|
|
Parser* value_29 = p;
|
|
{
|
|
Parser* p = value_29;
|
|
Scan value_31 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_31;
|
|
int64_t value_32 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_32 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_23 = true;
|
|
value_24: ;
|
|
}
|
|
if (value_23) {
|
|
result = compiler_parse_Node(p, (ZirExprKind)(17), start, StringLiteral(""), StringLiteral(""), -1, -1);
|
|
} else {
|
|
Parser* value_33 = p;
|
|
String value_34 = StringLiteral("#procedure_name");
|
|
bool value_35 = false;
|
|
{
|
|
Parser* p = value_33;
|
|
String wanted = value_34;
|
|
Parser* value_37 = p;
|
|
String value_38 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_37;
|
|
String value_40 = p->source;
|
|
value_38 = StringRange(value_40, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_38, wanted)) {
|
|
value_35 = false;
|
|
goto value_36;
|
|
}
|
|
Parser* value_41 = p;
|
|
{
|
|
Parser* p = value_41;
|
|
Scan value_43 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_43;
|
|
int64_t value_44 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_44 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_35 = true;
|
|
value_36: ;
|
|
}
|
|
if (value_35) {
|
|
if ((int64_t)(scope).length == 0LL) {
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.procedure_name"), StringLiteral("#procedure_name() requires a procedure scope"));
|
|
}
|
|
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) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_52 = p;
|
|
String value_53 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_52;
|
|
String wanted = value_53;
|
|
Parser* value_55 = p;
|
|
String value_56 = wanted;
|
|
bool value_57 = false;
|
|
{
|
|
Parser* p = value_55;
|
|
String wanted = value_56;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_57 = false;
|
|
goto value_58;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_57 = true;
|
|
value_58: ;
|
|
}
|
|
if (!value_57) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(4), start, StringLiteral(""), StringLiteral(""), -1, -1);
|
|
uint8_t buffer[256] = {0};
|
|
buffer[0] = 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 (;;) {
|
|
ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)((uint64_t)i + UINT64_C(1)))) = (uint8_t)scope.data[i];
|
|
if (i == range_last_35) {
|
|
break;
|
|
}
|
|
i = (int64_t)((uint64_t)i + UINT64_C(1));
|
|
}
|
|
}
|
|
ZIRAN_INDEX(buffer, sizeof(buffer) / sizeof(buffer[0]), ((int64_t)((uint64_t)((int64_t)(scope).length) + UINT64_C(1)))) = 34;
|
|
if (result >= 0) {
|
|
Slice value_59 = {buffer, 256};
|
|
Slice value_60 = SliceRange(value_59, (int64_t)0LL, (int64_t)((int64_t)((uint64_t)((int64_t)(scope).length) + UINT64_C(2))), sizeof(uint8_t));
|
|
Slice value_61 = value_60;
|
|
uint8_t* value_62 = compiler_services_Keep(StringView((const char *)(value_61).data, (size_t)(value_61).length));
|
|
(p->fn->exprs[result]).text = (const char *)(value_62);
|
|
}
|
|
} else {
|
|
Parser* value_63 = p;
|
|
String value_64 = StringLiteral("#char");
|
|
bool value_65 = false;
|
|
{
|
|
Parser* p = value_63;
|
|
String wanted = value_64;
|
|
Parser* value_67 = p;
|
|
String value_68 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_67;
|
|
String value_70 = p->source;
|
|
value_68 = StringRange(value_70, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_68, wanted)) {
|
|
value_65 = false;
|
|
goto value_66;
|
|
}
|
|
Parser* value_71 = p;
|
|
{
|
|
Parser* p = value_71;
|
|
Scan value_73 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_73;
|
|
int64_t value_74 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_74 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_65 = true;
|
|
value_66: ;
|
|
}
|
|
if (value_65) {
|
|
Parser* value_75 = p;
|
|
String value_76 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_75;
|
|
String value_78 = p->source;
|
|
value_76 = StringRange(value_78, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
int32_t byte = compiler_expression_CharacterByte(value_76);
|
|
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_79 = p;
|
|
{
|
|
Parser* p = value_79;
|
|
Scan value_81 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_81;
|
|
int64_t value_82 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_82 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(2), start, StringLiteral(""), StringLiteral(""), -1, -1);
|
|
uint8_t digits[4] = {0};
|
|
if (result >= 0) {
|
|
Slice value_83 = {digits, 4};
|
|
Slice value_84 = {digits, 4};
|
|
int64_t value_85 = compiler_parse_Decimal(value_84, (int64_t)(byte));
|
|
Slice value_86 = SliceRange(value_83, (int64_t)0LL, (int64_t)value_85, sizeof(uint8_t));
|
|
uint8_t* value_87 = compiler_services_Keep(StringView((const char *)(value_86).data, (size_t)(value_86).length));
|
|
(p->fn->exprs[result]).text = (const char *)(value_87);
|
|
}
|
|
} else {
|
|
Parser* value_88 = p;
|
|
String value_89 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_88;
|
|
String value_91 = p->source;
|
|
value_89 = StringRange(value_91, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_92 = StringEqual(value_89, StringLiteral("ifx"));
|
|
if (!value_92) {
|
|
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);
|
|
}
|
|
value_92 = (StringEqual(value_94, StringLiteral("#ifx")));
|
|
}
|
|
if (value_92) {
|
|
String op = StringLiteral("ifx");
|
|
Parser* value_97 = p;
|
|
String value_98 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_97;
|
|
String value_100 = p->source;
|
|
value_98 = StringRange(value_100, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_98, StringLiteral("#ifx"))) {
|
|
op = StringLiteral("#ifx");
|
|
}
|
|
Parser* value_101 = p;
|
|
{
|
|
Parser* p = value_101;
|
|
Scan value_103 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_103;
|
|
int64_t value_104 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_104 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int32_t condition = compiler_parse_ParseBinary(p, 2);
|
|
Parser* value_105 = p;
|
|
String value_106 = StringLiteral("then");
|
|
bool value_107 = false;
|
|
{
|
|
Parser* p = value_105;
|
|
String wanted = value_106;
|
|
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);
|
|
}
|
|
if (!StringEqual(value_110, wanted)) {
|
|
value_107 = false;
|
|
goto value_108;
|
|
}
|
|
Parser* value_113 = p;
|
|
{
|
|
Parser* p = value_113;
|
|
Scan value_115 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_115;
|
|
int64_t value_116 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_116 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_107 = true;
|
|
value_108: ;
|
|
}
|
|
(void)value_107;
|
|
int32_t selected = compiler_parse_ParseBinary(p, 1);
|
|
Parser* value_117 = p;
|
|
String value_118 = StringLiteral(";");
|
|
bool value_119 = false;
|
|
{
|
|
Parser* p = value_117;
|
|
String wanted = value_118;
|
|
Parser* value_121 = p;
|
|
String value_122 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_121;
|
|
String value_124 = p->source;
|
|
value_122 = StringRange(value_124, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_122, wanted)) {
|
|
value_119 = false;
|
|
goto value_120;
|
|
}
|
|
Parser* value_125 = p;
|
|
{
|
|
Parser* p = value_125;
|
|
Scan value_127 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_127;
|
|
int64_t value_128 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_128 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_119 = true;
|
|
value_120: ;
|
|
}
|
|
(void)value_119;
|
|
Parser* value_129 = p;
|
|
String value_130 = StringLiteral("else");
|
|
{
|
|
Parser* p = value_129;
|
|
String wanted = value_130;
|
|
Parser* value_132 = p;
|
|
String value_133 = wanted;
|
|
bool value_134 = false;
|
|
{
|
|
Parser* p = value_132;
|
|
String wanted = value_133;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_134 = false;
|
|
goto value_135;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_134 = true;
|
|
value_135: ;
|
|
}
|
|
if (!value_134) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int32_t alternative = compiler_parse_ParseBinary(p, 1);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(14), start, StringLiteral(""), op, condition, selected);
|
|
if (result >= 0) {
|
|
(p->fn->exprs[result]).third = alternative;
|
|
}
|
|
} else {
|
|
Parser* value_136 = p;
|
|
String value_137 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_136;
|
|
String value_139 = p->source;
|
|
value_137 = StringRange(value_139, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_137, StringLiteral("sizeof"))) {
|
|
Parser* value_140 = p;
|
|
String value_141 = StringLiteral("sizeof is not Jai syntax; use size_of(Type)");
|
|
{
|
|
Parser* p = value_140;
|
|
String message = value_141;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_143 = p;
|
|
String value_144 = StringLiteral("size_of");
|
|
bool value_145 = false;
|
|
{
|
|
Parser* p = value_143;
|
|
String wanted = value_144;
|
|
Parser* value_147 = p;
|
|
String value_148 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_147;
|
|
String value_150 = p->source;
|
|
value_148 = StringRange(value_150, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_148, wanted)) {
|
|
value_145 = false;
|
|
goto value_146;
|
|
}
|
|
Parser* value_151 = p;
|
|
{
|
|
Parser* p = value_151;
|
|
Scan value_153 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = 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))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_145 = true;
|
|
value_146: ;
|
|
}
|
|
if (value_145) {
|
|
Parser* value_155 = p;
|
|
String value_156 = StringLiteral("(");
|
|
{
|
|
Parser* p = value_155;
|
|
String wanted = value_156;
|
|
Parser* value_158 = p;
|
|
String value_159 = wanted;
|
|
bool value_160 = false;
|
|
{
|
|
Parser* p = value_158;
|
|
String wanted = value_159;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_160 = false;
|
|
goto value_161;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_160 = true;
|
|
value_161: ;
|
|
}
|
|
if (!value_160) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int64_t type_start = p->token.begin;
|
|
int32_t nested = 0;
|
|
while (((TokenKind)(p->token.kind)) != ((TokenKind)(0))) {
|
|
Parser* value_162 = p;
|
|
String value_163 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_162;
|
|
String value_165 = p->source;
|
|
value_163 = StringRange(value_165, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (((StringEqual(value_163, StringLiteral(")"))) && nested == 0)) {
|
|
break;
|
|
}
|
|
Parser* value_166 = p;
|
|
String value_167 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_166;
|
|
String value_169 = p->source;
|
|
value_167 = StringRange(value_169, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if ((StringEqual(value_167, StringLiteral("(")))) {
|
|
nested = (int32_t)((uint32_t)nested + 1u);
|
|
}
|
|
Parser* value_170 = p;
|
|
String value_171 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_170;
|
|
String value_173 = p->source;
|
|
value_171 = StringRange(value_173, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if ((StringEqual(value_171, StringLiteral(")")))) {
|
|
nested = (int32_t)((uint32_t)nested - 1u);
|
|
}
|
|
Parser* value_174 = p;
|
|
{
|
|
Parser* p = value_174;
|
|
Scan value_176 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_176;
|
|
int64_t value_177 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_177 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_178 = p;
|
|
String value_179 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_178;
|
|
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) {
|
|
p->failed = true;
|
|
value_179 = StringLiteral("");
|
|
goto value_180;
|
|
}
|
|
String value_181 = p->source;
|
|
String value_182 = StringRange(value_181, (int64_t)start, (int64_t)end);
|
|
String value_183 = StringView(NULL, 0);
|
|
{
|
|
String source = value_182;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_183 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
value_179 = value_183;
|
|
value_180: ;
|
|
}
|
|
String type = value_179;
|
|
Parser* value_185 = p;
|
|
String value_186 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_185;
|
|
String wanted = value_186;
|
|
Parser* value_188 = p;
|
|
String value_189 = wanted;
|
|
bool value_190 = false;
|
|
{
|
|
Parser* p = value_188;
|
|
String wanted = value_189;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_190 = false;
|
|
goto value_191;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_190 = true;
|
|
value_191: ;
|
|
}
|
|
if (!value_190) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_Node(p, (ZirExprKind)(13), start, type, StringLiteral(""), -1, -1);
|
|
} else {
|
|
Parser* value_192 = p;
|
|
String value_193 = StringLiteral("cast");
|
|
bool value_194 = false;
|
|
{
|
|
Parser* p = value_192;
|
|
String wanted = value_193;
|
|
Parser* value_196 = p;
|
|
String value_197 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_196;
|
|
String value_199 = p->source;
|
|
value_197 = StringRange(value_199, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_197, wanted)) {
|
|
value_194 = false;
|
|
goto value_195;
|
|
}
|
|
Parser* value_200 = p;
|
|
{
|
|
Parser* p = value_200;
|
|
Scan value_202 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_202;
|
|
int64_t value_203 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_203 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_194 = true;
|
|
value_195: ;
|
|
}
|
|
if (value_194) {
|
|
Parser* value_204 = p;
|
|
String value_205 = StringLiteral("(");
|
|
{
|
|
Parser* p = value_204;
|
|
String wanted = value_205;
|
|
Parser* value_207 = p;
|
|
String value_208 = wanted;
|
|
bool value_209 = false;
|
|
{
|
|
Parser* p = value_207;
|
|
String wanted = value_208;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_209 = false;
|
|
goto value_210;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_209 = true;
|
|
value_210: ;
|
|
}
|
|
if (!value_209) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int64_t type_start = p->token.begin;
|
|
Parser* value_211 = p;
|
|
String value_212 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_211;
|
|
String value_214 = p->source;
|
|
value_212 = StringRange(value_214, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_212, StringLiteral("char"))) {
|
|
Parser* value_215 = p;
|
|
String value_216 = StringLiteral("non-Jai primitive type spelling: char");
|
|
{
|
|
Parser* p = value_215;
|
|
String message = value_216;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
while (true) {
|
|
bool value_218 = ((TokenKind)(p->token.kind)) != ((TokenKind)(0));
|
|
bool value_219 = value_218;
|
|
if (value_219) {
|
|
Parser* value_220 = p;
|
|
String value_221 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_220;
|
|
String value_223 = p->source;
|
|
value_221 = StringRange(value_223, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_219 = (!StringEqual(value_221, StringLiteral(")")));
|
|
}
|
|
if (!value_219) { break; }
|
|
Parser* value_224 = p;
|
|
{
|
|
Parser* p = value_224;
|
|
Scan value_226 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_226;
|
|
int64_t value_227 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_227 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_228 = p;
|
|
String value_229 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_228;
|
|
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) {
|
|
p->failed = true;
|
|
value_229 = StringLiteral("");
|
|
goto value_230;
|
|
}
|
|
String value_231 = p->source;
|
|
String value_232 = StringRange(value_231, (int64_t)start, (int64_t)end);
|
|
String value_233 = StringView(NULL, 0);
|
|
{
|
|
String source = value_232;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_233 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
value_229 = value_233;
|
|
value_230: ;
|
|
}
|
|
String type = value_229;
|
|
Parser* value_235 = p;
|
|
bool value_236 = false;
|
|
{
|
|
Parser* p = value_235;
|
|
String name = type;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_236 = false;
|
|
goto value_237;
|
|
}
|
|
String value_238 = name;
|
|
bool value_239 = false;
|
|
{
|
|
String name = value_238;
|
|
bool value_241 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_239 = value_241 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_242 = value_239;
|
|
if (!value_242) {
|
|
bool value_243 = p->module != ((void *)0);
|
|
bool value_244 = value_243;
|
|
if (value_244) {
|
|
ZirType* value_245 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_244 = (value_245 != ((void *)0));
|
|
}
|
|
value_242 = value_244;
|
|
}
|
|
value_236 = value_242;
|
|
value_237: ;
|
|
}
|
|
if (!value_236 && ((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))) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_246 = p;
|
|
String value_247 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_246;
|
|
String wanted = value_247;
|
|
Parser* value_249 = p;
|
|
String value_250 = wanted;
|
|
bool value_251 = false;
|
|
{
|
|
Parser* p = value_249;
|
|
String wanted = value_250;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_251 = false;
|
|
goto value_252;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_251 = true;
|
|
value_252: ;
|
|
}
|
|
if (!value_251) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int32_t right = compiler_parse_ParsePrefix(p);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(11), start, type, StringLiteral(""), -1, right);
|
|
} else {
|
|
Parser* value_253 = p;
|
|
String value_254 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_253;
|
|
String value_256 = p->source;
|
|
value_254 = StringRange(value_256, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_257 = StringEqual(value_254, StringLiteral("++"));
|
|
if (!value_257) {
|
|
Parser* value_258 = p;
|
|
String value_259 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_258;
|
|
String value_261 = p->source;
|
|
value_259 = StringRange(value_261, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_257 = (StringEqual(value_259, StringLiteral("--")));
|
|
}
|
|
if (value_257) {
|
|
Parser* value_262 = p;
|
|
String value_263 = StringLiteral("Jai has no increment or decrement operators; use += 1 or -= 1");
|
|
{
|
|
Parser* p = value_262;
|
|
String message = value_263;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_265 = p;
|
|
String value_266 = StringLiteral("<<");
|
|
bool value_267 = false;
|
|
{
|
|
Parser* p = value_265;
|
|
String wanted = value_266;
|
|
Parser* value_269 = p;
|
|
String value_270 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_269;
|
|
String value_272 = p->source;
|
|
value_270 = StringRange(value_272, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_270, wanted)) {
|
|
value_267 = false;
|
|
goto value_268;
|
|
}
|
|
Parser* value_273 = p;
|
|
{
|
|
Parser* p = value_273;
|
|
Scan value_275 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_275;
|
|
int64_t value_276 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_276 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_267 = true;
|
|
value_268: ;
|
|
}
|
|
if (value_267) {
|
|
int32_t right = compiler_parse_ParsePrefix(p);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(7), start, StringLiteral(""), StringLiteral("*"), -1, right);
|
|
} else {
|
|
Parser* value_277 = p;
|
|
String value_278 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_277;
|
|
String value_280 = p->source;
|
|
value_278 = StringRange(value_280, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_281 = StringEqual(value_278, StringLiteral("+"));
|
|
if (!value_281) {
|
|
Parser* value_282 = p;
|
|
String value_283 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_282;
|
|
String value_285 = p->source;
|
|
value_283 = StringRange(value_285, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_281 = (StringEqual(value_283, StringLiteral("-")));
|
|
}
|
|
bool value_286 = value_281;
|
|
if (!value_286) {
|
|
Parser* value_287 = p;
|
|
String value_288 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_287;
|
|
String value_290 = p->source;
|
|
value_288 = StringRange(value_290, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_286 = (StringEqual(value_288, StringLiteral("!")));
|
|
}
|
|
bool value_291 = value_286;
|
|
if (!value_291) {
|
|
Parser* value_292 = p;
|
|
String value_293 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_292;
|
|
String value_295 = p->source;
|
|
value_293 = StringRange(value_295, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_291 = (StringEqual(value_293, StringLiteral("~")));
|
|
}
|
|
bool value_296 = value_291;
|
|
if (!value_296) {
|
|
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);
|
|
}
|
|
value_296 = (StringEqual(value_298, StringLiteral("*")));
|
|
}
|
|
if (value_296) {
|
|
Parser* value_301 = p;
|
|
String value_302 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_301;
|
|
String value_304 = p->source;
|
|
value_302 = StringRange(value_304, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String value_305 = StringView(NULL, 0);
|
|
{
|
|
String operator = value_302;
|
|
if (StringEqual(operator, StringLiteral("*"))) {
|
|
value_305 = StringLiteral("&");
|
|
goto value_306;
|
|
}
|
|
if (StringEqual(operator, StringLiteral("+"))) {
|
|
value_305 = StringLiteral("+");
|
|
goto value_306;
|
|
}
|
|
if (StringEqual(operator, StringLiteral("-"))) {
|
|
value_305 = StringLiteral("-");
|
|
goto value_306;
|
|
}
|
|
if (StringEqual(operator, StringLiteral("!"))) {
|
|
value_305 = StringLiteral("!");
|
|
goto value_306;
|
|
}
|
|
value_305 = StringLiteral("~");
|
|
value_306: ;
|
|
}
|
|
String op = value_305;
|
|
Parser* value_307 = p;
|
|
{
|
|
Parser* p = value_307;
|
|
Scan value_309 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_309;
|
|
int64_t value_310 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_310 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
int32_t right = compiler_parse_ParsePrefix(p);
|
|
result = compiler_parse_Node(p, (ZirExprKind)(7), start, StringLiteral(""), op, -1, right);
|
|
} else {
|
|
Parser* value_311 = p;
|
|
String value_312 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_311;
|
|
String value_314 = p->source;
|
|
value_312 = StringRange(value_314, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_312, StringLiteral("&"))) {
|
|
Parser* value_315 = p;
|
|
String value_316 = StringLiteral("C-style address-of is not valid Jai syntax; use *value");
|
|
{
|
|
Parser* p = value_315;
|
|
String message = value_316;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
} else {
|
|
Parser* value_318 = p;
|
|
String value_319 = StringLiteral("(");
|
|
bool value_320 = false;
|
|
{
|
|
Parser* p = value_318;
|
|
String wanted = value_319;
|
|
Parser* value_322 = p;
|
|
String value_323 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_322;
|
|
String value_325 = p->source;
|
|
value_323 = StringRange(value_325, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_323, wanted)) {
|
|
value_320 = false;
|
|
goto value_321;
|
|
}
|
|
Parser* value_326 = p;
|
|
{
|
|
Parser* p = value_326;
|
|
Scan value_328 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_328;
|
|
int64_t value_329 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_329 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_320 = true;
|
|
value_321: ;
|
|
}
|
|
if (value_320) {
|
|
Parser* value_330 = p;
|
|
Parser* value_331 = p;
|
|
String value_332 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_331;
|
|
String value_334 = p->source;
|
|
value_332 = StringRange(value_334, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_335 = false;
|
|
{
|
|
Parser* p = value_330;
|
|
String name = value_332;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_335 = false;
|
|
goto value_336;
|
|
}
|
|
String value_337 = name;
|
|
bool value_338 = false;
|
|
{
|
|
String name = value_337;
|
|
bool value_340 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_338 = value_340 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_341 = value_338;
|
|
if (!value_341) {
|
|
bool value_342 = p->module != ((void *)0);
|
|
bool value_343 = value_342;
|
|
if (value_343) {
|
|
ZirType* value_344 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_343 = (value_344 != ((void *)0));
|
|
}
|
|
value_341 = value_343;
|
|
}
|
|
value_335 = value_341;
|
|
value_336: ;
|
|
}
|
|
bool value_345 = value_335;
|
|
if (!value_345) {
|
|
Parser* value_346 = p;
|
|
String value_347 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_346;
|
|
String value_349 = p->source;
|
|
value_347 = StringRange(value_349, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_345 = (StringEqual(value_347, StringLiteral("[")));
|
|
}
|
|
bool typed = value_345;
|
|
bool value_350 = typed;
|
|
bool value_351 = value_350;
|
|
if (value_351) {
|
|
Parser* value_352 = p;
|
|
String value_353 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_352;
|
|
String value_355 = p->source;
|
|
value_353 = StringRange(value_355, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_351 = (!StringEqual(value_353, StringLiteral(".")));
|
|
}
|
|
bool value_356 = value_351;
|
|
bool value_357 = value_356 && !StringEqual(compiler_parse_Following(p, 1), StringLiteral("."));
|
|
bool value_358 = value_357;
|
|
bool value_359 = value_358;
|
|
if (value_359) {
|
|
bool value_360 = compiler_parse_ArrayLiteralAhead(p);
|
|
value_359 = !value_360;
|
|
}
|
|
if (value_359) {
|
|
Parser* value_361 = p;
|
|
String value_362 = StringLiteral("C-style cast or literal is not valid Jai syntax; use cast(Type) value or Type.{...}");
|
|
{
|
|
Parser* p = value_361;
|
|
String message = value_362;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
result = compiler_parse_ParseBinary(p, 1);
|
|
Parser* value_364 = p;
|
|
String value_365 = StringLiteral(")");
|
|
{
|
|
Parser* p = value_364;
|
|
String wanted = value_365;
|
|
Parser* value_367 = p;
|
|
String value_368 = wanted;
|
|
bool value_369 = false;
|
|
{
|
|
Parser* p = value_367;
|
|
String wanted = value_368;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_369 = false;
|
|
goto value_370;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_369 = true;
|
|
value_370: ;
|
|
}
|
|
if (!value_369) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
bool value_371 = !typed;
|
|
bool value_372 = value_371;
|
|
if (value_372) {
|
|
Parser* value_373 = p;
|
|
String value_374 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_373;
|
|
String value_376 = p->source;
|
|
value_374 = StringRange(value_376, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_372 = (StringEqual(value_374, StringLiteral("{")));
|
|
}
|
|
if (value_372) {
|
|
Parser* value_377 = p;
|
|
String value_378 = StringLiteral("C-style literal is not valid Jai syntax; use Type.{...}");
|
|
{
|
|
Parser* p = value_377;
|
|
String message = value_378;
|
|
compiler_services_Fatal(p->span, StringLiteral("parse.jai_syntax"), message);
|
|
}
|
|
}
|
|
} else {
|
|
Parser* value_380 = p;
|
|
String value_381 = StringLiteral(".");
|
|
bool value_382 = false;
|
|
{
|
|
Parser* p = value_380;
|
|
String wanted = value_381;
|
|
Parser* value_384 = p;
|
|
String value_385 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_384;
|
|
String value_387 = p->source;
|
|
value_385 = StringRange(value_387, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!StringEqual(value_385, wanted)) {
|
|
value_382 = false;
|
|
goto value_383;
|
|
}
|
|
Parser* value_388 = p;
|
|
{
|
|
Parser* p = value_388;
|
|
Scan value_390 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_390;
|
|
int64_t value_391 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_391 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
value_382 = true;
|
|
value_383: ;
|
|
}
|
|
if (value_382) {
|
|
Parser* value_392 = p;
|
|
String value_393 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_392;
|
|
String value_395 = p->source;
|
|
value_393 = StringRange(value_395, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_393, StringLiteral("{"))) {
|
|
result = compiler_parse_ParseInitializer(p, start, StringLiteral(""), StringLiteral("{"), StringLiteral("}"));
|
|
} else {
|
|
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);
|
|
}
|
|
bool value_400 = StringEqual(value_397, StringLiteral("["));
|
|
if (value_400) {
|
|
String value_401 = p->expected_type;
|
|
bool value_402 = false;
|
|
{
|
|
String name = value_401;
|
|
String value_404 = StringView(NULL, 0);
|
|
{
|
|
String text = name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_404 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_405;
|
|
}
|
|
value_404 = text;
|
|
value_405: ;
|
|
}
|
|
ElementType value_406 = compiler_type_ArrayElement(value_404);
|
|
value_402 = value_406.valid;
|
|
}
|
|
value_400 = value_402;
|
|
}
|
|
if (value_400) {
|
|
result = compiler_parse_ParseInitializer(p, start, p->expected_type, StringLiteral("["), StringLiteral("]"));
|
|
} else if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
p->failed = true;
|
|
} else {
|
|
uint8_t buffer[256] = {0};
|
|
Slice value_407 = {buffer, 256};
|
|
Slice value_408 = value_407;
|
|
Parser* value_409 = p;
|
|
String value_410 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_409;
|
|
String value_412 = p->source;
|
|
value_410 = StringRange(value_412, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
String name = compiler_parse_QualifiedName(value_408, StringLiteral(""), value_410, 128LL);
|
|
if ((int64_t)(name).length == 0LL) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_413 = p;
|
|
{
|
|
Parser* p = value_413;
|
|
Scan value_415 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_415;
|
|
int64_t value_416 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_416 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
if (!p->failed) {
|
|
result = compiler_parse_Node(p, (ZirExprKind)(1), start, name, StringLiteral(""), -1, -1);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
Parser* value_417 = p;
|
|
String value_418 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_417;
|
|
String value_420 = p->source;
|
|
value_418 = StringRange(value_420, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_418, StringLiteral("["))) {
|
|
int64_t type_start = p->token.begin;
|
|
while (true) {
|
|
Parser* value_421 = p;
|
|
String value_422 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_421;
|
|
String value_424 = p->source;
|
|
value_422 = StringRange(value_424, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (!(StringEqual(value_422, StringLiteral("[")) && !p->failed)) { break; }
|
|
Parser* value_425 = p;
|
|
{
|
|
Parser* p = value_425;
|
|
Scan value_427 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_427;
|
|
int64_t value_428 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_428 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_429 = p;
|
|
String value_430 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_429;
|
|
String value_432 = p->source;
|
|
value_430 = StringRange(value_432, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
if (StringEqual(value_430, StringLiteral("]"))) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_433 = p;
|
|
{
|
|
Parser* p = value_433;
|
|
Scan value_435 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_435;
|
|
int64_t value_436 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_436 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_437 = p;
|
|
String value_438 = StringLiteral("]");
|
|
{
|
|
Parser* p = value_437;
|
|
String wanted = value_438;
|
|
Parser* value_440 = p;
|
|
String value_441 = wanted;
|
|
bool value_442 = false;
|
|
{
|
|
Parser* p = value_440;
|
|
String wanted = value_441;
|
|
if (!StringEqual(compiler_parse_Token(p), wanted)) {
|
|
value_442 = false;
|
|
goto value_443;
|
|
}
|
|
compiler_parse_Advance(p);
|
|
value_442 = true;
|
|
value_443: ;
|
|
}
|
|
if (!value_442) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
}
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_444 = p;
|
|
{
|
|
Parser* p = value_444;
|
|
Scan value_446 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_446;
|
|
int64_t value_447 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_447 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_448 = p;
|
|
String value_449 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_448;
|
|
String value_451 = p->source;
|
|
value_449 = StringRange(value_451, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
bool value_452 = StringEqual(value_449, StringLiteral(".")) && ((TokenKind)(p->token.kind)) != ((TokenKind)(0));
|
|
if (value_452 && !StringEqual(compiler_parse_Following(p, 1), StringLiteral("["))) {
|
|
Parser* value_453 = p;
|
|
{
|
|
Parser* p = value_453;
|
|
Scan value_455 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_455;
|
|
int64_t value_456 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_456 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
if (((TokenKind)(p->token.kind)) != ((TokenKind)(1))) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_457 = p;
|
|
{
|
|
Parser* p = value_457;
|
|
Scan value_459 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_459;
|
|
int64_t value_460 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_460 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
}
|
|
Parser* value_461 = p;
|
|
String value_462 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_461;
|
|
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) {
|
|
p->failed = true;
|
|
value_462 = StringLiteral("");
|
|
goto value_463;
|
|
}
|
|
String value_464 = p->source;
|
|
String value_465 = StringRange(value_464, (int64_t)start, (int64_t)end);
|
|
String value_466 = StringView(NULL, 0);
|
|
{
|
|
String source = value_465;
|
|
SourceRange range = compiler_text_TrimRange(source);
|
|
value_466 = StringRange(source, (int64_t)range.begin, (int64_t)range.end);
|
|
}
|
|
value_462 = value_466;
|
|
value_463: ;
|
|
}
|
|
String type = value_462;
|
|
bool value_468 = !p->failed;
|
|
bool value_469 = value_468;
|
|
if (value_469) {
|
|
Parser* value_470 = p;
|
|
String value_471 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_470;
|
|
String value_473 = p->source;
|
|
value_471 = StringRange(value_473, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_469 = (StringEqual(value_471, StringLiteral(".")));
|
|
}
|
|
bool value_474 = value_469;
|
|
bool value_475 = value_474 && StringEqual(compiler_parse_Following(p, 1), StringLiteral("["));
|
|
bool value_476 = value_475;
|
|
bool value_477 = value_476;
|
|
if (value_477) {
|
|
bool value_478 = false;
|
|
{
|
|
String name = type;
|
|
String value_480 = StringView(NULL, 0);
|
|
{
|
|
String text = name;
|
|
if ((int64_t)(text).length >= 128LL) {
|
|
value_480 = StringRange(text, (int64_t)0LL, (int64_t)127LL);
|
|
goto value_481;
|
|
}
|
|
value_480 = text;
|
|
value_481: ;
|
|
}
|
|
ElementType value_482 = compiler_type_ArrayElement(value_480);
|
|
value_478 = value_482.valid;
|
|
}
|
|
value_477 = value_478;
|
|
}
|
|
if (value_477) {
|
|
Parser* value_483 = p;
|
|
{
|
|
Parser* p = value_483;
|
|
Scan value_485 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = 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))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_TypedArray(p, start, type);
|
|
} else {
|
|
p->failed = 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))) {
|
|
p->failed = true;
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 1u);
|
|
return -1;
|
|
}
|
|
Parser* value_487 = p;
|
|
{
|
|
Parser* p = value_487;
|
|
Scan value_489 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_489;
|
|
int64_t value_490 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_490 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
bool value_491 = kind == ((ZirExprKind)(1));
|
|
bool value_492 = value_491;
|
|
if (value_492) {
|
|
Parser* value_493 = p;
|
|
String value_494 = StringView(NULL, 0);
|
|
{
|
|
Parser* p = value_493;
|
|
String value_496 = p->source;
|
|
value_494 = StringRange(value_496, (int64_t)p->token.begin, (int64_t)p->token.end);
|
|
}
|
|
value_492 = (StringEqual(value_494, StringLiteral(".")));
|
|
}
|
|
if (value_492) {
|
|
String following = compiler_parse_Following(p, 1);
|
|
if (StringEqual(following, StringLiteral("{"))) {
|
|
Parser* value_497 = p;
|
|
bool value_498 = false;
|
|
{
|
|
Parser* p = value_497;
|
|
String name = original;
|
|
if ((int64_t)(name).length >= 128LL || p->module == ((void *)0)) {
|
|
value_498 = false;
|
|
goto value_499;
|
|
}
|
|
ZirType* record = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_498 = record != ((void *)0) && record->is_enum == 0;
|
|
value_499: ;
|
|
}
|
|
if (!value_498) {
|
|
p->failed = true;
|
|
}
|
|
Parser* value_500 = p;
|
|
{
|
|
Parser* p = value_500;
|
|
Scan value_502 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_502;
|
|
int64_t value_503 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_503 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_ParseInitializer(p, start, original, StringLiteral("{"), StringLiteral("}"));
|
|
} else {
|
|
bool value_504 = StringEqual(following, StringLiteral("["));
|
|
bool value_505 = value_504;
|
|
if (value_505) {
|
|
Parser* value_506 = p;
|
|
bool value_507 = false;
|
|
{
|
|
Parser* p = value_506;
|
|
String name = original;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_507 = false;
|
|
goto value_508;
|
|
}
|
|
String value_509 = name;
|
|
bool value_510 = false;
|
|
{
|
|
String name = value_509;
|
|
bool value_512 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_510 = value_512 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_513 = value_510;
|
|
if (!value_513) {
|
|
bool value_514 = p->module != ((void *)0);
|
|
bool value_515 = value_514;
|
|
if (value_515) {
|
|
ZirType* value_516 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_515 = (value_516 != ((void *)0));
|
|
}
|
|
value_513 = value_515;
|
|
}
|
|
value_507 = value_513;
|
|
value_508: ;
|
|
}
|
|
value_505 = value_507;
|
|
}
|
|
if (value_505) {
|
|
Parser* value_517 = p;
|
|
{
|
|
Parser* p = value_517;
|
|
Scan value_519 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_519;
|
|
int64_t value_520 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_520 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
result = compiler_parse_TypedArray(p, start, original);
|
|
} else {
|
|
Scan value_521 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
if (((TokenKind)(value_521.kind)) == ((TokenKind)(1)) && StringEqual(compiler_parse_Following(p, 2), StringLiteral("."))) {
|
|
uint8_t buffer[256] = {0};
|
|
Slice value_522 = {buffer, 256};
|
|
String qualified = compiler_parse_QualifiedName(value_522, original, following, 128LL);
|
|
String opener = compiler_parse_Following(p, 3);
|
|
bool value_523 = (int64_t)(qualified).length > 0LL;
|
|
bool value_524 = value_523;
|
|
if (value_524) {
|
|
Parser* value_525 = p;
|
|
bool value_526 = false;
|
|
{
|
|
Parser* p = value_525;
|
|
String name = qualified;
|
|
if ((int64_t)(name).length >= 128LL) {
|
|
value_526 = false;
|
|
goto value_527;
|
|
}
|
|
String value_528 = name;
|
|
bool value_529 = false;
|
|
{
|
|
String name = value_528;
|
|
bool value_531 = StringEqual(name, StringLiteral("void")) || StringEqual(name, StringLiteral("string")) || StringEqual(name, StringLiteral("isize"));
|
|
value_529 = value_531 || StringEqual(name, StringLiteral("usize")) || (!StringEqual(name, StringLiteral("integer")) && compiler_type_ScalarByteWidth(name) > 0);
|
|
}
|
|
bool value_532 = value_529;
|
|
if (!value_532) {
|
|
bool value_533 = p->module != ((void *)0);
|
|
bool value_534 = value_533;
|
|
if (value_534) {
|
|
ZirType* value_535 = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_534 = (value_535 != ((void *)0));
|
|
}
|
|
value_532 = value_534;
|
|
}
|
|
value_526 = value_532;
|
|
value_527: ;
|
|
}
|
|
value_524 = value_526;
|
|
}
|
|
if (value_524 && (StringEqual(opener, StringLiteral("[")) || StringEqual(opener, StringLiteral("{")))) {
|
|
Parser* value_536 = p;
|
|
{
|
|
Parser* p = value_536;
|
|
Scan value_538 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_538;
|
|
int64_t value_539 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_539 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_540 = p;
|
|
{
|
|
Parser* p = value_540;
|
|
Scan value_542 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_542;
|
|
int64_t value_543 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_543 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
Parser* value_544 = p;
|
|
{
|
|
Parser* p = value_544;
|
|
Scan value_546 = compiler_scan_NextToken(p->source, p->token.end, 1, 1);
|
|
p->token = value_546;
|
|
int64_t value_547 = (int64_t)((uint64_t)(p->token.end) - (uint64_t)(p->token.begin));
|
|
if (value_547 >= 4096LL && ((TokenKind)(p->token.kind)) != ((TokenKind)(4))) {
|
|
p->failed = true;
|
|
}
|
|
}
|
|
if (StringEqual(opener, StringLiteral("["))) {
|
|
result = compiler_parse_TypedArray(p, start, qualified);
|
|
} else {
|
|
Parser* value_548 = p;
|
|
bool value_549 = false;
|
|
{
|
|
Parser* p = value_548;
|
|
String name = qualified;
|
|
if ((int64_t)(name).length >= 128LL || p->module == ((void *)0)) {
|
|
value_549 = false;
|
|
goto value_550;
|
|
}
|
|
ZirType* record = compiler_services_FindType(p->module, name, (void *)0);
|
|
value_549 = record != ((void *)0) && record->is_enum == 0;
|
|
value_550: ;
|
|
}
|
|
if (!value_549) {
|
|
p->failed = 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);
|
|
p->depth = (int32_t)((uint32_t)(p->depth) - 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 *)output.data)[SliceIndex(output, (int64_t)index)] = (uint8_t)first.data[index];
|
|
if (index == range_last_4) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
((uint8_t *)output.data)[SliceIndex(output, (int64_t)(int64_t)(first).length)] = 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 *)output.data)[SliceIndex(output, (int64_t)((int64_t)(((uint64_t)((int64_t)(first).length) + UINT64_C(1)) + (uint64_t)index)))] = (uint8_t)second.data[index];
|
|
if (index == range_last_8) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
Slice value_0 = output;
|
|
Slice value_1 = SliceRange(value_0, (int64_t)0LL, (int64_t)count, sizeof(uint8_t));
|
|
return StringView((const char *)(value_1).data, (size_t)(value_1).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;
|
|
}
|