Move 222 compiler modules under cmd/compiler and remove the repeated compiler_ filename prefix. Update file imports, native symbol bindings, build rules, bootstrap metadata and seeds, retained fixtures and docs. Document the existing shared lowering pipeline and measured source-size baseline, with feature-preserving sharing priorities and separate speed acceptance criteria. No performance improvement is claimed for the move. Local tests: all 272 retained make check cases (0 reused); bootstrap update and independent make check-bootstrap reproduce all 95 roots at stage 2.
3477 lines
140 KiB
C
3477 lines
140 KiB
C
/* Generated by zi2c from source.zi. */
|
|
#define ZIRAN_SOURCE_H_SOURCE 1
|
|
#include <stdbool.h>
|
|
#include "zir_string.h"
|
|
#include "source.h"
|
|
#include "ziran_compiler.h"
|
|
static uint8_t source_Byte(String source, int64_t at) ZIRAN_MAYBE_UNUSED;
|
|
static bool source_Space(uint8_t byte) ZIRAN_MAYBE_UNUSED;
|
|
static bool source_Letter(uint8_t byte) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t source_SkipSpace(String source, int64_t at) ZIRAN_MAYBE_UNUSED;
|
|
static bool source_Matches(String source, int64_t at, String text) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t source_Find(String source, String text) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t source_FindCode(String source, String text) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t source_AfterQuote(String source, int64_t at) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t source_ClosedQuote(String source, int64_t at) ZIRAN_MAYBE_UNUSED;
|
|
static void source_Put(Slice output, int64_t* used, uint8_t byte) ZIRAN_MAYBE_UNUSED;
|
|
static void source_PutScanned(Slice output, int64_t* used, uint8_t byte, int64_t* gaps) ZIRAN_MAYBE_UNUSED;
|
|
static void source_PutRaw(Slice output, int64_t* used, uint8_t byte) ZIRAN_MAYBE_UNUSED;
|
|
static bool source_LiteralPosition(String source, int64_t at) ZIRAN_MAYBE_UNUSED;
|
|
static bool source_TypedParameters(String source) ZIRAN_MAYBE_UNUSED;
|
|
static int64_t source_LiteralBody(String source, int64_t close) ZIRAN_MAYBE_UNUSED;
|
|
|
|
static uint8_t
|
|
source_Byte(String source, int64_t at)
|
|
{
|
|
if (at < 0LL || at >= (int64_t)(source).length) {
|
|
return 0;
|
|
}
|
|
return (uint8_t)source.data[at];
|
|
}
|
|
|
|
static bool
|
|
source_Space(uint8_t byte)
|
|
{
|
|
return byte == 32 || (byte >= 9 && byte <= 13);
|
|
}
|
|
|
|
static bool
|
|
source_Letter(uint8_t byte)
|
|
{
|
|
return (byte >= 65 && byte <= 90) || (byte >= 97 && byte <= 122) || byte == 95;
|
|
}
|
|
|
|
static int64_t
|
|
source_SkipSpace(String source, int64_t at)
|
|
{
|
|
while (true) {
|
|
bool value_0 = at < (int64_t)(source).length;
|
|
if (value_0) {
|
|
uint8_t value_1 = (uint8_t)source.data[at];
|
|
bool value_2 = false;
|
|
{
|
|
uint8_t value_4 = value_1;
|
|
value_2 = value_4 == 32 || (value_4 >= 9 && value_4 <= 13);
|
|
}
|
|
value_0 = value_2;
|
|
}
|
|
if (!value_0) { break; }
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return at;
|
|
}
|
|
|
|
static bool
|
|
source_Matches(String source, int64_t at, String text)
|
|
{
|
|
bool value_0 = at >= 0LL && at <= (int64_t)(source).length && (int64_t)(text).length <= (int64_t)((uint64_t)((int64_t)(source).length) - (uint64_t)at);
|
|
return value_0 && StringEqual(StringRangeAt(source, (int64_t)at, (int64_t)((int64_t)((uint64_t)at + (uint64_t)((int64_t)(text).length)))), text);
|
|
}
|
|
|
|
static int64_t
|
|
source_Find(String source, String text)
|
|
{
|
|
int64_t at = 0LL;
|
|
while (at <= (int64_t)(source).length) {
|
|
bool value_0 = (int64_t)(text).length == 0LL || (at < (int64_t)(source).length && (uint8_t)source.data[at] == (uint8_t)text.data[0]);
|
|
bool value_1 = value_0;
|
|
bool value_2 = value_1;
|
|
if (value_2) {
|
|
String value_3 = source;
|
|
int64_t value_4 = at;
|
|
String value_5 = text;
|
|
bool value_6 = false;
|
|
{
|
|
String value_8 = value_3;
|
|
int64_t value_9 = value_4;
|
|
String value_10 = value_5;
|
|
bool value_11 = value_9 >= 0LL && value_9 <= (int64_t)(value_8).length && (int64_t)(value_10).length <= (int64_t)((uint64_t)((int64_t)(value_8).length) - (uint64_t)value_9);
|
|
value_6 = value_11 && StringEqual(StringRangeAt(value_8, (int64_t)value_9, (int64_t)((int64_t)((uint64_t)value_9 + (uint64_t)((int64_t)(value_10).length)))), value_10);
|
|
}
|
|
value_2 = value_6;
|
|
}
|
|
if (value_2) {
|
|
return at;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
static int64_t
|
|
source_FindCode(String source, String text)
|
|
{
|
|
int64_t at = 0LL;
|
|
while (at <= (int64_t)(source).length) {
|
|
if (at < (int64_t)(source).length && (uint8_t)source.data[at] == 34) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
bool value_0 = (int64_t)(text).length == 0LL || (at < (int64_t)(source).length && (uint8_t)source.data[at] == (uint8_t)text.data[0]);
|
|
bool value_1 = value_0;
|
|
bool value_2 = value_1;
|
|
if (value_2) {
|
|
String value_3 = source;
|
|
int64_t value_4 = at;
|
|
String value_5 = text;
|
|
bool value_6 = false;
|
|
{
|
|
String value_8 = value_3;
|
|
int64_t value_9 = value_4;
|
|
String value_10 = value_5;
|
|
bool value_11 = value_9 >= 0LL && value_9 <= (int64_t)(value_8).length && (int64_t)(value_10).length <= (int64_t)((uint64_t)((int64_t)(value_8).length) - (uint64_t)value_9);
|
|
value_6 = value_11 && StringEqual(StringRangeAt(value_8, (int64_t)value_9, (int64_t)((int64_t)((uint64_t)value_9 + (uint64_t)((int64_t)(value_10).length)))), value_10);
|
|
}
|
|
value_2 = value_6;
|
|
}
|
|
if (value_2) {
|
|
return at;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
static int64_t
|
|
source_AfterQuote(String source, int64_t at)
|
|
{
|
|
uint8_t quote = (uint8_t)source.data[at];
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
if (byte == 92 && at < (int64_t)(source).length) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (byte == quote) {
|
|
break;
|
|
}
|
|
}
|
|
return at;
|
|
}
|
|
|
|
static int64_t
|
|
source_ClosedQuote(String source, int64_t at)
|
|
{
|
|
uint8_t quote = (uint8_t)source.data[at];
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
if (byte == 92 && at < (int64_t)(source).length) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (byte == quote) {
|
|
return at;
|
|
}
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
static void
|
|
source_Put(Slice output, int64_t* used, uint8_t byte)
|
|
{
|
|
int64_t value_0 = *(used);
|
|
int64_t value_1 = (int64_t)(output).length;
|
|
if (value_0 < value_1) {
|
|
uint8_t* value_2 = &(((uint8_t *)(output).data)[*(used)]);
|
|
(*value_2) = byte;
|
|
}
|
|
int64_t* value_3 = &((*(used)));
|
|
(*value_3) = (int64_t)((uint64_t)((*value_3)) + UINT64_C(1));
|
|
}
|
|
|
|
static void
|
|
source_PutScanned(Slice output, int64_t* used, uint8_t byte, int64_t* gaps)
|
|
{
|
|
source_Put(output, used, byte);
|
|
if (byte == 10) {
|
|
while (true) {
|
|
int64_t value_0 = *(gaps);
|
|
if (!(value_0 > 0LL)) { break; }
|
|
source_Put(output, used, 10);
|
|
int64_t* value_1 = &((*(gaps)));
|
|
(*value_1) = (int64_t)((uint64_t)((*value_1)) - UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
source_PutRaw(Slice output, int64_t* used, uint8_t byte)
|
|
{
|
|
uint8_t escaped = 0;
|
|
if (byte == 34 || byte == 92) {
|
|
escaped = byte;
|
|
} else if (byte == 10) {
|
|
escaped = 110;
|
|
} else if (byte == 13) {
|
|
escaped = 114;
|
|
} else if (byte == 9) {
|
|
escaped = 116;
|
|
}
|
|
if (escaped != 0) {
|
|
source_Put(output, used, 92);
|
|
source_Put(output, used, escaped);
|
|
} else if (byte < 32 || byte == 127) {
|
|
String digits = StringLiteral("0123456789abcdef");
|
|
source_Put(output, used, 92);
|
|
source_Put(output, used, 120);
|
|
source_Put(output, used, (uint8_t)digits.data[((uint8_t)(byte >> 4))]);
|
|
source_Put(output, used, (uint8_t)digits.data[((uint8_t)((uint32_t)byte & 15u))]);
|
|
} else {
|
|
source_Put(output, used, byte);
|
|
}
|
|
}
|
|
|
|
bool
|
|
source_SourceIdentifier(uint8_t byte)
|
|
{
|
|
uint8_t value_0 = byte;
|
|
bool value_1 = false;
|
|
{
|
|
uint8_t value_3 = value_0;
|
|
value_1 = (value_3 >= 65 && value_3 <= 90) || (value_3 >= 97 && value_3 <= 122) || value_3 == 95;
|
|
}
|
|
return value_1 || (byte >= 48 && byte <= 57);
|
|
}
|
|
|
|
int64_t
|
|
source_FindUnquoted(String source, String needle, bool word)
|
|
{
|
|
int64_t at = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
if ((uint8_t)source.data[at] == 34 || (uint8_t)source.data[at] == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
bool value_0 = (int64_t)(needle).length == 0LL || (uint8_t)source.data[at] == (uint8_t)needle.data[0];
|
|
bool value_1 = value_0;
|
|
if (value_1) {
|
|
String value_2 = source;
|
|
int64_t value_3 = at;
|
|
bool value_4 = false;
|
|
{
|
|
String value_6 = value_2;
|
|
int64_t value_7 = value_3;
|
|
String value_8 = needle;
|
|
bool value_9 = value_7 >= 0LL && value_7 <= (int64_t)(value_6).length && (int64_t)(value_8).length <= (int64_t)((uint64_t)((int64_t)(value_6).length) - (uint64_t)value_7);
|
|
value_4 = value_9 && StringEqual(StringRangeAt(value_6, (int64_t)value_7, (int64_t)((int64_t)((uint64_t)value_7 + (uint64_t)((int64_t)(value_8).length)))), value_8);
|
|
}
|
|
value_1 = value_4;
|
|
}
|
|
bool value_10 = value_1;
|
|
bool value_11 = value_10;
|
|
if (value_11) {
|
|
bool value_12 = !word;
|
|
if (!value_12) {
|
|
String value_13 = source;
|
|
int64_t value_14 = (int64_t)((uint64_t)at - UINT64_C(1));
|
|
uint8_t value_15 = 0;
|
|
{
|
|
String value_17 = value_13;
|
|
int64_t value_18 = value_14;
|
|
if (value_18 < 0LL || value_18 >= (int64_t)(value_17).length) {
|
|
value_15 = 0;
|
|
goto value_16;
|
|
}
|
|
value_15 = (uint8_t)value_17.data[value_18];
|
|
value_16: ;
|
|
}
|
|
bool value_19 = false;
|
|
{
|
|
uint8_t value_21 = value_15;
|
|
bool value_22 = false;
|
|
{
|
|
uint8_t value_24 = value_21;
|
|
value_22 = (value_24 >= 65 && value_24 <= 90) || (value_24 >= 97 && value_24 <= 122) || value_24 == 95;
|
|
}
|
|
value_19 = value_22 || (value_21 >= 48 && value_21 <= 57);
|
|
}
|
|
bool value_25 = !value_19;
|
|
if (value_25) {
|
|
String value_26 = source;
|
|
int64_t value_27 = (int64_t)((uint64_t)at + (uint64_t)((int64_t)(needle).length));
|
|
uint8_t value_28 = 0;
|
|
{
|
|
String value_30 = value_26;
|
|
int64_t value_31 = value_27;
|
|
if (value_31 < 0LL || value_31 >= (int64_t)(value_30).length) {
|
|
value_28 = 0;
|
|
goto value_29;
|
|
}
|
|
value_28 = (uint8_t)value_30.data[value_31];
|
|
value_29: ;
|
|
}
|
|
bool value_32 = false;
|
|
{
|
|
uint8_t value_34 = value_28;
|
|
bool value_35 = false;
|
|
{
|
|
uint8_t value_37 = value_34;
|
|
value_35 = (value_37 >= 65 && value_37 <= 90) || (value_37 >= 97 && value_37 <= 122) || value_37 == 95;
|
|
}
|
|
value_32 = value_35 || (value_34 >= 48 && value_34 <= 57);
|
|
}
|
|
value_25 = !value_32;
|
|
}
|
|
value_12 = value_25;
|
|
}
|
|
value_11 = value_12;
|
|
}
|
|
if (value_11) {
|
|
return at;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
bool
|
|
source_StartsWord(String source, String word)
|
|
{
|
|
String value_0 = source;
|
|
bool value_1 = false;
|
|
{
|
|
String value_3 = value_0;
|
|
int64_t value_4 = 0LL;
|
|
String value_5 = word;
|
|
bool value_6 = value_4 >= 0LL && value_4 <= (int64_t)(value_3).length && (int64_t)(value_5).length <= (int64_t)((uint64_t)((int64_t)(value_3).length) - (uint64_t)value_4);
|
|
value_1 = value_6 && StringEqual(StringRangeAt(value_3, (int64_t)value_4, (int64_t)((int64_t)((uint64_t)value_4 + (uint64_t)((int64_t)(value_5).length)))), value_5);
|
|
}
|
|
if (!value_1) {
|
|
return false;
|
|
}
|
|
String value_7 = source;
|
|
int64_t value_8 = (int64_t)(word).length;
|
|
uint8_t value_9 = 0;
|
|
{
|
|
String value_11 = value_7;
|
|
int64_t value_12 = value_8;
|
|
if (value_12 < 0LL || value_12 >= (int64_t)(value_11).length) {
|
|
value_9 = 0;
|
|
goto value_10;
|
|
}
|
|
value_9 = (uint8_t)value_11.data[value_12];
|
|
value_10: ;
|
|
}
|
|
uint8_t byte = value_9;
|
|
return byte == 0 || byte == 32 || byte == 9 || byte == 40 || byte == 34 || byte == 123;
|
|
}
|
|
|
|
bool
|
|
source_IdentifierText(String source, bool member_path)
|
|
{
|
|
bool value_0 = (int64_t)(source).length == 0LL;
|
|
if (!value_0) {
|
|
uint8_t value_1 = (uint8_t)source.data[0];
|
|
bool value_2 = false;
|
|
{
|
|
uint8_t value_4 = value_1;
|
|
value_2 = (value_4 >= 65 && value_4 <= 90) || (value_4 >= 97 && value_4 <= 122) || value_4 == 95;
|
|
}
|
|
value_0 = !value_2;
|
|
}
|
|
if (value_0) {
|
|
return false;
|
|
}
|
|
int64_t at = 1LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t value_5 = (uint8_t)source.data[at];
|
|
bool value_6 = false;
|
|
{
|
|
uint8_t value_8 = value_5;
|
|
bool value_9 = false;
|
|
{
|
|
uint8_t value_11 = value_8;
|
|
value_9 = (value_11 >= 65 && value_11 <= 90) || (value_11 >= 97 && value_11 <= 122) || value_11 == 95;
|
|
}
|
|
value_6 = value_9 || (value_8 >= 48 && value_8 <= 57);
|
|
}
|
|
if (value_6) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else {
|
|
bool value_12 = member_path && (uint8_t)source.data[at] == 46;
|
|
bool value_13 = value_12;
|
|
if (value_13) {
|
|
String value_14 = source;
|
|
int64_t value_15 = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
uint8_t value_16 = 0;
|
|
{
|
|
String value_18 = value_14;
|
|
int64_t value_19 = value_15;
|
|
if (value_19 < 0LL || value_19 >= (int64_t)(value_18).length) {
|
|
value_16 = 0;
|
|
goto value_17;
|
|
}
|
|
value_16 = (uint8_t)value_18.data[value_19];
|
|
value_17: ;
|
|
}
|
|
bool value_20 = false;
|
|
{
|
|
uint8_t value_22 = value_16;
|
|
value_20 = (value_22 >= 65 && value_22 <= 90) || (value_22 >= 97 && value_22 <= 122) || value_22 == 95;
|
|
}
|
|
value_13 = value_20;
|
|
}
|
|
if (value_13) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
source_NonJaiControl(String source, String word)
|
|
{
|
|
String value_0 = source;
|
|
String value_1 = word;
|
|
bool value_2 = false;
|
|
{
|
|
String value_4 = value_0;
|
|
String value_5 = value_1;
|
|
bool value_6 = false;
|
|
{
|
|
String value_8 = value_4;
|
|
int64_t value_9 = 0LL;
|
|
String value_10 = value_5;
|
|
bool value_11 = value_9 >= 0LL && value_9 <= (int64_t)(value_8).length && (int64_t)(value_10).length <= (int64_t)((uint64_t)((int64_t)(value_8).length) - (uint64_t)value_9);
|
|
value_6 = value_11 && StringEqual(StringRangeAt(value_8, (int64_t)value_9, (int64_t)((int64_t)((uint64_t)value_9 + (uint64_t)((int64_t)(value_10).length)))), value_10);
|
|
}
|
|
if (!value_6) {
|
|
value_2 = false;
|
|
goto value_3;
|
|
}
|
|
int64_t value_12 = (int64_t)(value_5).length;
|
|
uint8_t value_13 = 0;
|
|
{
|
|
String value_15 = value_4;
|
|
int64_t value_16 = value_12;
|
|
if (value_16 < 0LL || value_16 >= (int64_t)(value_15).length) {
|
|
value_13 = 0;
|
|
goto value_14;
|
|
}
|
|
value_13 = (uint8_t)value_15.data[value_16];
|
|
value_14: ;
|
|
}
|
|
uint8_t value_17 = value_13;
|
|
value_2 = value_17 == 0 || value_17 == 32 || value_17 == 9 || value_17 == 40 || value_17 == 34 || value_17 == 123;
|
|
value_3: ;
|
|
}
|
|
if (!value_2) {
|
|
return false;
|
|
}
|
|
int64_t at = source_SkipSpace(source, (int64_t)(word).length);
|
|
String value_18 = source;
|
|
int64_t value_19 = at;
|
|
uint8_t value_20 = 0;
|
|
{
|
|
String value_22 = value_18;
|
|
int64_t value_23 = value_19;
|
|
if (value_23 < 0LL || value_23 >= (int64_t)(value_22).length) {
|
|
value_20 = 0;
|
|
goto value_21;
|
|
}
|
|
value_20 = (uint8_t)value_22.data[value_23];
|
|
value_21: ;
|
|
}
|
|
uint8_t byte = value_20;
|
|
if (byte == 40) {
|
|
int64_t value_24 = source_Find(StringRangeAt(source, (int64_t)at, (int64_t)source.length), StringLiteral("{"));
|
|
return value_24 >= 0LL;
|
|
}
|
|
String operators = StringLiteral(":=.[+-*/%&|^<>!");
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(operators).length; it_index++) {
|
|
uint8_t operator_byte = (uint8_t)operators.data[it_index];
|
|
if (byte == operator_byte) {
|
|
return false;
|
|
}
|
|
}
|
|
bool value_25 = byte == 0 || byte == 59 || byte == 123;
|
|
if (!value_25) {
|
|
uint8_t value_26 = byte;
|
|
bool value_27 = false;
|
|
{
|
|
uint8_t value_29 = value_26;
|
|
bool value_30 = false;
|
|
{
|
|
uint8_t value_32 = value_29;
|
|
value_30 = (value_32 >= 65 && value_32 <= 90) || (value_32 >= 97 && value_32 <= 122) || value_32 == 95;
|
|
}
|
|
value_27 = value_30 || (value_29 >= 48 && value_29 <= 57);
|
|
}
|
|
value_25 = value_27;
|
|
}
|
|
return value_25;
|
|
}
|
|
|
|
bool
|
|
source_LooksLikeLabel(String source)
|
|
{
|
|
int64_t at = 0LL;
|
|
while (true) {
|
|
String value_0 = source;
|
|
int64_t value_1 = at;
|
|
uint8_t value_2 = 0;
|
|
{
|
|
String value_4 = value_0;
|
|
int64_t value_5 = value_1;
|
|
if (value_5 < 0LL || value_5 >= (int64_t)(value_4).length) {
|
|
value_2 = 0;
|
|
goto value_3;
|
|
}
|
|
value_2 = (uint8_t)value_4.data[value_5];
|
|
value_3: ;
|
|
}
|
|
bool value_6 = false;
|
|
{
|
|
uint8_t value_8 = value_2;
|
|
bool value_9 = false;
|
|
{
|
|
uint8_t value_11 = value_8;
|
|
value_9 = (value_11 >= 65 && value_11 <= 90) || (value_11 >= 97 && value_11 <= 122) || value_11 == 95;
|
|
}
|
|
value_6 = value_9 || (value_8 >= 48 && value_8 <= 57);
|
|
}
|
|
if (!value_6) { break; }
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
bool value_12 = at == 0LL;
|
|
if (!value_12) {
|
|
String value_13 = source;
|
|
int64_t value_14 = at;
|
|
uint8_t value_15 = 0;
|
|
{
|
|
String value_17 = value_13;
|
|
int64_t value_18 = value_14;
|
|
if (value_18 < 0LL || value_18 >= (int64_t)(value_17).length) {
|
|
value_15 = 0;
|
|
goto value_16;
|
|
}
|
|
value_15 = (uint8_t)value_17.data[value_18];
|
|
value_16: ;
|
|
}
|
|
value_12 = (value_15 != 58);
|
|
}
|
|
if (value_12) {
|
|
return false;
|
|
}
|
|
at = source_SkipSpace(source, (int64_t)((uint64_t)at + UINT64_C(1)));
|
|
return at == (int64_t)(source).length || StringEqual(StringRangeAt(source, (int64_t)at, (int64_t)source.length), StringLiteral(";"));
|
|
}
|
|
|
|
StatementKind
|
|
source_ClassifyStatement(String source)
|
|
{
|
|
String value_0 = source;
|
|
uint8_t value_1 = 0;
|
|
{
|
|
String value_3 = value_0;
|
|
int64_t value_4 = 0LL;
|
|
if (value_4 < 0LL || value_4 >= (int64_t)(value_3).length) {
|
|
value_1 = 0;
|
|
goto value_2;
|
|
}
|
|
value_1 = (uint8_t)value_3.data[value_4];
|
|
value_2: ;
|
|
}
|
|
if (value_1 == 125) {
|
|
return StatementKind_BlockClose;
|
|
}
|
|
if (StringEqual(source, StringLiteral("{"))) {
|
|
return StatementKind_BlockOpen;
|
|
}
|
|
String value_5 = source;
|
|
uint8_t value_6 = 0;
|
|
{
|
|
String value_8 = value_5;
|
|
int64_t value_9 = 0LL;
|
|
if (value_9 < 0LL || value_9 >= (int64_t)(value_8).length) {
|
|
value_6 = 0;
|
|
goto value_7;
|
|
}
|
|
value_6 = (uint8_t)value_8.data[value_9];
|
|
value_7: ;
|
|
}
|
|
bool value_10 = value_6 == 35;
|
|
if (value_10) {
|
|
String value_11 = source;
|
|
String value_12 = StringLiteral("#asm");
|
|
bool value_13 = false;
|
|
{
|
|
String value_15 = value_11;
|
|
String value_16 = value_12;
|
|
bool value_17 = false;
|
|
{
|
|
String value_19 = value_15;
|
|
int64_t value_20 = 0LL;
|
|
String value_21 = value_16;
|
|
bool value_22 = value_20 >= 0LL && value_20 <= (int64_t)(value_19).length && (int64_t)(value_21).length <= (int64_t)((uint64_t)((int64_t)(value_19).length) - (uint64_t)value_20);
|
|
value_17 = value_22 && StringEqual(StringRangeAt(value_19, (int64_t)value_20, (int64_t)((int64_t)((uint64_t)value_20 + (uint64_t)((int64_t)(value_21).length)))), value_21);
|
|
}
|
|
if (!value_17) {
|
|
value_13 = false;
|
|
goto value_14;
|
|
}
|
|
int64_t value_23 = (int64_t)(value_16).length;
|
|
uint8_t value_24 = 0;
|
|
{
|
|
String value_26 = value_15;
|
|
int64_t value_27 = value_23;
|
|
if (value_27 < 0LL || value_27 >= (int64_t)(value_26).length) {
|
|
value_24 = 0;
|
|
goto value_25;
|
|
}
|
|
value_24 = (uint8_t)value_26.data[value_27];
|
|
value_25: ;
|
|
}
|
|
uint8_t value_28 = value_24;
|
|
value_13 = value_28 == 0 || value_28 == 32 || value_28 == 9 || value_28 == 40 || value_28 == 34 || value_28 == 123;
|
|
value_14: ;
|
|
}
|
|
value_10 = value_13;
|
|
}
|
|
if (value_10) {
|
|
return StatementKind_BlockOpen;
|
|
}
|
|
String value_29 = source;
|
|
String value_30 = StringLiteral("if");
|
|
bool value_31 = false;
|
|
{
|
|
String value_33 = value_29;
|
|
String value_34 = value_30;
|
|
bool value_35 = false;
|
|
{
|
|
String value_37 = value_33;
|
|
int64_t value_38 = 0LL;
|
|
String value_39 = value_34;
|
|
bool value_40 = value_38 >= 0LL && value_38 <= (int64_t)(value_37).length && (int64_t)(value_39).length <= (int64_t)((uint64_t)((int64_t)(value_37).length) - (uint64_t)value_38);
|
|
value_35 = value_40 && StringEqual(StringRangeAt(value_37, (int64_t)value_38, (int64_t)((int64_t)((uint64_t)value_38 + (uint64_t)((int64_t)(value_39).length)))), value_39);
|
|
}
|
|
if (!value_35) {
|
|
value_31 = false;
|
|
goto value_32;
|
|
}
|
|
int64_t value_41 = (int64_t)(value_34).length;
|
|
uint8_t value_42 = 0;
|
|
{
|
|
String value_44 = value_33;
|
|
int64_t value_45 = value_41;
|
|
if (value_45 < 0LL || value_45 >= (int64_t)(value_44).length) {
|
|
value_42 = 0;
|
|
goto value_43;
|
|
}
|
|
value_42 = (uint8_t)value_44.data[value_45];
|
|
value_43: ;
|
|
}
|
|
uint8_t value_46 = value_42;
|
|
value_31 = value_46 == 0 || value_46 == 32 || value_46 == 9 || value_46 == 40 || value_46 == 34 || value_46 == 123;
|
|
value_32: ;
|
|
}
|
|
bool value_47 = value_31;
|
|
if (!value_47) {
|
|
String value_48 = source;
|
|
String value_49 = StringLiteral("else");
|
|
bool value_50 = false;
|
|
{
|
|
String value_52 = value_48;
|
|
String value_53 = value_49;
|
|
bool value_54 = false;
|
|
{
|
|
String value_56 = value_52;
|
|
int64_t value_57 = 0LL;
|
|
String value_58 = value_53;
|
|
bool value_59 = value_57 >= 0LL && value_57 <= (int64_t)(value_56).length && (int64_t)(value_58).length <= (int64_t)((uint64_t)((int64_t)(value_56).length) - (uint64_t)value_57);
|
|
value_54 = value_59 && StringEqual(StringRangeAt(value_56, (int64_t)value_57, (int64_t)((int64_t)((uint64_t)value_57 + (uint64_t)((int64_t)(value_58).length)))), value_58);
|
|
}
|
|
if (!value_54) {
|
|
value_50 = false;
|
|
goto value_51;
|
|
}
|
|
int64_t value_60 = (int64_t)(value_53).length;
|
|
uint8_t value_61 = 0;
|
|
{
|
|
String value_63 = value_52;
|
|
int64_t value_64 = value_60;
|
|
if (value_64 < 0LL || value_64 >= (int64_t)(value_63).length) {
|
|
value_61 = 0;
|
|
goto value_62;
|
|
}
|
|
value_61 = (uint8_t)value_63.data[value_64];
|
|
value_62: ;
|
|
}
|
|
uint8_t value_65 = value_61;
|
|
value_50 = value_65 == 0 || value_65 == 32 || value_65 == 9 || value_65 == 40 || value_65 == 34 || value_65 == 123;
|
|
value_51: ;
|
|
}
|
|
value_47 = value_50;
|
|
}
|
|
if (value_47) {
|
|
return StatementKind_If;
|
|
}
|
|
String value_66 = source;
|
|
String value_67 = StringLiteral("while");
|
|
bool value_68 = false;
|
|
{
|
|
String value_70 = value_66;
|
|
String value_71 = value_67;
|
|
bool value_72 = false;
|
|
{
|
|
String value_74 = value_70;
|
|
int64_t value_75 = 0LL;
|
|
String value_76 = value_71;
|
|
bool value_77 = value_75 >= 0LL && value_75 <= (int64_t)(value_74).length && (int64_t)(value_76).length <= (int64_t)((uint64_t)((int64_t)(value_74).length) - (uint64_t)value_75);
|
|
value_72 = value_77 && StringEqual(StringRangeAt(value_74, (int64_t)value_75, (int64_t)((int64_t)((uint64_t)value_75 + (uint64_t)((int64_t)(value_76).length)))), value_76);
|
|
}
|
|
if (!value_72) {
|
|
value_68 = false;
|
|
goto value_69;
|
|
}
|
|
int64_t value_78 = (int64_t)(value_71).length;
|
|
uint8_t value_79 = 0;
|
|
{
|
|
String value_81 = value_70;
|
|
int64_t value_82 = value_78;
|
|
if (value_82 < 0LL || value_82 >= (int64_t)(value_81).length) {
|
|
value_79 = 0;
|
|
goto value_80;
|
|
}
|
|
value_79 = (uint8_t)value_81.data[value_82];
|
|
value_80: ;
|
|
}
|
|
uint8_t value_83 = value_79;
|
|
value_68 = value_83 == 0 || value_83 == 32 || value_83 == 9 || value_83 == 40 || value_83 == 34 || value_83 == 123;
|
|
value_69: ;
|
|
}
|
|
if (value_68) {
|
|
return StatementKind_While;
|
|
}
|
|
String value_84 = source;
|
|
String value_85 = StringLiteral("for");
|
|
bool value_86 = false;
|
|
{
|
|
String value_88 = value_84;
|
|
String value_89 = value_85;
|
|
bool value_90 = false;
|
|
{
|
|
String value_92 = value_88;
|
|
int64_t value_93 = 0LL;
|
|
String value_94 = value_89;
|
|
bool value_95 = value_93 >= 0LL && value_93 <= (int64_t)(value_92).length && (int64_t)(value_94).length <= (int64_t)((uint64_t)((int64_t)(value_92).length) - (uint64_t)value_93);
|
|
value_90 = value_95 && StringEqual(StringRangeAt(value_92, (int64_t)value_93, (int64_t)((int64_t)((uint64_t)value_93 + (uint64_t)((int64_t)(value_94).length)))), value_94);
|
|
}
|
|
if (!value_90) {
|
|
value_86 = false;
|
|
goto value_87;
|
|
}
|
|
int64_t value_96 = (int64_t)(value_89).length;
|
|
uint8_t value_97 = 0;
|
|
{
|
|
String value_99 = value_88;
|
|
int64_t value_100 = value_96;
|
|
if (value_100 < 0LL || value_100 >= (int64_t)(value_99).length) {
|
|
value_97 = 0;
|
|
goto value_98;
|
|
}
|
|
value_97 = (uint8_t)value_99.data[value_100];
|
|
value_98: ;
|
|
}
|
|
uint8_t value_101 = value_97;
|
|
value_86 = value_101 == 0 || value_101 == 32 || value_101 == 9 || value_101 == 40 || value_101 == 34 || value_101 == 123;
|
|
value_87: ;
|
|
}
|
|
if (value_86) {
|
|
return StatementKind_For;
|
|
}
|
|
String value_102 = source;
|
|
String value_103 = StringLiteral("case");
|
|
bool value_104 = false;
|
|
{
|
|
String value_106 = value_102;
|
|
String value_107 = value_103;
|
|
bool value_108 = false;
|
|
{
|
|
String value_110 = value_106;
|
|
int64_t value_111 = 0LL;
|
|
String value_112 = value_107;
|
|
bool value_113 = value_111 >= 0LL && value_111 <= (int64_t)(value_110).length && (int64_t)(value_112).length <= (int64_t)((uint64_t)((int64_t)(value_110).length) - (uint64_t)value_111);
|
|
value_108 = value_113 && StringEqual(StringRangeAt(value_110, (int64_t)value_111, (int64_t)((int64_t)((uint64_t)value_111 + (uint64_t)((int64_t)(value_112).length)))), value_112);
|
|
}
|
|
if (!value_108) {
|
|
value_104 = false;
|
|
goto value_105;
|
|
}
|
|
int64_t value_114 = (int64_t)(value_107).length;
|
|
uint8_t value_115 = 0;
|
|
{
|
|
String value_117 = value_106;
|
|
int64_t value_118 = value_114;
|
|
if (value_118 < 0LL || value_118 >= (int64_t)(value_117).length) {
|
|
value_115 = 0;
|
|
goto value_116;
|
|
}
|
|
value_115 = (uint8_t)value_117.data[value_118];
|
|
value_116: ;
|
|
}
|
|
uint8_t value_119 = value_115;
|
|
value_104 = value_119 == 0 || value_119 == 32 || value_119 == 9 || value_119 == 40 || value_119 == 34 || value_119 == 123;
|
|
value_105: ;
|
|
}
|
|
if (value_104 || StringEqual(source, StringLiteral("case;"))) {
|
|
return StatementKind_Case;
|
|
}
|
|
String value_120 = source;
|
|
String value_121 = StringLiteral("return");
|
|
bool value_122 = false;
|
|
{
|
|
String value_124 = value_120;
|
|
String value_125 = value_121;
|
|
bool value_126 = false;
|
|
{
|
|
String value_128 = value_124;
|
|
int64_t value_129 = 0LL;
|
|
String value_130 = value_125;
|
|
bool value_131 = value_129 >= 0LL && value_129 <= (int64_t)(value_128).length && (int64_t)(value_130).length <= (int64_t)((uint64_t)((int64_t)(value_128).length) - (uint64_t)value_129);
|
|
value_126 = value_131 && StringEqual(StringRangeAt(value_128, (int64_t)value_129, (int64_t)((int64_t)((uint64_t)value_129 + (uint64_t)((int64_t)(value_130).length)))), value_130);
|
|
}
|
|
if (!value_126) {
|
|
value_122 = false;
|
|
goto value_123;
|
|
}
|
|
int64_t value_132 = (int64_t)(value_125).length;
|
|
uint8_t value_133 = 0;
|
|
{
|
|
String value_135 = value_124;
|
|
int64_t value_136 = value_132;
|
|
if (value_136 < 0LL || value_136 >= (int64_t)(value_135).length) {
|
|
value_133 = 0;
|
|
goto value_134;
|
|
}
|
|
value_133 = (uint8_t)value_135.data[value_136];
|
|
value_134: ;
|
|
}
|
|
uint8_t value_137 = value_133;
|
|
value_122 = value_137 == 0 || value_137 == 32 || value_137 == 9 || value_137 == 40 || value_137 == 34 || value_137 == 123;
|
|
value_123: ;
|
|
}
|
|
if (value_122 || StringEqual(source, StringLiteral("return;"))) {
|
|
return StatementKind_Return;
|
|
}
|
|
if (StringEqual(source, StringLiteral("unreachable")) || StringEqual(source, StringLiteral("unreachable;"))) {
|
|
return StatementKind_Unreachable;
|
|
}
|
|
String value_138 = source;
|
|
String value_139 = StringLiteral("break");
|
|
bool value_140 = false;
|
|
{
|
|
String value_142 = value_138;
|
|
String value_143 = value_139;
|
|
bool value_144 = false;
|
|
{
|
|
String value_146 = value_142;
|
|
int64_t value_147 = 0LL;
|
|
String value_148 = value_143;
|
|
bool value_149 = value_147 >= 0LL && value_147 <= (int64_t)(value_146).length && (int64_t)(value_148).length <= (int64_t)((uint64_t)((int64_t)(value_146).length) - (uint64_t)value_147);
|
|
value_144 = value_149 && StringEqual(StringRangeAt(value_146, (int64_t)value_147, (int64_t)((int64_t)((uint64_t)value_147 + (uint64_t)((int64_t)(value_148).length)))), value_148);
|
|
}
|
|
if (!value_144) {
|
|
value_140 = false;
|
|
goto value_141;
|
|
}
|
|
int64_t value_150 = (int64_t)(value_143).length;
|
|
uint8_t value_151 = 0;
|
|
{
|
|
String value_153 = value_142;
|
|
int64_t value_154 = value_150;
|
|
if (value_154 < 0LL || value_154 >= (int64_t)(value_153).length) {
|
|
value_151 = 0;
|
|
goto value_152;
|
|
}
|
|
value_151 = (uint8_t)value_153.data[value_154];
|
|
value_152: ;
|
|
}
|
|
uint8_t value_155 = value_151;
|
|
value_140 = value_155 == 0 || value_155 == 32 || value_155 == 9 || value_155 == 40 || value_155 == 34 || value_155 == 123;
|
|
value_141: ;
|
|
}
|
|
if (value_140 || StringEqual(source, StringLiteral("break;"))) {
|
|
return StatementKind_Break;
|
|
}
|
|
String value_156 = source;
|
|
String value_157 = StringLiteral("continue");
|
|
bool value_158 = false;
|
|
{
|
|
String value_160 = value_156;
|
|
String value_161 = value_157;
|
|
bool value_162 = false;
|
|
{
|
|
String value_164 = value_160;
|
|
int64_t value_165 = 0LL;
|
|
String value_166 = value_161;
|
|
bool value_167 = value_165 >= 0LL && value_165 <= (int64_t)(value_164).length && (int64_t)(value_166).length <= (int64_t)((uint64_t)((int64_t)(value_164).length) - (uint64_t)value_165);
|
|
value_162 = value_167 && StringEqual(StringRangeAt(value_164, (int64_t)value_165, (int64_t)((int64_t)((uint64_t)value_165 + (uint64_t)((int64_t)(value_166).length)))), value_166);
|
|
}
|
|
if (!value_162) {
|
|
value_158 = false;
|
|
goto value_159;
|
|
}
|
|
int64_t value_168 = (int64_t)(value_161).length;
|
|
uint8_t value_169 = 0;
|
|
{
|
|
String value_171 = value_160;
|
|
int64_t value_172 = value_168;
|
|
if (value_172 < 0LL || value_172 >= (int64_t)(value_171).length) {
|
|
value_169 = 0;
|
|
goto value_170;
|
|
}
|
|
value_169 = (uint8_t)value_171.data[value_172];
|
|
value_170: ;
|
|
}
|
|
uint8_t value_173 = value_169;
|
|
value_158 = value_173 == 0 || value_173 == 32 || value_173 == 9 || value_173 == 40 || value_173 == 34 || value_173 == 123;
|
|
value_159: ;
|
|
}
|
|
if (value_158 || StringEqual(source, StringLiteral("continue;"))) {
|
|
return StatementKind_Continue;
|
|
}
|
|
String value_174 = source;
|
|
String value_175 = StringLiteral("defer");
|
|
bool value_176 = false;
|
|
{
|
|
String value_178 = value_174;
|
|
String value_179 = value_175;
|
|
bool value_180 = false;
|
|
{
|
|
String value_182 = value_178;
|
|
int64_t value_183 = 0LL;
|
|
String value_184 = value_179;
|
|
bool value_185 = value_183 >= 0LL && value_183 <= (int64_t)(value_182).length && (int64_t)(value_184).length <= (int64_t)((uint64_t)((int64_t)(value_182).length) - (uint64_t)value_183);
|
|
value_180 = value_185 && StringEqual(StringRangeAt(value_182, (int64_t)value_183, (int64_t)((int64_t)((uint64_t)value_183 + (uint64_t)((int64_t)(value_184).length)))), value_184);
|
|
}
|
|
if (!value_180) {
|
|
value_176 = false;
|
|
goto value_177;
|
|
}
|
|
int64_t value_186 = (int64_t)(value_179).length;
|
|
uint8_t value_187 = 0;
|
|
{
|
|
String value_189 = value_178;
|
|
int64_t value_190 = value_186;
|
|
if (value_190 < 0LL || value_190 >= (int64_t)(value_189).length) {
|
|
value_187 = 0;
|
|
goto value_188;
|
|
}
|
|
value_187 = (uint8_t)value_189.data[value_190];
|
|
value_188: ;
|
|
}
|
|
uint8_t value_191 = value_187;
|
|
value_176 = value_191 == 0 || value_191 == 32 || value_191 == 9 || value_191 == 40 || value_191 == 34 || value_191 == 123;
|
|
value_177: ;
|
|
}
|
|
if (value_176) {
|
|
return StatementKind_Defer;
|
|
}
|
|
String value_192 = source;
|
|
String value_193 = StringLiteral("unused");
|
|
bool value_194 = false;
|
|
{
|
|
String value_196 = value_192;
|
|
String value_197 = value_193;
|
|
bool value_198 = false;
|
|
{
|
|
String value_200 = value_196;
|
|
int64_t value_201 = 0LL;
|
|
String value_202 = value_197;
|
|
bool value_203 = value_201 >= 0LL && value_201 <= (int64_t)(value_200).length && (int64_t)(value_202).length <= (int64_t)((uint64_t)((int64_t)(value_200).length) - (uint64_t)value_201);
|
|
value_198 = value_203 && StringEqual(StringRangeAt(value_200, (int64_t)value_201, (int64_t)((int64_t)((uint64_t)value_201 + (uint64_t)((int64_t)(value_202).length)))), value_202);
|
|
}
|
|
if (!value_198) {
|
|
value_194 = false;
|
|
goto value_195;
|
|
}
|
|
int64_t value_204 = (int64_t)(value_197).length;
|
|
uint8_t value_205 = 0;
|
|
{
|
|
String value_207 = value_196;
|
|
int64_t value_208 = value_204;
|
|
if (value_208 < 0LL || value_208 >= (int64_t)(value_207).length) {
|
|
value_205 = 0;
|
|
goto value_206;
|
|
}
|
|
value_205 = (uint8_t)value_207.data[value_208];
|
|
value_206: ;
|
|
}
|
|
uint8_t value_209 = value_205;
|
|
value_194 = value_209 == 0 || value_209 == 32 || value_209 == 9 || value_209 == 40 || value_209 == 34 || value_209 == 123;
|
|
value_195: ;
|
|
}
|
|
if (value_194) {
|
|
return StatementKind_Unused;
|
|
}
|
|
int64_t constant = source_Find(source, StringLiteral("::"));
|
|
if (constant > 0LL) {
|
|
int64_t end = 0LL;
|
|
while (true) {
|
|
String value_210 = source;
|
|
uint8_t value_211 = 0;
|
|
{
|
|
String value_213 = value_210;
|
|
int64_t value_214 = end;
|
|
if (value_214 < 0LL || value_214 >= (int64_t)(value_213).length) {
|
|
value_211 = 0;
|
|
goto value_212;
|
|
}
|
|
value_211 = (uint8_t)value_213.data[value_214];
|
|
value_212: ;
|
|
}
|
|
bool value_215 = false;
|
|
{
|
|
uint8_t value_217 = value_211;
|
|
bool value_218 = false;
|
|
{
|
|
uint8_t value_220 = value_217;
|
|
value_218 = (value_220 >= 65 && value_220 <= 90) || (value_220 >= 97 && value_220 <= 122) || value_220 == 95;
|
|
}
|
|
value_215 = value_218 || (value_217 >= 48 && value_217 <= 57);
|
|
}
|
|
if (!value_215) { break; }
|
|
end = (int64_t)((uint64_t)end + UINT64_C(1));
|
|
}
|
|
int64_t value_221 = source_SkipSpace(source, end);
|
|
if (value_221 == constant && source_IdentifierText(StringRangeAt(source, (int64_t)0LL, (int64_t)end), false)) {
|
|
return StatementKind_Declaration;
|
|
}
|
|
}
|
|
int64_t colon = source_Find(source, StringLiteral(": "));
|
|
if (colon < 0LL) {
|
|
colon = source_Find(source, StringLiteral(": ["));
|
|
}
|
|
if (colon > 0LL && source_IdentifierText(StringRangeAt(source, (int64_t)0LL, (int64_t)colon), false)) {
|
|
return StatementKind_Declaration;
|
|
}
|
|
String rejected[11] = {StringLiteral("s8 "), StringLiteral("s16 "), StringLiteral("s32 "), StringLiteral("s64 "), StringLiteral("float32 "), StringLiteral("float64 "), StringLiteral("bool "), StringLiteral("unsigned "), StringLiteral("long "), StringLiteral("const "), StringLiteral("struct ")};
|
|
for (int64_t it_index = 0LL; it_index < 11; it_index++) {
|
|
String prefix = (rejected)[it_index];
|
|
String value_222 = source;
|
|
bool value_223 = false;
|
|
{
|
|
String value_225 = value_222;
|
|
int64_t value_226 = 0LL;
|
|
String value_227 = prefix;
|
|
bool value_228 = value_226 >= 0LL && value_226 <= (int64_t)(value_225).length && (int64_t)(value_227).length <= (int64_t)((uint64_t)((int64_t)(value_225).length) - (uint64_t)value_226);
|
|
value_223 = value_228 && StringEqual(StringRangeAt(value_225, (int64_t)value_226, (int64_t)((int64_t)((uint64_t)value_226 + (uint64_t)((int64_t)(value_227).length)))), value_227);
|
|
}
|
|
if (value_223) {
|
|
return StatementKind_Declaration;
|
|
}
|
|
}
|
|
int64_t at = 0LL;
|
|
int32_t depth = 0;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 40 || byte == 91 || byte == 123) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if (byte == 41 || byte == 93 || byte == 125) {
|
|
if (depth > 0) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
}
|
|
} else {
|
|
bool value_229 = depth == 0;
|
|
if (value_229) {
|
|
String value_230 = source;
|
|
int64_t value_231 = at;
|
|
String value_232 = StringLiteral(":=");
|
|
bool value_233 = false;
|
|
{
|
|
String value_235 = value_230;
|
|
int64_t value_236 = value_231;
|
|
String value_237 = value_232;
|
|
bool value_238 = value_236 >= 0LL && value_236 <= (int64_t)(value_235).length && (int64_t)(value_237).length <= (int64_t)((uint64_t)((int64_t)(value_235).length) - (uint64_t)value_236);
|
|
value_233 = value_238 && StringEqual(StringRangeAt(value_235, (int64_t)value_236, (int64_t)((int64_t)((uint64_t)value_236 + (uint64_t)((int64_t)(value_237).length)))), value_237);
|
|
}
|
|
value_229 = value_233;
|
|
}
|
|
if (value_229) {
|
|
return StatementKind_Declaration;
|
|
} else if (byte == 61 && depth == 0) {
|
|
return StatementKind_Assignment;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
int64_t value_239 = source_Find(source, StringLiteral("("));
|
|
bool value_240 = value_239 >= 0LL;
|
|
if (!value_240) {
|
|
int64_t value_241 = source_Find(source, StringLiteral("+"));
|
|
value_240 = (value_241 >= 0LL);
|
|
}
|
|
bool value_242 = value_240;
|
|
if (!value_242) {
|
|
int64_t value_243 = source_Find(source, StringLiteral("-"));
|
|
value_242 = (value_243 >= 0LL);
|
|
}
|
|
if (value_242) {
|
|
return StatementKind_Expression;
|
|
}
|
|
return StatementKind_Unknown;
|
|
}
|
|
|
|
void
|
|
source_NormalizeRecordSeparators(Slice body, bool split_commas)
|
|
{
|
|
int64_t at = 0LL;
|
|
bool quoted = false;
|
|
int32_t nesting = 0;
|
|
while (at < (int64_t)(body).length) {
|
|
uint8_t byte = ((uint8_t *)(body).data)[at];
|
|
if (quoted) {
|
|
if (byte == 92 && (int64_t)((uint64_t)at + UINT64_C(1)) < (int64_t)(body).length) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (byte == 34) {
|
|
quoted = false;
|
|
}
|
|
} else if (byte == 34) {
|
|
quoted = true;
|
|
} else if (byte == 91 || byte == 40) {
|
|
nesting = (int32_t)((uint32_t)nesting + 1u);
|
|
} else if (byte == 93 || byte == 41) {
|
|
nesting = (int32_t)((uint32_t)nesting - 1u);
|
|
} else if (nesting == 0 && (byte == 59 || (split_commas && byte == 44))) {
|
|
uint8_t* value_0 = &(((uint8_t *)(body).data)[at]);
|
|
(*value_0) = 10;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
|
|
bool
|
|
source_ContainsDirective(String source, String directive)
|
|
{
|
|
int64_t at = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34) {
|
|
at = source_AfterQuote(source, at);
|
|
} else {
|
|
bool value_0 = byte == 47;
|
|
if (value_0) {
|
|
String value_1 = source;
|
|
int64_t value_2 = at;
|
|
String value_3 = StringLiteral("//");
|
|
bool value_4 = false;
|
|
{
|
|
String value_6 = value_1;
|
|
int64_t value_7 = value_2;
|
|
String value_8 = value_3;
|
|
bool value_9 = value_7 >= 0LL && value_7 <= (int64_t)(value_6).length && (int64_t)(value_8).length <= (int64_t)((uint64_t)((int64_t)(value_6).length) - (uint64_t)value_7);
|
|
value_4 = value_9 && StringEqual(StringRangeAt(value_6, (int64_t)value_7, (int64_t)((int64_t)((uint64_t)value_7 + (uint64_t)((int64_t)(value_8).length)))), value_8);
|
|
}
|
|
value_0 = value_4;
|
|
}
|
|
if (value_0) {
|
|
return false;
|
|
} else {
|
|
bool value_10 = (int64_t)(directive).length == 0LL || byte == (uint8_t)directive.data[0];
|
|
bool value_11 = value_10;
|
|
if (value_11) {
|
|
String value_12 = source;
|
|
int64_t value_13 = at;
|
|
bool value_14 = false;
|
|
{
|
|
String value_16 = value_12;
|
|
int64_t value_17 = value_13;
|
|
String value_18 = directive;
|
|
bool value_19 = value_17 >= 0LL && value_17 <= (int64_t)(value_16).length && (int64_t)(value_18).length <= (int64_t)((uint64_t)((int64_t)(value_16).length) - (uint64_t)value_17);
|
|
value_14 = value_19 && StringEqual(StringRangeAt(value_16, (int64_t)value_17, (int64_t)((int64_t)((uint64_t)value_17 + (uint64_t)((int64_t)(value_18).length)))), value_18);
|
|
}
|
|
value_11 = value_14;
|
|
}
|
|
bool value_20 = value_11;
|
|
bool value_21 = value_20;
|
|
if (value_21) {
|
|
String value_22 = source;
|
|
int64_t value_23 = (int64_t)((uint64_t)at + (uint64_t)((int64_t)(directive).length));
|
|
uint8_t value_24 = 0;
|
|
{
|
|
String value_26 = value_22;
|
|
int64_t value_27 = value_23;
|
|
if (value_27 < 0LL || value_27 >= (int64_t)(value_26).length) {
|
|
value_24 = 0;
|
|
goto value_25;
|
|
}
|
|
value_24 = (uint8_t)value_26.data[value_27];
|
|
value_25: ;
|
|
}
|
|
bool value_28 = false;
|
|
{
|
|
uint8_t value_30 = value_24;
|
|
bool value_31 = false;
|
|
{
|
|
uint8_t value_33 = value_30;
|
|
value_31 = (value_33 >= 65 && value_33 <= 90) || (value_33 >= 97 && value_33 <= 122) || value_33 == 95;
|
|
}
|
|
value_28 = value_31 || (value_30 >= 48 && value_30 <= 57);
|
|
}
|
|
value_21 = !value_28;
|
|
}
|
|
if (value_21) {
|
|
return true;
|
|
} else {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
SourceRewrite
|
|
source_RewriteRawStrings(String source, Slice output, int64_t marker_limit)
|
|
{
|
|
SourceRewrite result = {0};
|
|
int64_t at = 0LL;
|
|
int64_t used = 0LL;
|
|
int64_t gaps = 0LL;
|
|
int32_t line = 1;
|
|
int32_t column = 1;
|
|
uint8_t quote = 0;
|
|
bool line_comment = false;
|
|
int32_t comment_depth = 0;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
bool value_0 = !line_comment && quote == 0;
|
|
if (value_0) {
|
|
String value_1 = source;
|
|
int64_t value_2 = at;
|
|
String value_3 = StringLiteral("/*");
|
|
bool value_4 = false;
|
|
{
|
|
String value_6 = value_1;
|
|
int64_t value_7 = value_2;
|
|
String value_8 = value_3;
|
|
bool value_9 = value_7 >= 0LL && value_7 <= (int64_t)(value_6).length && (int64_t)(value_8).length <= (int64_t)((uint64_t)((int64_t)(value_6).length) - (uint64_t)value_7);
|
|
value_4 = value_9 && StringEqual(StringRangeAt(value_6, (int64_t)value_7, (int64_t)((int64_t)((uint64_t)value_7 + (uint64_t)((int64_t)(value_8).length)))), value_8);
|
|
}
|
|
bool value_10 = value_4;
|
|
if (!value_10) {
|
|
bool value_11 = comment_depth > 0;
|
|
if (value_11) {
|
|
String value_12 = source;
|
|
int64_t value_13 = at;
|
|
String value_14 = StringLiteral("*/");
|
|
bool value_15 = false;
|
|
{
|
|
String value_17 = value_12;
|
|
int64_t value_18 = value_13;
|
|
String value_19 = value_14;
|
|
bool value_20 = value_18 >= 0LL && value_18 <= (int64_t)(value_17).length && (int64_t)(value_19).length <= (int64_t)((uint64_t)((int64_t)(value_17).length) - (uint64_t)value_18);
|
|
value_15 = value_20 && StringEqual(StringRangeAt(value_17, (int64_t)value_18, (int64_t)((int64_t)((uint64_t)value_18 + (uint64_t)((int64_t)(value_19).length)))), value_19);
|
|
}
|
|
value_11 = value_15;
|
|
}
|
|
value_10 = value_11;
|
|
}
|
|
value_0 = value_10;
|
|
}
|
|
if (value_0) {
|
|
if (byte == 47) {
|
|
comment_depth = (int32_t)((uint32_t)comment_depth + 1u);
|
|
} else {
|
|
comment_depth = (int32_t)((uint32_t)comment_depth - 1u);
|
|
}
|
|
source_Put(output, &(used), byte);
|
|
source_Put(output, &(used), (uint8_t)source.data[((int64_t)((uint64_t)at + UINT64_C(1)))]);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
column = (int32_t)((uint32_t)column + 2u);
|
|
continue;
|
|
}
|
|
if (!line_comment && comment_depth == 0 && quote == 0) {
|
|
String value_21 = source;
|
|
int64_t value_22 = at;
|
|
String value_23 = StringLiteral("//");
|
|
bool value_24 = false;
|
|
{
|
|
String value_26 = value_21;
|
|
int64_t value_27 = value_22;
|
|
String value_28 = value_23;
|
|
bool value_29 = value_27 >= 0LL && value_27 <= (int64_t)(value_26).length && (int64_t)(value_28).length <= (int64_t)((uint64_t)((int64_t)(value_26).length) - (uint64_t)value_27);
|
|
value_24 = value_29 && StringEqual(StringRangeAt(value_26, (int64_t)value_27, (int64_t)((int64_t)((uint64_t)value_27 + (uint64_t)((int64_t)(value_28).length)))), value_28);
|
|
}
|
|
if (value_24) {
|
|
line_comment = true;
|
|
} else if (byte == 34 || byte == 39) {
|
|
quote = byte;
|
|
} else {
|
|
String value_30 = source;
|
|
int64_t value_31 = at;
|
|
String value_32 = StringLiteral("#string");
|
|
bool value_33 = false;
|
|
{
|
|
String value_35 = value_30;
|
|
int64_t value_36 = value_31;
|
|
String value_37 = value_32;
|
|
bool value_38 = value_36 >= 0LL && value_36 <= (int64_t)(value_35).length && (int64_t)(value_37).length <= (int64_t)((uint64_t)((int64_t)(value_35).length) - (uint64_t)value_36);
|
|
value_33 = value_38 && StringEqual(StringRangeAt(value_35, (int64_t)value_36, (int64_t)((int64_t)((uint64_t)value_36 + (uint64_t)((int64_t)(value_37).length)))), value_37);
|
|
}
|
|
bool value_39 = value_33;
|
|
if (value_39) {
|
|
bool value_40 = at == 0LL;
|
|
if (!value_40) {
|
|
uint8_t value_41 = (uint8_t)source.data[((int64_t)((uint64_t)at - UINT64_C(1)))];
|
|
bool value_42 = false;
|
|
{
|
|
uint8_t value_44 = value_41;
|
|
bool value_45 = false;
|
|
{
|
|
uint8_t value_47 = value_44;
|
|
value_45 = (value_47 >= 65 && value_47 <= 90) || (value_47 >= 97 && value_47 <= 122) || value_47 == 95;
|
|
}
|
|
value_42 = value_45 || (value_44 >= 48 && value_44 <= 57);
|
|
}
|
|
value_40 = !value_42;
|
|
}
|
|
value_39 = value_40;
|
|
}
|
|
bool value_48 = value_39;
|
|
if (value_48) {
|
|
bool value_49 = (int64_t)((uint64_t)at + UINT64_C(7)) == (int64_t)(source).length;
|
|
if (!value_49) {
|
|
uint8_t value_50 = (uint8_t)source.data[((int64_t)((uint64_t)at + UINT64_C(7)))];
|
|
bool value_51 = false;
|
|
{
|
|
uint8_t value_53 = value_50;
|
|
value_51 = value_53 == 32 || (value_53 >= 9 && value_53 <= 13);
|
|
}
|
|
value_49 = value_51;
|
|
}
|
|
value_48 = value_49;
|
|
}
|
|
if (value_48) {
|
|
int32_t* value_54 = &(result.line);
|
|
(*value_54) = line;
|
|
int32_t* value_55 = &(result.column);
|
|
(*value_55) = column;
|
|
int64_t cursor = (int64_t)((uint64_t)at + UINT64_C(7));
|
|
while (true) {
|
|
String value_56 = source;
|
|
uint8_t value_57 = 0;
|
|
{
|
|
String value_59 = value_56;
|
|
int64_t value_60 = cursor;
|
|
if (value_60 < 0LL || value_60 >= (int64_t)(value_59).length) {
|
|
value_57 = 0;
|
|
goto value_58;
|
|
}
|
|
value_57 = (uint8_t)value_59.data[value_60];
|
|
value_58: ;
|
|
}
|
|
bool value_61 = value_57 == 32;
|
|
if (!value_61) {
|
|
String value_62 = source;
|
|
uint8_t value_63 = 0;
|
|
{
|
|
String value_65 = value_62;
|
|
int64_t value_66 = cursor;
|
|
if (value_66 < 0LL || value_66 >= (int64_t)(value_65).length) {
|
|
value_63 = 0;
|
|
goto value_64;
|
|
}
|
|
value_63 = (uint8_t)value_65.data[value_66];
|
|
value_64: ;
|
|
}
|
|
value_61 = (value_63 == 9);
|
|
}
|
|
if (!value_61) { break; }
|
|
cursor = (int64_t)((uint64_t)cursor + UINT64_C(1));
|
|
}
|
|
int64_t begin = cursor;
|
|
while (true) {
|
|
String value_67 = source;
|
|
uint8_t value_68 = 0;
|
|
{
|
|
String value_70 = value_67;
|
|
int64_t value_71 = cursor;
|
|
if (value_71 < 0LL || value_71 >= (int64_t)(value_70).length) {
|
|
value_68 = 0;
|
|
goto value_69;
|
|
}
|
|
value_68 = (uint8_t)value_70.data[value_71];
|
|
value_69: ;
|
|
}
|
|
bool value_72 = false;
|
|
{
|
|
uint8_t value_74 = value_68;
|
|
bool value_75 = false;
|
|
{
|
|
uint8_t value_77 = value_74;
|
|
value_75 = (value_77 >= 65 && value_77 <= 90) || (value_77 >= 97 && value_77 <= 122) || value_77 == 95;
|
|
}
|
|
value_72 = value_75 || (value_74 >= 48 && value_74 <= 57);
|
|
}
|
|
if (!value_72) { break; }
|
|
cursor = (int64_t)((uint64_t)cursor + UINT64_C(1));
|
|
}
|
|
int64_t end = cursor;
|
|
int64_t* value_78 = &(result.marker_begin);
|
|
(*value_78) = begin;
|
|
int64_t* value_79 = &(result.marker_end);
|
|
(*value_79) = end;
|
|
bool value_80 = end == begin || (int64_t)((uint64_t)end - (uint64_t)begin) >= marker_limit;
|
|
if (!value_80) {
|
|
String value_81 = source;
|
|
uint8_t value_82 = 0;
|
|
{
|
|
String value_84 = value_81;
|
|
int64_t value_85 = begin;
|
|
if (value_85 < 0LL || value_85 >= (int64_t)(value_84).length) {
|
|
value_82 = 0;
|
|
goto value_83;
|
|
}
|
|
value_82 = (uint8_t)value_84.data[value_85];
|
|
value_83: ;
|
|
}
|
|
bool value_86 = false;
|
|
{
|
|
uint8_t value_88 = value_82;
|
|
value_86 = (value_88 >= 65 && value_88 <= 90) || (value_88 >= 97 && value_88 <= 122) || value_88 == 95;
|
|
}
|
|
value_80 = !value_86;
|
|
}
|
|
if (value_80) {
|
|
SourceError* value_89 = &(result.error);
|
|
(*value_89) = SourceError_Delimiter;
|
|
return result;
|
|
}
|
|
while (true) {
|
|
String value_90 = source;
|
|
uint8_t value_91 = 0;
|
|
{
|
|
String value_93 = value_90;
|
|
int64_t value_94 = cursor;
|
|
if (value_94 < 0LL || value_94 >= (int64_t)(value_93).length) {
|
|
value_91 = 0;
|
|
goto value_92;
|
|
}
|
|
value_91 = (uint8_t)value_93.data[value_94];
|
|
value_92: ;
|
|
}
|
|
bool value_95 = value_91 == 32;
|
|
if (!value_95) {
|
|
String value_96 = source;
|
|
uint8_t value_97 = 0;
|
|
{
|
|
String value_99 = value_96;
|
|
int64_t value_100 = cursor;
|
|
if (value_100 < 0LL || value_100 >= (int64_t)(value_99).length) {
|
|
value_97 = 0;
|
|
goto value_98;
|
|
}
|
|
value_97 = (uint8_t)value_99.data[value_100];
|
|
value_98: ;
|
|
}
|
|
value_95 = (value_97 == 9);
|
|
}
|
|
if (!value_95) { break; }
|
|
cursor = (int64_t)((uint64_t)cursor + UINT64_C(1));
|
|
}
|
|
String value_101 = source;
|
|
uint8_t value_102 = 0;
|
|
{
|
|
String value_104 = value_101;
|
|
int64_t value_105 = cursor;
|
|
if (value_105 < 0LL || value_105 >= (int64_t)(value_104).length) {
|
|
value_102 = 0;
|
|
goto value_103;
|
|
}
|
|
value_102 = (uint8_t)value_104.data[value_105];
|
|
value_103: ;
|
|
}
|
|
if (value_102 == 13) {
|
|
cursor = (int64_t)((uint64_t)cursor + UINT64_C(1));
|
|
}
|
|
if (cursor >= (int64_t)(source).length || (uint8_t)source.data[cursor] != 10) {
|
|
SourceError* value_106 = &(result.error);
|
|
(*value_106) = SourceError_DelimiterLine;
|
|
return result;
|
|
}
|
|
int64_t body = (int64_t)((uint64_t)cursor + UINT64_C(1));
|
|
int64_t close = body;
|
|
String marker = StringRangeAt(source, (int64_t)begin, (int64_t)end);
|
|
while (close < (int64_t)(source).length) {
|
|
String value_107 = source;
|
|
bool value_108 = false;
|
|
{
|
|
String value_110 = value_107;
|
|
int64_t value_111 = close;
|
|
String value_112 = marker;
|
|
bool value_113 = value_111 >= 0LL && value_111 <= (int64_t)(value_110).length && (int64_t)(value_112).length <= (int64_t)((uint64_t)((int64_t)(value_110).length) - (uint64_t)value_111);
|
|
value_108 = value_113 && StringEqual(StringRangeAt(value_110, (int64_t)value_111, (int64_t)((int64_t)((uint64_t)value_111 + (uint64_t)((int64_t)(value_112).length)))), value_112);
|
|
}
|
|
bool value_114 = value_108;
|
|
if (value_114) {
|
|
String value_115 = source;
|
|
int64_t value_116 = (int64_t)((uint64_t)close + (uint64_t)((int64_t)(marker).length));
|
|
uint8_t value_117 = 0;
|
|
{
|
|
String value_119 = value_115;
|
|
int64_t value_120 = value_116;
|
|
if (value_120 < 0LL || value_120 >= (int64_t)(value_119).length) {
|
|
value_117 = 0;
|
|
goto value_118;
|
|
}
|
|
value_117 = (uint8_t)value_119.data[value_120];
|
|
value_118: ;
|
|
}
|
|
bool value_121 = false;
|
|
{
|
|
uint8_t value_123 = value_117;
|
|
bool value_124 = false;
|
|
{
|
|
uint8_t value_126 = value_123;
|
|
value_124 = (value_126 >= 65 && value_126 <= 90) || (value_126 >= 97 && value_126 <= 122) || value_126 == 95;
|
|
}
|
|
value_121 = value_124 || (value_123 >= 48 && value_123 <= 57);
|
|
}
|
|
value_114 = !value_121;
|
|
}
|
|
if (value_114) {
|
|
break;
|
|
}
|
|
while (close < (int64_t)(source).length && (uint8_t)source.data[close] != 10) {
|
|
close = (int64_t)((uint64_t)close + UINT64_C(1));
|
|
}
|
|
if (close < (int64_t)(source).length) {
|
|
close = (int64_t)((uint64_t)close + UINT64_C(1));
|
|
}
|
|
}
|
|
if (close >= (int64_t)(source).length) {
|
|
SourceError* value_127 = &(result.error);
|
|
(*value_127) = SourceError_Unterminated;
|
|
return result;
|
|
}
|
|
source_Put(output, &(used), 34);
|
|
cursor = body;
|
|
while (cursor < close) {
|
|
source_PutRaw(output, &(used), (uint8_t)source.data[cursor]);
|
|
cursor = (int64_t)((uint64_t)cursor + UINT64_C(1));
|
|
}
|
|
source_Put(output, &(used), 34);
|
|
while (at < close) {
|
|
if ((uint8_t)source.data[at] == 10) {
|
|
line = (int32_t)((uint32_t)line + 1u);
|
|
gaps = (int64_t)((uint64_t)gaps + UINT64_C(1));
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
column = (int32_t)((uint32_t)((int64_t)(marker).length) + 1u);
|
|
at = (int64_t)((uint64_t)at + (uint64_t)((int64_t)(marker).length));
|
|
continue;
|
|
}
|
|
}
|
|
source_PutScanned(output, &(used), byte, &(gaps));
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (quote != 0) {
|
|
source_PutScanned(output, &(used), byte, &(gaps));
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
if (byte == 92 && at < (int64_t)(source).length) {
|
|
column = (int32_t)((uint32_t)column + 1u);
|
|
byte = (uint8_t)source.data[at];
|
|
source_PutScanned(output, &(used), byte, &(gaps));
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (byte == quote) {
|
|
quote = 0;
|
|
}
|
|
} else {
|
|
source_PutScanned(output, &(used), byte, &(gaps));
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (byte == 10) {
|
|
line = (int32_t)((uint32_t)line + 1u);
|
|
column = 1;
|
|
line_comment = false;
|
|
} else {
|
|
column = (int32_t)((uint32_t)column + 1u);
|
|
}
|
|
}
|
|
int64_t* value_128 = &(result.count);
|
|
(*value_128) = used;
|
|
return result;
|
|
}
|
|
|
|
CommentScan
|
|
source_StripComments(String source, Slice output, int32_t depth)
|
|
{
|
|
int64_t at = 0LL;
|
|
int64_t used = 0LL;
|
|
uint8_t quote = 0;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (depth > 0) {
|
|
String value_0 = source;
|
|
int64_t value_1 = at;
|
|
String value_2 = StringLiteral("/*");
|
|
bool value_3 = false;
|
|
{
|
|
String value_5 = value_0;
|
|
int64_t value_6 = value_1;
|
|
String value_7 = value_2;
|
|
bool value_8 = value_6 >= 0LL && value_6 <= (int64_t)(value_5).length && (int64_t)(value_7).length <= (int64_t)((uint64_t)((int64_t)(value_5).length) - (uint64_t)value_6);
|
|
value_3 = value_8 && StringEqual(StringRangeAt(value_5, (int64_t)value_6, (int64_t)((int64_t)((uint64_t)value_6 + (uint64_t)((int64_t)(value_7).length)))), value_7);
|
|
}
|
|
if (value_3) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
} else {
|
|
String value_9 = source;
|
|
int64_t value_10 = at;
|
|
String value_11 = StringLiteral("*/");
|
|
bool value_12 = false;
|
|
{
|
|
String value_14 = value_9;
|
|
int64_t value_15 = value_10;
|
|
String value_16 = value_11;
|
|
bool value_17 = value_15 >= 0LL && value_15 <= (int64_t)(value_14).length && (int64_t)(value_16).length <= (int64_t)((uint64_t)((int64_t)(value_14).length) - (uint64_t)value_15);
|
|
value_12 = value_17 && StringEqual(StringRangeAt(value_14, (int64_t)value_15, (int64_t)((int64_t)((uint64_t)value_15 + (uint64_t)((int64_t)(value_16).length)))), value_16);
|
|
}
|
|
if (value_12) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
if (depth == 0) {
|
|
source_Put(output, &(used), 32);
|
|
}
|
|
} else {
|
|
if (byte == 10) {
|
|
source_Put(output, &(used), byte);
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
} else if (quote != 0) {
|
|
source_Put(output, &(used), byte);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
if (byte == 92 && at < (int64_t)(source).length) {
|
|
source_Put(output, &(used), (uint8_t)source.data[at]);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (byte == quote || byte == 10) {
|
|
quote = 0;
|
|
}
|
|
} else if (byte == 34 || byte == 39) {
|
|
quote = byte;
|
|
source_Put(output, &(used), byte);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else {
|
|
String value_18 = source;
|
|
int64_t value_19 = at;
|
|
String value_20 = StringLiteral("//");
|
|
bool value_21 = false;
|
|
{
|
|
String value_23 = value_18;
|
|
int64_t value_24 = value_19;
|
|
String value_25 = value_20;
|
|
bool value_26 = value_24 >= 0LL && value_24 <= (int64_t)(value_23).length && (int64_t)(value_25).length <= (int64_t)((uint64_t)((int64_t)(value_23).length) - (uint64_t)value_24);
|
|
value_21 = value_26 && StringEqual(StringRangeAt(value_23, (int64_t)value_24, (int64_t)((int64_t)((uint64_t)value_24 + (uint64_t)((int64_t)(value_25).length)))), value_25);
|
|
}
|
|
if (value_21) {
|
|
while (at < (int64_t)(source).length && (uint8_t)source.data[at] != 10) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
} else {
|
|
String value_27 = source;
|
|
int64_t value_28 = at;
|
|
String value_29 = StringLiteral("/*");
|
|
bool value_30 = false;
|
|
{
|
|
String value_32 = value_27;
|
|
int64_t value_33 = value_28;
|
|
String value_34 = value_29;
|
|
bool value_35 = value_33 >= 0LL && value_33 <= (int64_t)(value_32).length && (int64_t)(value_34).length <= (int64_t)((uint64_t)((int64_t)(value_32).length) - (uint64_t)value_33);
|
|
value_30 = value_35 && StringEqual(StringRangeAt(value_32, (int64_t)value_33, (int64_t)((int64_t)((uint64_t)value_33 + (uint64_t)((int64_t)(value_34).length)))), value_34);
|
|
}
|
|
if (value_30) {
|
|
depth = 1;
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
} else {
|
|
source_Put(output, &(used), byte);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return (CommentScan){.count = used, .depth = depth};
|
|
}
|
|
|
|
int32_t
|
|
source_NetBlockBraces(String source)
|
|
{
|
|
int64_t at = 0LL;
|
|
int32_t parentheses = 0;
|
|
int32_t result = 0;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 40 || byte == 91) {
|
|
parentheses = (int32_t)((uint32_t)parentheses + 1u);
|
|
} else if (byte == 41 || byte == 93) {
|
|
if (parentheses > 0) {
|
|
parentheses = (int32_t)((uint32_t)parentheses - 1u);
|
|
}
|
|
} else if (parentheses == 0) {
|
|
if (byte == 123) {
|
|
result = (int32_t)((uint32_t)result + 1u);
|
|
} else if (byte == 125) {
|
|
result = (int32_t)((uint32_t)result - 1u);
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
int64_t
|
|
source_StatementSeparator(String source)
|
|
{
|
|
String value_0 = source;
|
|
uint8_t value_1 = 0;
|
|
{
|
|
String value_3 = value_0;
|
|
int64_t value_4 = 0LL;
|
|
if (value_4 < 0LL || value_4 >= (int64_t)(value_3).length) {
|
|
value_1 = 0;
|
|
goto value_2;
|
|
}
|
|
value_1 = (uint8_t)value_3.data[value_4];
|
|
value_2: ;
|
|
}
|
|
bool value_5 = value_1 == 125;
|
|
if (value_5) {
|
|
String value_6 = source;
|
|
int64_t value_7 = source_SkipSpace(source, 1LL);
|
|
uint8_t value_8 = 0;
|
|
{
|
|
String value_10 = value_6;
|
|
int64_t value_11 = value_7;
|
|
if (value_11 < 0LL || value_11 >= (int64_t)(value_10).length) {
|
|
value_8 = 0;
|
|
goto value_9;
|
|
}
|
|
value_8 = (uint8_t)value_10.data[value_11];
|
|
value_9: ;
|
|
}
|
|
value_5 = (value_8 == 125);
|
|
}
|
|
if (value_5) {
|
|
return 0LL;
|
|
}
|
|
int64_t at = 0LL;
|
|
int32_t parentheses = 0;
|
|
int32_t brackets = 0;
|
|
int32_t braces = 0;
|
|
int64_t first_brace = source_Find(source, StringLiteral("{"));
|
|
int64_t conditional = source_Find(source, StringLiteral("#ifx"));
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 40) {
|
|
parentheses = (int32_t)((uint32_t)parentheses + 1u);
|
|
} else if (byte == 41) {
|
|
parentheses = (int32_t)((uint32_t)parentheses - 1u);
|
|
} else if (byte == 91) {
|
|
brackets = (int32_t)((uint32_t)brackets + 1u);
|
|
} else if (byte == 93) {
|
|
brackets = (int32_t)((uint32_t)brackets - 1u);
|
|
} else if (byte == 123) {
|
|
braces = (int32_t)((uint32_t)braces + 1u);
|
|
} else if (byte == 125 && braces > 0) {
|
|
braces = (int32_t)((uint32_t)braces - 1u);
|
|
} else if (byte == 59 && parentheses == 0 && brackets == 0 && braces == 0) {
|
|
int64_t after = source_SkipSpace(source, (int64_t)((uint64_t)at + UINT64_C(1)));
|
|
bool value_12 = after < (int64_t)(source).length;
|
|
if (value_12) {
|
|
String value_13 = source;
|
|
String value_14 = StringLiteral("for");
|
|
bool value_15 = false;
|
|
{
|
|
String value_17 = value_13;
|
|
String value_18 = value_14;
|
|
bool value_19 = false;
|
|
{
|
|
String value_21 = value_17;
|
|
int64_t value_22 = 0LL;
|
|
String value_23 = value_18;
|
|
bool value_24 = value_22 >= 0LL && value_22 <= (int64_t)(value_21).length && (int64_t)(value_23).length <= (int64_t)((uint64_t)((int64_t)(value_21).length) - (uint64_t)value_22);
|
|
value_19 = value_24 && StringEqual(StringRangeAt(value_21, (int64_t)value_22, (int64_t)((int64_t)((uint64_t)value_22 + (uint64_t)((int64_t)(value_23).length)))), value_23);
|
|
}
|
|
if (!value_19) {
|
|
value_15 = false;
|
|
goto value_16;
|
|
}
|
|
int64_t value_25 = (int64_t)(value_18).length;
|
|
uint8_t value_26 = 0;
|
|
{
|
|
String value_28 = value_17;
|
|
int64_t value_29 = value_25;
|
|
if (value_29 < 0LL || value_29 >= (int64_t)(value_28).length) {
|
|
value_26 = 0;
|
|
goto value_27;
|
|
}
|
|
value_26 = (uint8_t)value_28.data[value_29];
|
|
value_27: ;
|
|
}
|
|
uint8_t value_30 = value_26;
|
|
value_15 = value_30 == 0 || value_30 == 32 || value_30 == 9 || value_30 == 40 || value_30 == 34 || value_30 == 123;
|
|
value_16: ;
|
|
}
|
|
value_12 = !(value_15 && (first_brace < 0LL || at < first_brace));
|
|
}
|
|
bool value_31 = value_12;
|
|
if (value_31) {
|
|
bool value_32 = conditional >= 0LL && conditional < at;
|
|
if (value_32) {
|
|
String value_33 = StringRangeAt(source, (int64_t)after, (int64_t)source.length);
|
|
String value_34 = StringLiteral("else");
|
|
bool value_35 = false;
|
|
{
|
|
String value_37 = value_33;
|
|
String value_38 = value_34;
|
|
bool value_39 = false;
|
|
{
|
|
String value_41 = value_37;
|
|
int64_t value_42 = 0LL;
|
|
String value_43 = value_38;
|
|
bool value_44 = value_42 >= 0LL && value_42 <= (int64_t)(value_41).length && (int64_t)(value_43).length <= (int64_t)((uint64_t)((int64_t)(value_41).length) - (uint64_t)value_42);
|
|
value_39 = value_44 && StringEqual(StringRangeAt(value_41, (int64_t)value_42, (int64_t)((int64_t)((uint64_t)value_42 + (uint64_t)((int64_t)(value_43).length)))), value_43);
|
|
}
|
|
if (!value_39) {
|
|
value_35 = false;
|
|
goto value_36;
|
|
}
|
|
int64_t value_45 = (int64_t)(value_38).length;
|
|
uint8_t value_46 = 0;
|
|
{
|
|
String value_48 = value_37;
|
|
int64_t value_49 = value_45;
|
|
if (value_49 < 0LL || value_49 >= (int64_t)(value_48).length) {
|
|
value_46 = 0;
|
|
goto value_47;
|
|
}
|
|
value_46 = (uint8_t)value_48.data[value_49];
|
|
value_47: ;
|
|
}
|
|
uint8_t value_50 = value_46;
|
|
value_35 = value_50 == 0 || value_50 == 32 || value_50 == 9 || value_50 == 40 || value_50 == 34 || value_50 == 123;
|
|
value_36: ;
|
|
}
|
|
value_32 = value_35;
|
|
}
|
|
value_31 = !value_32;
|
|
}
|
|
if (value_31) {
|
|
return at;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
ControlBlock
|
|
source_SplitControlBlock(String source)
|
|
{
|
|
ControlBlock result = {0};
|
|
if ((int64_t)(source).length < 4LL) {
|
|
return result;
|
|
}
|
|
int64_t control = 0LL;
|
|
if ((uint8_t)source.data[0] == 125) {
|
|
int64_t after = source_SkipSpace(source, 1LL);
|
|
String value_0 = StringRangeAt(source, (int64_t)after, (int64_t)source.length);
|
|
String value_1 = StringLiteral("else");
|
|
bool value_2 = false;
|
|
{
|
|
String value_4 = value_0;
|
|
String value_5 = value_1;
|
|
bool value_6 = false;
|
|
{
|
|
String value_8 = value_4;
|
|
int64_t value_9 = 0LL;
|
|
String value_10 = value_5;
|
|
bool value_11 = value_9 >= 0LL && value_9 <= (int64_t)(value_8).length && (int64_t)(value_10).length <= (int64_t)((uint64_t)((int64_t)(value_8).length) - (uint64_t)value_9);
|
|
value_6 = value_11 && StringEqual(StringRangeAt(value_8, (int64_t)value_9, (int64_t)((int64_t)((uint64_t)value_9 + (uint64_t)((int64_t)(value_10).length)))), value_10);
|
|
}
|
|
if (!value_6) {
|
|
value_2 = false;
|
|
goto value_3;
|
|
}
|
|
int64_t value_12 = (int64_t)(value_5).length;
|
|
uint8_t value_13 = 0;
|
|
{
|
|
String value_15 = value_4;
|
|
int64_t value_16 = value_12;
|
|
if (value_16 < 0LL || value_16 >= (int64_t)(value_15).length) {
|
|
value_13 = 0;
|
|
goto value_14;
|
|
}
|
|
value_13 = (uint8_t)value_15.data[value_16];
|
|
value_14: ;
|
|
}
|
|
uint8_t value_17 = value_13;
|
|
value_2 = value_17 == 0 || value_17 == 32 || value_17 == 9 || value_17 == 40 || value_17 == 34 || value_17 == 123;
|
|
value_3: ;
|
|
}
|
|
if (value_2) {
|
|
control = after;
|
|
}
|
|
}
|
|
int64_t end = control;
|
|
while (true) {
|
|
bool value_18 = end < (int64_t)(source).length;
|
|
if (value_18) {
|
|
uint8_t value_19 = (uint8_t)source.data[end];
|
|
bool value_20 = false;
|
|
{
|
|
uint8_t value_22 = value_19;
|
|
bool value_23 = false;
|
|
{
|
|
uint8_t value_25 = value_22;
|
|
value_23 = (value_25 >= 65 && value_25 <= 90) || (value_25 >= 97 && value_25 <= 122) || value_25 == 95;
|
|
}
|
|
value_20 = value_23 || (value_22 >= 48 && value_22 <= 57);
|
|
}
|
|
value_18 = value_20;
|
|
}
|
|
if (!(value_18 && (int64_t)((uint64_t)end - (uint64_t)control) < 15LL)) { break; }
|
|
end = (int64_t)((uint64_t)end + UINT64_C(1));
|
|
}
|
|
String word = StringRangeAt(source, (int64_t)control, (int64_t)end);
|
|
bool value_26 = !StringEqual(word, StringLiteral("if")) && !StringEqual(word, StringLiteral("else")) && !StringEqual(word, StringLiteral("while"));
|
|
bool value_27 = value_26 && !StringEqual(word, StringLiteral("for")) && !StringEqual(word, StringLiteral("defer"));
|
|
bool value_28 = value_27 && !StringEqual(word, StringLiteral("switch")) && !StringEqual(word, StringLiteral("case"));
|
|
bool value_29 = value_28 && !StringEqual(word, StringLiteral("guard")) && !StringEqual(word, StringLiteral("do"));
|
|
bool value_30 = value_29;
|
|
if (value_30) {
|
|
bool value_31 = (uint8_t)source.data[0] == 35;
|
|
bool value_32 = value_31;
|
|
if (value_32) {
|
|
String value_33 = source;
|
|
String value_34 = StringLiteral("#asm");
|
|
bool value_35 = false;
|
|
{
|
|
String value_37 = value_33;
|
|
String value_38 = value_34;
|
|
bool value_39 = false;
|
|
{
|
|
String value_41 = value_37;
|
|
int64_t value_42 = 0LL;
|
|
String value_43 = value_38;
|
|
bool value_44 = value_42 >= 0LL && value_42 <= (int64_t)(value_41).length && (int64_t)(value_43).length <= (int64_t)((uint64_t)((int64_t)(value_41).length) - (uint64_t)value_42);
|
|
value_39 = value_44 && StringEqual(StringRangeAt(value_41, (int64_t)value_42, (int64_t)((int64_t)((uint64_t)value_42 + (uint64_t)((int64_t)(value_43).length)))), value_43);
|
|
}
|
|
if (!value_39) {
|
|
value_35 = false;
|
|
goto value_36;
|
|
}
|
|
int64_t value_45 = (int64_t)(value_38).length;
|
|
uint8_t value_46 = 0;
|
|
{
|
|
String value_48 = value_37;
|
|
int64_t value_49 = value_45;
|
|
if (value_49 < 0LL || value_49 >= (int64_t)(value_48).length) {
|
|
value_46 = 0;
|
|
goto value_47;
|
|
}
|
|
value_46 = (uint8_t)value_48.data[value_49];
|
|
value_47: ;
|
|
}
|
|
uint8_t value_50 = value_46;
|
|
value_35 = value_50 == 0 || value_50 == 32 || value_50 == 9 || value_50 == 40 || value_50 == 34 || value_50 == 123;
|
|
value_36: ;
|
|
}
|
|
value_32 = value_35;
|
|
}
|
|
value_30 = !value_32;
|
|
}
|
|
if (value_30) {
|
|
return result;
|
|
}
|
|
int64_t at = 0LL;
|
|
int32_t parentheses = 0;
|
|
int32_t expressions = 0;
|
|
int64_t opening = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 40 || byte == 91) {
|
|
parentheses = (int32_t)((uint32_t)parentheses + 1u);
|
|
} else if (byte == 41 || byte == 93) {
|
|
parentheses = (int32_t)((uint32_t)parentheses - 1u);
|
|
} else if (byte == 123 && parentheses == 0) {
|
|
int64_t before = at;
|
|
while (true) {
|
|
bool value_51 = before > 0LL;
|
|
if (value_51) {
|
|
uint8_t value_52 = (uint8_t)source.data[((int64_t)((uint64_t)before - UINT64_C(1)))];
|
|
bool value_53 = false;
|
|
{
|
|
uint8_t value_55 = value_52;
|
|
value_53 = value_55 == 32 || (value_55 >= 9 && value_55 <= 13);
|
|
}
|
|
value_51 = value_53;
|
|
}
|
|
if (!value_51) { break; }
|
|
before = (int64_t)((uint64_t)before - UINT64_C(1));
|
|
}
|
|
if (expressions > 0 || (before > 0LL && (uint8_t)source.data[((int64_t)((uint64_t)before - UINT64_C(1)))] == 46 && (before < 2LL || (uint8_t)source.data[((int64_t)((uint64_t)before - UINT64_C(2)))] != 46))) {
|
|
expressions = (int32_t)((uint32_t)expressions + 1u);
|
|
} else {
|
|
opening = at;
|
|
break;
|
|
}
|
|
} else if (byte == 125 && parentheses == 0 && expressions > 0) {
|
|
expressions = (int32_t)((uint32_t)expressions - 1u);
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (opening == 0LL || expressions != 0) {
|
|
return result;
|
|
}
|
|
int32_t depth = 1;
|
|
at = (int64_t)((uint64_t)opening + UINT64_C(1));
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_ClosedQuote(source, at);
|
|
if (at < 0LL) {
|
|
return result;
|
|
}
|
|
continue;
|
|
}
|
|
if (byte == 123) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if (byte == 125) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
if (depth == 0) {
|
|
break;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (at >= (int64_t)(source).length) {
|
|
int64_t value_56 = source_SkipSpace(source, (int64_t)((uint64_t)opening + UINT64_C(1)));
|
|
int64_t value_57 = (int64_t)(source).length;
|
|
if (value_56 >= value_57) {
|
|
return result;
|
|
}
|
|
return (ControlBlock){.valid = true, .head_end = (int64_t)((uint64_t)opening + UINT64_C(1)), .body_begin = (int64_t)((uint64_t)opening + UINT64_C(1)), .body_end = (int64_t)(source).length, .tail_begin = (int64_t)(source).length, .open = true};
|
|
}
|
|
int64_t tail = source_SkipSpace(source, (int64_t)((uint64_t)at + UINT64_C(1)));
|
|
String value_58 = source;
|
|
uint8_t value_59 = 0;
|
|
{
|
|
String value_61 = value_58;
|
|
int64_t value_62 = tail;
|
|
if (value_62 < 0LL || value_62 >= (int64_t)(value_61).length) {
|
|
value_59 = 0;
|
|
goto value_60;
|
|
}
|
|
value_59 = (uint8_t)value_61.data[value_62];
|
|
value_60: ;
|
|
}
|
|
if (value_59 == 59) {
|
|
tail = source_SkipSpace(source, (int64_t)((uint64_t)tail + UINT64_C(1)));
|
|
}
|
|
bool value_63 = tail < (int64_t)(source).length;
|
|
if (value_63) {
|
|
bool value_64 = StringEqual(word, StringLiteral("do")) || StringEqual(word, StringLiteral("case")) || StringEqual(word, StringLiteral("guard"));
|
|
bool value_65 = value_64;
|
|
if (!value_65) {
|
|
String value_66 = StringRangeAt(source, (int64_t)tail, (int64_t)source.length);
|
|
String value_67 = StringLiteral("else");
|
|
bool value_68 = false;
|
|
{
|
|
String value_70 = value_66;
|
|
String value_71 = value_67;
|
|
bool value_72 = false;
|
|
{
|
|
String value_74 = value_70;
|
|
int64_t value_75 = 0LL;
|
|
String value_76 = value_71;
|
|
bool value_77 = value_75 >= 0LL && value_75 <= (int64_t)(value_74).length && (int64_t)(value_76).length <= (int64_t)((uint64_t)((int64_t)(value_74).length) - (uint64_t)value_75);
|
|
value_72 = value_77 && StringEqual(StringRangeAt(value_74, (int64_t)value_75, (int64_t)((int64_t)((uint64_t)value_75 + (uint64_t)((int64_t)(value_76).length)))), value_76);
|
|
}
|
|
if (!value_72) {
|
|
value_68 = false;
|
|
goto value_69;
|
|
}
|
|
int64_t value_78 = (int64_t)(value_71).length;
|
|
uint8_t value_79 = 0;
|
|
{
|
|
String value_81 = value_70;
|
|
int64_t value_82 = value_78;
|
|
if (value_82 < 0LL || value_82 >= (int64_t)(value_81).length) {
|
|
value_79 = 0;
|
|
goto value_80;
|
|
}
|
|
value_79 = (uint8_t)value_81.data[value_82];
|
|
value_80: ;
|
|
}
|
|
uint8_t value_83 = value_79;
|
|
value_68 = value_83 == 0 || value_83 == 32 || value_83 == 9 || value_83 == 40 || value_83 == 34 || value_83 == 123;
|
|
value_69: ;
|
|
}
|
|
value_65 = (value_68 && !StringEqual(word, StringLiteral("if")) && !StringEqual(word, StringLiteral("else")));
|
|
}
|
|
value_63 = value_65;
|
|
}
|
|
if (value_63) {
|
|
return result;
|
|
}
|
|
return (ControlBlock){.valid = true, .head_end = (int64_t)((uint64_t)opening + UINT64_C(1)), .body_begin = (int64_t)((uint64_t)opening + UINT64_C(1)), .body_end = at, .tail_begin = tail, .open = false};
|
|
}
|
|
|
|
int64_t
|
|
source_ClosingParenthesis(String source)
|
|
{
|
|
if ((int64_t)(source).length == 0LL || (uint8_t)source.data[0] != 40) {
|
|
return -1LL;
|
|
}
|
|
int32_t depth = 0;
|
|
int64_t at = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 40) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if (byte == 41) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
if (depth == 0) {
|
|
return at;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
BraceClose
|
|
source_CloseBraces(String source, int32_t depth)
|
|
{
|
|
int32_t open = depth;
|
|
int64_t at = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
bool value_0 = byte == 47;
|
|
if (value_0) {
|
|
String value_1 = source;
|
|
int64_t value_2 = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
uint8_t value_3 = 0;
|
|
{
|
|
String value_5 = value_1;
|
|
int64_t value_6 = value_2;
|
|
if (value_6 < 0LL || value_6 >= (int64_t)(value_5).length) {
|
|
value_3 = 0;
|
|
goto value_4;
|
|
}
|
|
value_3 = (uint8_t)value_5.data[value_6];
|
|
value_4: ;
|
|
}
|
|
value_0 = (value_3 == 47);
|
|
}
|
|
if (value_0) {
|
|
break;
|
|
}
|
|
if (byte == 123) {
|
|
open = (int32_t)((uint32_t)open + 1u);
|
|
} else if (byte == 125) {
|
|
open = (int32_t)((uint32_t)open - 1u);
|
|
if (open == 0) {
|
|
return (BraceClose){.close = at, .depth = 0};
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return (BraceClose){.close = -1LL, .depth = open};
|
|
}
|
|
|
|
ProcedureLiteral
|
|
source_FindProcedureLiteral(String source)
|
|
{
|
|
ProcedureLiteral none = {.begin = -1LL, .open = -1LL, .close = -1LL, .depth = 0};
|
|
int64_t at = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
bool value_0 = byte == 47;
|
|
if (value_0) {
|
|
String value_1 = source;
|
|
int64_t value_2 = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
uint8_t value_3 = 0;
|
|
{
|
|
String value_5 = value_1;
|
|
int64_t value_6 = value_2;
|
|
if (value_6 < 0LL || value_6 >= (int64_t)(value_5).length) {
|
|
value_3 = 0;
|
|
goto value_4;
|
|
}
|
|
value_3 = (uint8_t)value_5.data[value_6];
|
|
value_4: ;
|
|
}
|
|
value_0 = (value_3 == 47);
|
|
}
|
|
if (value_0) {
|
|
return none;
|
|
}
|
|
if (byte == 40 && source_LiteralPosition(source, at)) {
|
|
int64_t close = source_ClosingParenthesis(StringRangeAt(source, (int64_t)at, (int64_t)source.length));
|
|
if (close > 0LL && source_TypedParameters(StringRangeAt(source, (int64_t)((int64_t)((uint64_t)at + UINT64_C(1))), (int64_t)((int64_t)((uint64_t)at + (uint64_t)close))))) {
|
|
int64_t open = source_LiteralBody(source, (int64_t)((uint64_t)at + (uint64_t)close));
|
|
if (open >= 0LL) {
|
|
BraceClose braces = source_CloseBraces(StringRangeAt(source, (int64_t)open, (int64_t)source.length), 0);
|
|
if (braces.close < 0LL) {
|
|
return (ProcedureLiteral){.begin = at, .open = open, .close = -1LL, .depth = braces.depth};
|
|
}
|
|
return (ProcedureLiteral){.begin = at, .open = open, .close = (int64_t)((uint64_t)open + (uint64_t)(braces.close)), .depth = 0};
|
|
}
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return none;
|
|
}
|
|
|
|
static bool
|
|
source_LiteralPosition(String source, int64_t at)
|
|
{
|
|
int64_t before = at;
|
|
while (true) {
|
|
bool value_0 = before > 0LL;
|
|
if (value_0) {
|
|
uint8_t value_1 = (uint8_t)source.data[((int64_t)((uint64_t)before - UINT64_C(1)))];
|
|
bool value_2 = false;
|
|
{
|
|
uint8_t value_4 = value_1;
|
|
value_2 = value_4 == 32 || (value_4 >= 9 && value_4 <= 13);
|
|
}
|
|
value_0 = value_2;
|
|
}
|
|
if (!value_0) { break; }
|
|
before = (int64_t)((uint64_t)before - UINT64_C(1));
|
|
}
|
|
if (before == 0LL) {
|
|
return false;
|
|
}
|
|
uint8_t previous = (uint8_t)source.data[((int64_t)((uint64_t)before - UINT64_C(1)))];
|
|
if (previous == 40 || previous == 44 || previous == 91) {
|
|
return true;
|
|
}
|
|
if (previous == 61) {
|
|
String value_5 = source;
|
|
int64_t value_6 = (int64_t)((uint64_t)before - UINT64_C(2));
|
|
uint8_t value_7 = 0;
|
|
{
|
|
String value_9 = value_5;
|
|
int64_t value_10 = value_6;
|
|
if (value_10 < 0LL || value_10 >= (int64_t)(value_9).length) {
|
|
value_7 = 0;
|
|
goto value_8;
|
|
}
|
|
value_7 = (uint8_t)value_9.data[value_10];
|
|
value_8: ;
|
|
}
|
|
uint8_t operator = value_7;
|
|
{
|
|
String value_11 = StringLiteral("=!<>+-*/%&|^");
|
|
String loop_view_13 = StringRangeAt(value_11, (int64_t)0, (int64_t)value_11.length);
|
|
int64_t loop_count_13 = (int64_t)(loop_view_13).length;
|
|
int64_t loop_cursor_13 = 0LL;
|
|
while (loop_cursor_13 < loop_count_13) {
|
|
int64_t loop_index_13 = loop_cursor_13;
|
|
uint8_t excluded = (uint8_t)loop_view_13.data[loop_index_13];
|
|
if (operator == excluded) {
|
|
return false;
|
|
}
|
|
loop_cursor_13 = (int64_t)((uint64_t)loop_cursor_13 + UINT64_C(1));
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
bool value_12 = before >= 6LL && StringEqual(StringRangeAt(source, (int64_t)((int64_t)((uint64_t)before - UINT64_C(6))), (int64_t)before), StringLiteral("return"));
|
|
bool value_13 = value_12;
|
|
bool value_14 = value_13;
|
|
if (value_14) {
|
|
String value_15 = source;
|
|
int64_t value_16 = (int64_t)((uint64_t)before - UINT64_C(7));
|
|
uint8_t value_17 = 0;
|
|
{
|
|
String value_19 = value_15;
|
|
int64_t value_20 = value_16;
|
|
if (value_20 < 0LL || value_20 >= (int64_t)(value_19).length) {
|
|
value_17 = 0;
|
|
goto value_18;
|
|
}
|
|
value_17 = (uint8_t)value_19.data[value_20];
|
|
value_18: ;
|
|
}
|
|
bool value_21 = false;
|
|
{
|
|
uint8_t value_23 = value_17;
|
|
bool value_24 = false;
|
|
{
|
|
uint8_t value_26 = value_23;
|
|
value_24 = (value_26 >= 65 && value_26 <= 90) || (value_26 >= 97 && value_26 <= 122) || value_26 == 95;
|
|
}
|
|
value_21 = value_24 || (value_23 >= 48 && value_23 <= 57);
|
|
}
|
|
value_14 = !value_21;
|
|
}
|
|
return value_14;
|
|
}
|
|
|
|
static bool
|
|
source_TypedParameters(String source)
|
|
{
|
|
int64_t value_0 = source_SkipSpace(source, 0LL);
|
|
int64_t value_1 = (int64_t)(source).length;
|
|
if (value_0 >= value_1) {
|
|
return true;
|
|
}
|
|
int32_t depth = 0;
|
|
int64_t begin = 0LL;
|
|
int64_t at = 0LL;
|
|
while (at <= (int64_t)(source).length) {
|
|
String value_2 = source;
|
|
int64_t value_3 = at;
|
|
uint8_t value_4 = 0;
|
|
{
|
|
String value_6 = value_2;
|
|
int64_t value_7 = value_3;
|
|
if (value_7 < 0LL || value_7 >= (int64_t)(value_6).length) {
|
|
value_4 = 0;
|
|
goto value_5;
|
|
}
|
|
value_4 = (uint8_t)value_6.data[value_7];
|
|
value_5: ;
|
|
}
|
|
uint8_t byte = value_4;
|
|
if (at < (int64_t)(source).length && (byte == 34 || byte == 39)) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 40 || byte == 91 || byte == 123) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if (byte == 41 || byte == 93 || byte == 125) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
} else if (at == (int64_t)(source).length || (byte == 44 && depth == 0)) {
|
|
String value_8 = source;
|
|
int64_t value_9 = source_SkipSpace(source, begin);
|
|
String part = StringRangeAt(value_8, (int64_t)value_9, (int64_t)at);
|
|
int64_t colon = source_FindCode(part, StringLiteral(":"));
|
|
bool value_10 = (int64_t)(part).length == 0LL;
|
|
if (!value_10) {
|
|
uint8_t value_11 = (uint8_t)part.data[0];
|
|
bool value_12 = false;
|
|
{
|
|
uint8_t value_14 = value_11;
|
|
value_12 = (value_14 >= 65 && value_14 <= 90) || (value_14 >= 97 && value_14 <= 122) || value_14 == 95;
|
|
}
|
|
value_10 = !value_12;
|
|
}
|
|
bool value_15 = value_10 || colon < 0LL;
|
|
if (!value_15) {
|
|
String value_16 = StringLiteral("::");
|
|
bool value_17 = false;
|
|
{
|
|
String value_19 = part;
|
|
int64_t value_20 = colon;
|
|
String value_21 = value_16;
|
|
bool value_22 = value_20 >= 0LL && value_20 <= (int64_t)(value_19).length && (int64_t)(value_21).length <= (int64_t)((uint64_t)((int64_t)(value_19).length) - (uint64_t)value_20);
|
|
value_17 = value_22 && StringEqual(StringRangeAt(value_19, (int64_t)value_20, (int64_t)((int64_t)((uint64_t)value_20 + (uint64_t)((int64_t)(value_21).length)))), value_21);
|
|
}
|
|
value_15 = value_17;
|
|
}
|
|
if (value_15) {
|
|
return false;
|
|
}
|
|
begin = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static int64_t
|
|
source_LiteralBody(String source, int64_t close)
|
|
{
|
|
int64_t at = source_SkipSpace(source, (int64_t)((uint64_t)close + UINT64_C(1)));
|
|
String value_0 = source;
|
|
int64_t value_1 = at;
|
|
String value_2 = StringLiteral("->");
|
|
bool value_3 = false;
|
|
{
|
|
String value_5 = value_0;
|
|
int64_t value_6 = value_1;
|
|
String value_7 = value_2;
|
|
bool value_8 = value_6 >= 0LL && value_6 <= (int64_t)(value_5).length && (int64_t)(value_7).length <= (int64_t)((uint64_t)((int64_t)(value_5).length) - (uint64_t)value_6);
|
|
value_3 = value_8 && StringEqual(StringRangeAt(value_5, (int64_t)value_6, (int64_t)((int64_t)((uint64_t)value_6 + (uint64_t)((int64_t)(value_7).length)))), value_7);
|
|
}
|
|
if (value_3) {
|
|
at = source_SkipSpace(source, (int64_t)((uint64_t)at + UINT64_C(2)));
|
|
int32_t depth = 0;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 40 || byte == 91) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if (byte == 41 || byte == 93) {
|
|
if (depth == 0) {
|
|
return -1LL;
|
|
}
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
} else if (depth == 0 && (byte == 123 || byte == 44 || byte == 59 || byte == 61)) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
String value_9 = source;
|
|
int64_t value_10 = at;
|
|
uint8_t value_11 = 0;
|
|
{
|
|
String value_13 = value_9;
|
|
int64_t value_14 = value_10;
|
|
if (value_14 < 0LL || value_14 >= (int64_t)(value_13).length) {
|
|
value_11 = 0;
|
|
goto value_12;
|
|
}
|
|
value_11 = (uint8_t)value_13.data[value_14];
|
|
value_12: ;
|
|
}
|
|
int64_t value_15 = 0;
|
|
if (value_11 == 123) {
|
|
value_15 = at;
|
|
} else {
|
|
value_15 = -1LL;
|
|
}
|
|
return value_15;
|
|
}
|
|
|
|
ProcedureHeader
|
|
source_ProcedureHeaderParts(String source)
|
|
{
|
|
ProcedureHeader header = {.name = StringLiteral(""), .parameters = StringLiteral(""), .result = StringLiteral("void")};
|
|
int64_t colons = source_FindCode(source, StringLiteral("::"));
|
|
if (colons >= 0LL) {
|
|
int64_t begin = 0LL;
|
|
while (begin < colons && ((uint8_t)source.data[begin] == 32 || (uint8_t)source.data[begin] == 9)) {
|
|
begin = (int64_t)((uint64_t)begin + UINT64_C(1));
|
|
}
|
|
int64_t end = begin;
|
|
while (true) {
|
|
bool value_0 = end < colons;
|
|
if (value_0) {
|
|
uint8_t value_1 = (uint8_t)source.data[end];
|
|
bool value_2 = false;
|
|
{
|
|
uint8_t value_4 = value_1;
|
|
bool value_5 = false;
|
|
{
|
|
uint8_t value_7 = value_4;
|
|
value_5 = (value_7 >= 65 && value_7 <= 90) || (value_7 >= 97 && value_7 <= 122) || value_7 == 95;
|
|
}
|
|
value_2 = value_5 || (value_4 >= 48 && value_4 <= 57);
|
|
}
|
|
value_0 = value_2;
|
|
}
|
|
if (!value_0) { break; }
|
|
end = (int64_t)((uint64_t)end + UINT64_C(1));
|
|
}
|
|
String* value_8 = &(header.name);
|
|
(*value_8) = StringRangeAt(source, (int64_t)begin, (int64_t)end);
|
|
}
|
|
int64_t opening = source_Find(source, StringLiteral("("));
|
|
if (opening < 0LL) {
|
|
return header;
|
|
}
|
|
int64_t closing = source_ClosingParenthesis(StringRangeAt(source, (int64_t)opening, (int64_t)source.length));
|
|
if (closing < 0LL) {
|
|
return header;
|
|
}
|
|
closing = (int64_t)((uint64_t)closing + (uint64_t)opening);
|
|
int64_t end = closing;
|
|
while (true) {
|
|
bool value_9 = end > (int64_t)((uint64_t)opening + UINT64_C(1));
|
|
if (value_9) {
|
|
uint8_t value_10 = (uint8_t)source.data[((int64_t)((uint64_t)end - UINT64_C(1)))];
|
|
bool value_11 = false;
|
|
{
|
|
uint8_t value_13 = value_10;
|
|
value_11 = value_13 == 32 || (value_13 >= 9 && value_13 <= 13);
|
|
}
|
|
value_9 = value_11;
|
|
}
|
|
if (!value_9) { break; }
|
|
end = (int64_t)((uint64_t)end - UINT64_C(1));
|
|
}
|
|
String* value_14 = &(header.parameters);
|
|
(*value_14) = StringRangeAt(source, (int64_t)((int64_t)((uint64_t)opening + UINT64_C(1))), (int64_t)end);
|
|
int64_t at = (int64_t)((uint64_t)closing + UINT64_C(1));
|
|
while (at < (int64_t)(source).length && ((uint8_t)source.data[at] == 32 || (uint8_t)source.data[at] == 9)) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
String value_15 = source;
|
|
int64_t value_16 = at;
|
|
String value_17 = StringLiteral("->");
|
|
bool value_18 = false;
|
|
{
|
|
String value_20 = value_15;
|
|
int64_t value_21 = value_16;
|
|
String value_22 = value_17;
|
|
bool value_23 = value_21 >= 0LL && value_21 <= (int64_t)(value_20).length && (int64_t)(value_22).length <= (int64_t)((uint64_t)((int64_t)(value_20).length) - (uint64_t)value_21);
|
|
value_18 = value_23 && StringEqual(StringRangeAt(value_20, (int64_t)value_21, (int64_t)((int64_t)((uint64_t)value_21 + (uint64_t)((int64_t)(value_22).length)))), value_22);
|
|
}
|
|
if (!value_18) {
|
|
return header;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
while (at < (int64_t)(source).length && ((uint8_t)source.data[at] == 32 || (uint8_t)source.data[at] == 9)) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
end = at;
|
|
while (end < (int64_t)(source).length && (uint8_t)source.data[end] != 35 && (uint8_t)source.data[end] != 123) {
|
|
end = (int64_t)((uint64_t)end + UINT64_C(1));
|
|
}
|
|
while (true) {
|
|
bool value_24 = end > at;
|
|
if (value_24) {
|
|
uint8_t value_25 = (uint8_t)source.data[((int64_t)((uint64_t)end - UINT64_C(1)))];
|
|
bool value_26 = false;
|
|
{
|
|
uint8_t value_28 = value_25;
|
|
value_26 = value_28 == 32 || (value_28 >= 9 && value_28 <= 13);
|
|
}
|
|
value_24 = value_26;
|
|
}
|
|
if (!value_24) { break; }
|
|
end = (int64_t)((uint64_t)end - UINT64_C(1));
|
|
}
|
|
String* value_29 = &(header.result);
|
|
(*value_29) = StringRangeAt(source, (int64_t)at, (int64_t)end);
|
|
return header;
|
|
}
|
|
|
|
int64_t
|
|
source_NormalizeTypeSpacing(String source, Slice output)
|
|
{
|
|
int64_t used = 0LL;
|
|
int64_t at = 0LL;
|
|
bool quoted = false;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
source_Put(output, &(used), byte);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
if (quoted) {
|
|
if (byte == 92 && at < (int64_t)(source).length) {
|
|
source_Put(output, &(used), (uint8_t)source.data[at]);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
} else if (byte == 34) {
|
|
quoted = false;
|
|
}
|
|
} else if (byte == 34) {
|
|
quoted = true;
|
|
} else if (byte == 93 || byte == 42) {
|
|
int64_t next = at;
|
|
while (next < (int64_t)(source).length && ((uint8_t)source.data[next] == 32 || (uint8_t)source.data[next] == 9)) {
|
|
next = (int64_t)((uint64_t)next + UINT64_C(1));
|
|
}
|
|
String value_0 = source;
|
|
uint8_t value_1 = 0;
|
|
{
|
|
String value_3 = value_0;
|
|
int64_t value_4 = next;
|
|
if (value_4 < 0LL || value_4 >= (int64_t)(value_3).length) {
|
|
value_1 = 0;
|
|
goto value_2;
|
|
}
|
|
value_1 = (uint8_t)value_3.data[value_4];
|
|
value_2: ;
|
|
}
|
|
uint8_t following = value_1;
|
|
bool value_5 = next > at;
|
|
if (value_5) {
|
|
bool value_6 = false;
|
|
{
|
|
uint8_t value_8 = following;
|
|
value_6 = (value_8 >= 65 && value_8 <= 90) || (value_8 >= 97 && value_8 <= 122) || value_8 == 95;
|
|
}
|
|
value_5 = (value_6 || following == 91 || following == 36);
|
|
}
|
|
if (value_5) {
|
|
at = next;
|
|
}
|
|
}
|
|
}
|
|
return used;
|
|
}
|
|
|
|
int64_t
|
|
source_CopyProcedureText(String source, Slice output, bool normalize_type)
|
|
{
|
|
if ((int64_t)(output).length == 0LL) {
|
|
return 0LL;
|
|
}
|
|
int64_t count = (int64_t)(source).length;
|
|
if (count >= (int64_t)(output).length) {
|
|
count = (int64_t)((uint64_t)((int64_t)(output).length) - UINT64_C(1));
|
|
}
|
|
int64_t used = 0LL;
|
|
if (normalize_type) {
|
|
while (true) {
|
|
bool value_0 = count > 0LL;
|
|
if (value_0) {
|
|
uint8_t value_1 = (uint8_t)source.data[((int64_t)((uint64_t)count - UINT64_C(1)))];
|
|
bool value_2 = false;
|
|
{
|
|
uint8_t value_4 = value_1;
|
|
value_2 = value_4 == 32 || (value_4 >= 9 && value_4 <= 13);
|
|
}
|
|
value_0 = value_2;
|
|
}
|
|
if (!value_0) { break; }
|
|
count = (int64_t)((uint64_t)count - UINT64_C(1));
|
|
}
|
|
Slice value_5 = output;
|
|
used = source_NormalizeTypeSpacing(StringRangeAt(source, (int64_t)0LL, (int64_t)count), SliceRangeAt(value_5, (int64_t)0LL, (int64_t)count, sizeof(uint8_t)));
|
|
} else {
|
|
{
|
|
int64_t range_first_15 = 0LL;
|
|
int64_t range_last_15 = (int64_t)((uint64_t)count - UINT64_C(1));
|
|
int64_t index = range_first_15;
|
|
if (index <= range_last_15) for (;;) {
|
|
uint8_t* value_6 = &(((uint8_t *)(output).data)[index]);
|
|
(*value_6) = (uint8_t)source.data[index];
|
|
if (index == range_last_15) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
used = count;
|
|
}
|
|
uint8_t* value_7 = &(((uint8_t *)(output).data)[used]);
|
|
(*value_7) = 0;
|
|
return used;
|
|
}
|
|
|
|
int64_t
|
|
source_OpeningBraceOutsideLiterals(String source)
|
|
{
|
|
int64_t at = 0LL;
|
|
int64_t depth = 0LL;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 92) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
if (at < (int64_t)(source).length) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
} else if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
} else {
|
|
if (byte == 123 && depth == 0LL) {
|
|
return at;
|
|
}
|
|
if (byte == 40 || byte == 91) {
|
|
depth = (int64_t)((uint64_t)depth + UINT64_C(1));
|
|
}
|
|
if (depth > 0LL && (byte == 41 || byte == 93)) {
|
|
depth = (int64_t)((uint64_t)depth - UINT64_C(1));
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
bool
|
|
source_BraceOutsideLiterals(String source)
|
|
{
|
|
int64_t value_0 = source_OpeningBraceOutsideLiterals(source);
|
|
return value_0 >= 0LL;
|
|
}
|
|
|
|
bool
|
|
source_LooksLikeProcedureHeader(String source)
|
|
{
|
|
String value_0 = source;
|
|
String value_1 = StringLiteral("#import");
|
|
bool value_2 = false;
|
|
{
|
|
String value_4 = value_0;
|
|
String value_5 = value_1;
|
|
bool value_6 = false;
|
|
{
|
|
String value_8 = value_4;
|
|
int64_t value_9 = 0LL;
|
|
String value_10 = value_5;
|
|
bool value_11 = value_9 >= 0LL && value_9 <= (int64_t)(value_8).length && (int64_t)(value_10).length <= (int64_t)((uint64_t)((int64_t)(value_8).length) - (uint64_t)value_9);
|
|
value_6 = value_11 && StringEqual(StringRangeAt(value_8, (int64_t)value_9, (int64_t)((int64_t)((uint64_t)value_9 + (uint64_t)((int64_t)(value_10).length)))), value_10);
|
|
}
|
|
if (!value_6) {
|
|
value_2 = false;
|
|
goto value_3;
|
|
}
|
|
int64_t value_12 = (int64_t)(value_5).length;
|
|
uint8_t value_13 = 0;
|
|
{
|
|
String value_15 = value_4;
|
|
int64_t value_16 = value_12;
|
|
if (value_16 < 0LL || value_16 >= (int64_t)(value_15).length) {
|
|
value_13 = 0;
|
|
goto value_14;
|
|
}
|
|
value_13 = (uint8_t)value_15.data[value_16];
|
|
value_14: ;
|
|
}
|
|
uint8_t value_17 = value_13;
|
|
value_2 = value_17 == 0 || value_17 == 32 || value_17 == 9 || value_17 == 40 || value_17 == 34 || value_17 == 123;
|
|
value_3: ;
|
|
}
|
|
bool value_18 = value_2;
|
|
if (!value_18) {
|
|
String value_19 = source;
|
|
String value_20 = StringLiteral("#import,");
|
|
bool value_21 = false;
|
|
{
|
|
String value_23 = value_19;
|
|
int64_t value_24 = 0LL;
|
|
String value_25 = value_20;
|
|
bool value_26 = value_24 >= 0LL && value_24 <= (int64_t)(value_23).length && (int64_t)(value_25).length <= (int64_t)((uint64_t)((int64_t)(value_23).length) - (uint64_t)value_24);
|
|
value_21 = value_26 && StringEqual(StringRangeAt(value_23, (int64_t)value_24, (int64_t)((int64_t)((uint64_t)value_24 + (uint64_t)((int64_t)(value_25).length)))), value_25);
|
|
}
|
|
value_18 = value_21;
|
|
}
|
|
if (value_18) {
|
|
return false;
|
|
}
|
|
int64_t colons = source_FindCode(source, StringLiteral("::"));
|
|
if (colons < 0LL) {
|
|
return false;
|
|
}
|
|
int64_t at = source_SkipSpace(source, (int64_t)((uint64_t)colons + UINT64_C(2)));
|
|
int64_t end = (int64_t)(source).length;
|
|
while (true) {
|
|
bool value_27 = end > at;
|
|
if (value_27) {
|
|
uint8_t value_28 = (uint8_t)source.data[((int64_t)((uint64_t)end - UINT64_C(1)))];
|
|
bool value_29 = false;
|
|
{
|
|
uint8_t value_31 = value_28;
|
|
value_29 = value_31 == 32 || (value_31 >= 9 && value_31 <= 13);
|
|
}
|
|
value_27 = value_29;
|
|
}
|
|
if (!value_27) { break; }
|
|
end = (int64_t)((uint64_t)end - UINT64_C(1));
|
|
}
|
|
String body = StringRangeAt(source, (int64_t)at, (int64_t)end);
|
|
String value_32 = StringLiteral("#as");
|
|
bool value_33 = false;
|
|
{
|
|
String value_35 = body;
|
|
String value_36 = value_32;
|
|
bool value_37 = false;
|
|
{
|
|
String value_39 = value_35;
|
|
int64_t value_40 = 0LL;
|
|
String value_41 = value_36;
|
|
bool value_42 = value_40 >= 0LL && value_40 <= (int64_t)(value_39).length && (int64_t)(value_41).length <= (int64_t)((uint64_t)((int64_t)(value_39).length) - (uint64_t)value_40);
|
|
value_37 = value_42 && StringEqual(StringRangeAt(value_39, (int64_t)value_40, (int64_t)((int64_t)((uint64_t)value_40 + (uint64_t)((int64_t)(value_41).length)))), value_41);
|
|
}
|
|
if (!value_37) {
|
|
value_33 = false;
|
|
goto value_34;
|
|
}
|
|
int64_t value_43 = (int64_t)(value_36).length;
|
|
uint8_t value_44 = 0;
|
|
{
|
|
String value_46 = value_35;
|
|
int64_t value_47 = value_43;
|
|
if (value_47 < 0LL || value_47 >= (int64_t)(value_46).length) {
|
|
value_44 = 0;
|
|
goto value_45;
|
|
}
|
|
value_44 = (uint8_t)value_46.data[value_47];
|
|
value_45: ;
|
|
}
|
|
uint8_t value_48 = value_44;
|
|
value_33 = value_48 == 0 || value_48 == 32 || value_48 == 9 || value_48 == 40 || value_48 == 34 || value_48 == 123;
|
|
value_34: ;
|
|
}
|
|
if (value_33) {
|
|
String value_49 = body;
|
|
int64_t value_50 = source_SkipSpace(body, 3LL);
|
|
body = StringRangeAt(value_49, (int64_t)value_50, (int64_t)value_49.length);
|
|
}
|
|
String value_51 = StringLiteral("#import");
|
|
bool value_52 = false;
|
|
{
|
|
String value_54 = body;
|
|
String value_55 = value_51;
|
|
bool value_56 = false;
|
|
{
|
|
String value_58 = value_54;
|
|
int64_t value_59 = 0LL;
|
|
String value_60 = value_55;
|
|
bool value_61 = value_59 >= 0LL && value_59 <= (int64_t)(value_58).length && (int64_t)(value_60).length <= (int64_t)((uint64_t)((int64_t)(value_58).length) - (uint64_t)value_59);
|
|
value_56 = value_61 && StringEqual(StringRangeAt(value_58, (int64_t)value_59, (int64_t)((int64_t)((uint64_t)value_59 + (uint64_t)((int64_t)(value_60).length)))), value_60);
|
|
}
|
|
if (!value_56) {
|
|
value_52 = false;
|
|
goto value_53;
|
|
}
|
|
int64_t value_62 = (int64_t)(value_55).length;
|
|
uint8_t value_63 = 0;
|
|
{
|
|
String value_65 = value_54;
|
|
int64_t value_66 = value_62;
|
|
if (value_66 < 0LL || value_66 >= (int64_t)(value_65).length) {
|
|
value_63 = 0;
|
|
goto value_64;
|
|
}
|
|
value_63 = (uint8_t)value_65.data[value_66];
|
|
value_64: ;
|
|
}
|
|
uint8_t value_67 = value_63;
|
|
value_52 = value_67 == 0 || value_67 == 32 || value_67 == 9 || value_67 == 40 || value_67 == 34 || value_67 == 123;
|
|
value_53: ;
|
|
}
|
|
bool value_68 = value_52;
|
|
if (!value_68) {
|
|
String value_69 = StringLiteral("#import,");
|
|
bool value_70 = false;
|
|
{
|
|
String value_72 = body;
|
|
int64_t value_73 = 0LL;
|
|
String value_74 = value_69;
|
|
bool value_75 = value_73 >= 0LL && value_73 <= (int64_t)(value_72).length && (int64_t)(value_74).length <= (int64_t)((uint64_t)((int64_t)(value_72).length) - (uint64_t)value_73);
|
|
value_70 = value_75 && StringEqual(StringRangeAt(value_72, (int64_t)value_73, (int64_t)((int64_t)((uint64_t)value_73 + (uint64_t)((int64_t)(value_74).length)))), value_74);
|
|
}
|
|
value_68 = value_70;
|
|
}
|
|
bool value_76 = value_68;
|
|
if (!value_76) {
|
|
String value_77 = StringLiteral("#defined");
|
|
bool value_78 = false;
|
|
{
|
|
String value_80 = body;
|
|
String value_81 = value_77;
|
|
bool value_82 = false;
|
|
{
|
|
String value_84 = value_80;
|
|
int64_t value_85 = 0LL;
|
|
String value_86 = value_81;
|
|
bool value_87 = value_85 >= 0LL && value_85 <= (int64_t)(value_84).length && (int64_t)(value_86).length <= (int64_t)((uint64_t)((int64_t)(value_84).length) - (uint64_t)value_85);
|
|
value_82 = value_87 && StringEqual(StringRangeAt(value_84, (int64_t)value_85, (int64_t)((int64_t)((uint64_t)value_85 + (uint64_t)((int64_t)(value_86).length)))), value_86);
|
|
}
|
|
if (!value_82) {
|
|
value_78 = false;
|
|
goto value_79;
|
|
}
|
|
int64_t value_88 = (int64_t)(value_81).length;
|
|
uint8_t value_89 = 0;
|
|
{
|
|
String value_91 = value_80;
|
|
int64_t value_92 = value_88;
|
|
if (value_92 < 0LL || value_92 >= (int64_t)(value_91).length) {
|
|
value_89 = 0;
|
|
goto value_90;
|
|
}
|
|
value_89 = (uint8_t)value_91.data[value_92];
|
|
value_90: ;
|
|
}
|
|
uint8_t value_93 = value_89;
|
|
value_78 = value_93 == 0 || value_93 == 32 || value_93 == 9 || value_93 == 40 || value_93 == 34 || value_93 == 123;
|
|
value_79: ;
|
|
}
|
|
value_76 = value_78;
|
|
}
|
|
bool value_94 = value_76;
|
|
if (!value_94) {
|
|
String value_95 = StringLiteral("#define");
|
|
bool value_96 = false;
|
|
{
|
|
String value_98 = body;
|
|
String value_99 = value_95;
|
|
bool value_100 = false;
|
|
{
|
|
String value_102 = value_98;
|
|
int64_t value_103 = 0LL;
|
|
String value_104 = value_99;
|
|
bool value_105 = value_103 >= 0LL && value_103 <= (int64_t)(value_102).length && (int64_t)(value_104).length <= (int64_t)((uint64_t)((int64_t)(value_102).length) - (uint64_t)value_103);
|
|
value_100 = value_105 && StringEqual(StringRangeAt(value_102, (int64_t)value_103, (int64_t)((int64_t)((uint64_t)value_103 + (uint64_t)((int64_t)(value_104).length)))), value_104);
|
|
}
|
|
if (!value_100) {
|
|
value_96 = false;
|
|
goto value_97;
|
|
}
|
|
int64_t value_106 = (int64_t)(value_99).length;
|
|
uint8_t value_107 = 0;
|
|
{
|
|
String value_109 = value_98;
|
|
int64_t value_110 = value_106;
|
|
if (value_110 < 0LL || value_110 >= (int64_t)(value_109).length) {
|
|
value_107 = 0;
|
|
goto value_108;
|
|
}
|
|
value_107 = (uint8_t)value_109.data[value_110];
|
|
value_108: ;
|
|
}
|
|
uint8_t value_111 = value_107;
|
|
value_96 = value_111 == 0 || value_111 == 32 || value_111 == 9 || value_111 == 40 || value_111 == 34 || value_111 == 123;
|
|
value_97: ;
|
|
}
|
|
value_94 = value_96;
|
|
}
|
|
bool value_112 = value_94;
|
|
if (!value_112) {
|
|
String value_113 = StringLiteral("struct");
|
|
bool value_114 = false;
|
|
{
|
|
String value_116 = body;
|
|
String value_117 = value_113;
|
|
bool value_118 = false;
|
|
{
|
|
String value_120 = value_116;
|
|
int64_t value_121 = 0LL;
|
|
String value_122 = value_117;
|
|
bool value_123 = value_121 >= 0LL && value_121 <= (int64_t)(value_120).length && (int64_t)(value_122).length <= (int64_t)((uint64_t)((int64_t)(value_120).length) - (uint64_t)value_121);
|
|
value_118 = value_123 && StringEqual(StringRangeAt(value_120, (int64_t)value_121, (int64_t)((int64_t)((uint64_t)value_121 + (uint64_t)((int64_t)(value_122).length)))), value_122);
|
|
}
|
|
if (!value_118) {
|
|
value_114 = false;
|
|
goto value_115;
|
|
}
|
|
int64_t value_124 = (int64_t)(value_117).length;
|
|
uint8_t value_125 = 0;
|
|
{
|
|
String value_127 = value_116;
|
|
int64_t value_128 = value_124;
|
|
if (value_128 < 0LL || value_128 >= (int64_t)(value_127).length) {
|
|
value_125 = 0;
|
|
goto value_126;
|
|
}
|
|
value_125 = (uint8_t)value_127.data[value_128];
|
|
value_126: ;
|
|
}
|
|
uint8_t value_129 = value_125;
|
|
value_114 = value_129 == 0 || value_129 == 32 || value_129 == 9 || value_129 == 40 || value_129 == 34 || value_129 == 123;
|
|
value_115: ;
|
|
}
|
|
value_112 = value_114;
|
|
}
|
|
bool value_130 = value_112;
|
|
if (!value_130) {
|
|
String value_131 = StringLiteral("enum");
|
|
bool value_132 = false;
|
|
{
|
|
String value_134 = body;
|
|
String value_135 = value_131;
|
|
bool value_136 = false;
|
|
{
|
|
String value_138 = value_134;
|
|
int64_t value_139 = 0LL;
|
|
String value_140 = value_135;
|
|
bool value_141 = value_139 >= 0LL && value_139 <= (int64_t)(value_138).length && (int64_t)(value_140).length <= (int64_t)((uint64_t)((int64_t)(value_138).length) - (uint64_t)value_139);
|
|
value_136 = value_141 && StringEqual(StringRangeAt(value_138, (int64_t)value_139, (int64_t)((int64_t)((uint64_t)value_139 + (uint64_t)((int64_t)(value_140).length)))), value_140);
|
|
}
|
|
if (!value_136) {
|
|
value_132 = false;
|
|
goto value_133;
|
|
}
|
|
int64_t value_142 = (int64_t)(value_135).length;
|
|
uint8_t value_143 = 0;
|
|
{
|
|
String value_145 = value_134;
|
|
int64_t value_146 = value_142;
|
|
if (value_146 < 0LL || value_146 >= (int64_t)(value_145).length) {
|
|
value_143 = 0;
|
|
goto value_144;
|
|
}
|
|
value_143 = (uint8_t)value_145.data[value_146];
|
|
value_144: ;
|
|
}
|
|
uint8_t value_147 = value_143;
|
|
value_132 = value_147 == 0 || value_147 == 32 || value_147 == 9 || value_147 == 40 || value_147 == 34 || value_147 == 123;
|
|
value_133: ;
|
|
}
|
|
value_130 = value_132;
|
|
}
|
|
bool value_148 = value_130;
|
|
if (!value_148) {
|
|
String value_149 = StringLiteral("union");
|
|
bool value_150 = false;
|
|
{
|
|
String value_152 = body;
|
|
String value_153 = value_149;
|
|
bool value_154 = false;
|
|
{
|
|
String value_156 = value_152;
|
|
int64_t value_157 = 0LL;
|
|
String value_158 = value_153;
|
|
bool value_159 = value_157 >= 0LL && value_157 <= (int64_t)(value_156).length && (int64_t)(value_158).length <= (int64_t)((uint64_t)((int64_t)(value_156).length) - (uint64_t)value_157);
|
|
value_154 = value_159 && StringEqual(StringRangeAt(value_156, (int64_t)value_157, (int64_t)((int64_t)((uint64_t)value_157 + (uint64_t)((int64_t)(value_158).length)))), value_158);
|
|
}
|
|
if (!value_154) {
|
|
value_150 = false;
|
|
goto value_151;
|
|
}
|
|
int64_t value_160 = (int64_t)(value_153).length;
|
|
uint8_t value_161 = 0;
|
|
{
|
|
String value_163 = value_152;
|
|
int64_t value_164 = value_160;
|
|
if (value_164 < 0LL || value_164 >= (int64_t)(value_163).length) {
|
|
value_161 = 0;
|
|
goto value_162;
|
|
}
|
|
value_161 = (uint8_t)value_163.data[value_164];
|
|
value_162: ;
|
|
}
|
|
uint8_t value_165 = value_161;
|
|
value_150 = value_165 == 0 || value_165 == 32 || value_165 == 9 || value_165 == 40 || value_165 == 34 || value_165 == 123;
|
|
value_151: ;
|
|
}
|
|
value_148 = value_150;
|
|
}
|
|
bool value_166 = value_148;
|
|
if (!value_166) {
|
|
int64_t value_167 = source_Find(body, StringLiteral("#type"));
|
|
value_166 = (value_167 >= 0LL);
|
|
}
|
|
bool value_168 = value_166;
|
|
if (!value_168) {
|
|
uint8_t value_169 = 0;
|
|
{
|
|
String value_171 = body;
|
|
int64_t value_172 = 0LL;
|
|
if (value_172 < 0LL || value_172 >= (int64_t)(value_171).length) {
|
|
value_169 = 0;
|
|
goto value_170;
|
|
}
|
|
value_169 = (uint8_t)value_171.data[value_172];
|
|
value_170: ;
|
|
}
|
|
value_168 = (value_169 != 40);
|
|
}
|
|
if (value_168) {
|
|
return false;
|
|
}
|
|
int64_t value_173 = source_Find(body, StringLiteral("{"));
|
|
bool value_174 = value_173 >= 0LL;
|
|
if (!value_174) {
|
|
int64_t value_175 = source_Find(body, StringLiteral("->"));
|
|
value_174 = (value_175 >= 0LL);
|
|
}
|
|
if (value_174) {
|
|
return true;
|
|
}
|
|
int32_t depth = 0;
|
|
int64_t begin = -1LL;
|
|
end = -1LL;
|
|
at = 0LL;
|
|
while (at < (int64_t)(body).length) {
|
|
if ((uint8_t)body.data[at] == 40) {
|
|
if (depth == 0) {
|
|
begin = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if ((uint8_t)body.data[at] == 41) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
if (depth == 0) {
|
|
end = at;
|
|
break;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (begin < 0LL || end < 0LL) {
|
|
return false;
|
|
}
|
|
while (begin < end && ((uint8_t)body.data[begin] == 32 || (uint8_t)body.data[begin] == 9)) {
|
|
begin = (int64_t)((uint64_t)begin + UINT64_C(1));
|
|
}
|
|
if (begin >= end) {
|
|
return true;
|
|
}
|
|
uint8_t byte = (uint8_t)body.data[begin];
|
|
if (byte == 34 || byte == 39 || (byte >= 48 && byte <= 57)) {
|
|
return false;
|
|
}
|
|
int64_t value_176 = source_Find(StringRangeAt(body, (int64_t)begin, (int64_t)body.length), StringLiteral("\?"));
|
|
bool value_177 = value_176 < 0LL;
|
|
if (value_177) {
|
|
int64_t value_178 = source_Find(StringRangeAt(body, (int64_t)begin, (int64_t)body.length), StringLiteral(":"));
|
|
value_177 = (value_178 >= 0LL);
|
|
}
|
|
return value_177;
|
|
}
|
|
|
|
ControlBlock
|
|
source_SplitProcedureBody(String source)
|
|
{
|
|
ControlBlock block = {0};
|
|
int64_t opening = source_OpeningBraceOutsideLiterals(source);
|
|
bool value_0 = opening < 0LL;
|
|
if (!value_0) {
|
|
String value_1 = source;
|
|
int64_t value_2 = (int64_t)((uint64_t)((int64_t)(source).length) - UINT64_C(1));
|
|
uint8_t value_3 = 0;
|
|
{
|
|
String value_5 = value_1;
|
|
int64_t value_6 = value_2;
|
|
if (value_6 < 0LL || value_6 >= (int64_t)(value_5).length) {
|
|
value_3 = 0;
|
|
goto value_4;
|
|
}
|
|
value_3 = (uint8_t)value_5.data[value_6];
|
|
value_4: ;
|
|
}
|
|
value_0 = (value_3 != 125);
|
|
}
|
|
bool value_7 = value_0;
|
|
if (!value_7) {
|
|
bool value_8 = source_LooksLikeProcedureHeader(source);
|
|
value_7 = !value_8;
|
|
}
|
|
if (value_7) {
|
|
return block;
|
|
}
|
|
int32_t depth = 0;
|
|
int64_t at = opening;
|
|
while (at < (int64_t)(source).length) {
|
|
uint8_t byte = (uint8_t)source.data[at];
|
|
if (byte == 34 || byte == 39) {
|
|
at = source_AfterQuote(source, at);
|
|
continue;
|
|
}
|
|
if (byte == 123) {
|
|
depth = (int32_t)((uint32_t)depth + 1u);
|
|
} else if (byte == 125) {
|
|
depth = (int32_t)((uint32_t)depth - 1u);
|
|
if (depth < 0 || (depth == 0 && at != (int64_t)((uint64_t)((int64_t)(source).length) - UINT64_C(1)))) {
|
|
return block;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (depth != 0) {
|
|
return block;
|
|
}
|
|
return (ControlBlock){.valid = true, .head_end = (int64_t)((uint64_t)opening + UINT64_C(1)), .body_begin = (int64_t)((uint64_t)opening + UINT64_C(1)), .body_end = (int64_t)((uint64_t)((int64_t)(source).length) - UINT64_C(1)), .tail_begin = (int64_t)(source).length, .open = false};
|
|
}
|
|
|
|
MustUseModifier
|
|
source_ProcedureMustUse(String source, String result_type)
|
|
{
|
|
int64_t opening = source_Find(source, StringLiteral("("));
|
|
if (opening < 0LL) {
|
|
return MustUseModifier_None;
|
|
}
|
|
int64_t closing = source_ClosingParenthesis(StringRangeAt(source, (int64_t)opening, (int64_t)source.length));
|
|
if (closing < 0LL) {
|
|
return MustUseModifier_None;
|
|
}
|
|
closing = (int64_t)((uint64_t)closing + (uint64_t)opening);
|
|
String tail = StringRangeAt(source, (int64_t)((int64_t)((uint64_t)closing + UINT64_C(1))), (int64_t)source.length);
|
|
int64_t end = source_Find(tail, StringLiteral("{"));
|
|
if (end < 0LL) {
|
|
end = source_Find(tail, StringLiteral(";"));
|
|
}
|
|
if (end < 0LL) {
|
|
end = (int64_t)(tail).length;
|
|
}
|
|
int32_t count = 0;
|
|
int64_t at = 0LL;
|
|
while (at < end) {
|
|
if ((uint8_t)tail.data[at] == 34) {
|
|
at = source_AfterQuote(StringRangeAt(tail, (int64_t)0LL, (int64_t)end), at);
|
|
} else {
|
|
String value_0 = StringRangeAt(tail, (int64_t)0LL, (int64_t)end);
|
|
int64_t value_1 = at;
|
|
String value_2 = StringLiteral("#must");
|
|
bool value_3 = false;
|
|
{
|
|
String value_5 = value_0;
|
|
int64_t value_6 = value_1;
|
|
String value_7 = value_2;
|
|
bool value_8 = value_6 >= 0LL && value_6 <= (int64_t)(value_5).length && (int64_t)(value_7).length <= (int64_t)((uint64_t)((int64_t)(value_5).length) - (uint64_t)value_6);
|
|
value_3 = value_8 && StringEqual(StringRangeAt(value_5, (int64_t)value_6, (int64_t)((int64_t)((uint64_t)value_6 + (uint64_t)((int64_t)(value_7).length)))), value_7);
|
|
}
|
|
bool value_9 = value_3;
|
|
if (value_9) {
|
|
int64_t value_10 = (int64_t)((uint64_t)at + UINT64_C(5));
|
|
uint8_t value_11 = 0;
|
|
{
|
|
String value_13 = tail;
|
|
int64_t value_14 = value_10;
|
|
if (value_14 < 0LL || value_14 >= (int64_t)(value_13).length) {
|
|
value_11 = 0;
|
|
goto value_12;
|
|
}
|
|
value_11 = (uint8_t)value_13.data[value_14];
|
|
value_12: ;
|
|
}
|
|
bool value_15 = false;
|
|
{
|
|
uint8_t value_17 = value_11;
|
|
bool value_18 = false;
|
|
{
|
|
uint8_t value_20 = value_17;
|
|
value_18 = (value_20 >= 65 && value_20 <= 90) || (value_20 >= 97 && value_20 <= 122) || value_20 == 95;
|
|
}
|
|
value_15 = value_18 || (value_17 >= 48 && value_17 <= 57);
|
|
}
|
|
value_9 = !value_15;
|
|
}
|
|
if (value_9) {
|
|
int64_t after = source_SkipSpace(tail, (int64_t)((uint64_t)at + UINT64_C(5)));
|
|
if (after < end && (uint8_t)tail.data[after] != 35) {
|
|
return MustUseModifier_Arguments;
|
|
}
|
|
count = (int32_t)((uint32_t)count + 1u);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(5));
|
|
} else {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
if (count > 1) {
|
|
return MustUseModifier_Duplicate;
|
|
}
|
|
if (count == 0) {
|
|
return MustUseModifier_None;
|
|
}
|
|
if (StringEqual(result_type, StringLiteral("void"))) {
|
|
return MustUseModifier_NoResult;
|
|
}
|
|
return MustUseModifier_Required;
|
|
}
|
|
|
|
InliningModifier
|
|
source_ProcedureInlining(String source)
|
|
{
|
|
int64_t opening = source_Find(source, StringLiteral("("));
|
|
if (opening < 0LL) {
|
|
return InliningModifier_None;
|
|
}
|
|
int64_t closing = source_ClosingParenthesis(StringRangeAt(source, (int64_t)opening, (int64_t)source.length));
|
|
if (closing < 0LL) {
|
|
return InliningModifier_None;
|
|
}
|
|
closing = (int64_t)((uint64_t)closing + (uint64_t)opening);
|
|
String tail = StringRangeAt(source, (int64_t)((int64_t)((uint64_t)closing + UINT64_C(1))), (int64_t)source.length);
|
|
int64_t end = source_Find(tail, StringLiteral("{"));
|
|
if (end < 0LL) {
|
|
end = source_Find(tail, StringLiteral(";"));
|
|
}
|
|
if (end < 0LL) {
|
|
end = (int64_t)(tail).length;
|
|
}
|
|
String head = StringRangeAt(tail, (int64_t)0LL, (int64_t)end);
|
|
int32_t ziran_keyword_inline_0 = 0;
|
|
int32_t cold = 0;
|
|
int64_t at = 0LL;
|
|
while (at < end) {
|
|
int64_t length = 0LL;
|
|
int64_t value_0 = at;
|
|
String value_1 = StringLiteral("#inline");
|
|
bool value_2 = false;
|
|
{
|
|
String value_4 = head;
|
|
int64_t value_5 = value_0;
|
|
String value_6 = value_1;
|
|
bool value_7 = value_5 >= 0LL && value_5 <= (int64_t)(value_4).length && (int64_t)(value_6).length <= (int64_t)((uint64_t)((int64_t)(value_4).length) - (uint64_t)value_5);
|
|
value_2 = value_7 && StringEqual(StringRangeAt(value_4, (int64_t)value_5, (int64_t)((int64_t)((uint64_t)value_5 + (uint64_t)((int64_t)(value_6).length)))), value_6);
|
|
}
|
|
if (value_2) {
|
|
length = 7LL;
|
|
} else {
|
|
int64_t value_8 = at;
|
|
String value_9 = StringLiteral("#cold");
|
|
bool value_10 = false;
|
|
{
|
|
String value_12 = head;
|
|
int64_t value_13 = value_8;
|
|
String value_14 = value_9;
|
|
bool value_15 = value_13 >= 0LL && value_13 <= (int64_t)(value_12).length && (int64_t)(value_14).length <= (int64_t)((uint64_t)((int64_t)(value_12).length) - (uint64_t)value_13);
|
|
value_10 = value_15 && StringEqual(StringRangeAt(value_12, (int64_t)value_13, (int64_t)((int64_t)((uint64_t)value_13 + (uint64_t)((int64_t)(value_14).length)))), value_14);
|
|
}
|
|
if (value_10) {
|
|
length = 5LL;
|
|
}
|
|
}
|
|
if ((uint8_t)tail.data[at] == 34) {
|
|
at = source_AfterQuote(head, at);
|
|
} else {
|
|
bool value_16 = length > 0LL;
|
|
if (value_16) {
|
|
int64_t value_17 = (int64_t)((uint64_t)at + (uint64_t)length);
|
|
uint8_t value_18 = 0;
|
|
{
|
|
String value_20 = head;
|
|
int64_t value_21 = value_17;
|
|
if (value_21 < 0LL || value_21 >= (int64_t)(value_20).length) {
|
|
value_18 = 0;
|
|
goto value_19;
|
|
}
|
|
value_18 = (uint8_t)value_20.data[value_21];
|
|
value_19: ;
|
|
}
|
|
bool value_22 = false;
|
|
{
|
|
uint8_t value_24 = value_18;
|
|
bool value_25 = false;
|
|
{
|
|
uint8_t value_27 = value_24;
|
|
value_25 = (value_27 >= 65 && value_27 <= 90) || (value_27 >= 97 && value_27 <= 122) || value_27 == 95;
|
|
}
|
|
value_22 = value_25 || (value_24 >= 48 && value_24 <= 57);
|
|
}
|
|
value_16 = !value_22;
|
|
}
|
|
if (value_16) {
|
|
int64_t after = source_SkipSpace(head, (int64_t)((uint64_t)at + (uint64_t)length));
|
|
if (after < end && (uint8_t)head.data[after] != 35) {
|
|
return InliningModifier_Arguments;
|
|
}
|
|
if (length == 7LL) {
|
|
ziran_keyword_inline_0 = (int32_t)((uint32_t)ziran_keyword_inline_0 + 1u);
|
|
} else {
|
|
cold = (int32_t)((uint32_t)cold + 1u);
|
|
}
|
|
at = (int64_t)((uint64_t)at + (uint64_t)length);
|
|
} else {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
if (ziran_keyword_inline_0 > 0 && cold > 0) {
|
|
return InliningModifier_Both;
|
|
}
|
|
if (ziran_keyword_inline_0 > 1 || cold > 1) {
|
|
return InliningModifier_Duplicate;
|
|
}
|
|
if (ziran_keyword_inline_0 == 1) {
|
|
return InliningModifier_Inline;
|
|
}
|
|
if (cold == 1) {
|
|
return InliningModifier_Cold;
|
|
}
|
|
return InliningModifier_None;
|
|
}
|
|
|
|
TargetModifier
|
|
source_ProcedureTarget(String source)
|
|
{
|
|
int64_t opening = source_Find(source, StringLiteral("("));
|
|
if (opening < 0LL) {
|
|
return TargetModifier_None;
|
|
}
|
|
int64_t closing = source_ClosingParenthesis(StringRangeAt(source, (int64_t)opening, (int64_t)source.length));
|
|
if (closing < 0LL) {
|
|
return TargetModifier_None;
|
|
}
|
|
closing = (int64_t)((uint64_t)closing + (uint64_t)opening);
|
|
String tail = StringRangeAt(source, (int64_t)((int64_t)((uint64_t)closing + UINT64_C(1))), (int64_t)source.length);
|
|
int64_t end = source_Find(tail, StringLiteral("{"));
|
|
if (end < 0LL) {
|
|
end = source_Find(tail, StringLiteral(";"));
|
|
}
|
|
if (end < 0LL) {
|
|
end = (int64_t)(tail).length;
|
|
}
|
|
String head = StringRangeAt(tail, (int64_t)0LL, (int64_t)end);
|
|
int32_t count = 0;
|
|
int64_t at = 0LL;
|
|
while (at < end) {
|
|
if ((uint8_t)head.data[at] == 34) {
|
|
at = source_AfterQuote(head, at);
|
|
} else {
|
|
int64_t value_0 = at;
|
|
String value_1 = StringLiteral("#target");
|
|
bool value_2 = false;
|
|
{
|
|
String value_4 = head;
|
|
int64_t value_5 = value_0;
|
|
String value_6 = value_1;
|
|
bool value_7 = value_5 >= 0LL && value_5 <= (int64_t)(value_4).length && (int64_t)(value_6).length <= (int64_t)((uint64_t)((int64_t)(value_4).length) - (uint64_t)value_5);
|
|
value_2 = value_7 && StringEqual(StringRangeAt(value_4, (int64_t)value_5, (int64_t)((int64_t)((uint64_t)value_5 + (uint64_t)((int64_t)(value_6).length)))), value_6);
|
|
}
|
|
bool value_8 = value_2;
|
|
if (value_8) {
|
|
int64_t value_9 = (int64_t)((uint64_t)at + UINT64_C(7));
|
|
uint8_t value_10 = 0;
|
|
{
|
|
String value_12 = head;
|
|
int64_t value_13 = value_9;
|
|
if (value_13 < 0LL || value_13 >= (int64_t)(value_12).length) {
|
|
value_10 = 0;
|
|
goto value_11;
|
|
}
|
|
value_10 = (uint8_t)value_12.data[value_13];
|
|
value_11: ;
|
|
}
|
|
bool value_14 = false;
|
|
{
|
|
uint8_t value_16 = value_10;
|
|
bool value_17 = false;
|
|
{
|
|
uint8_t value_19 = value_16;
|
|
value_17 = (value_19 >= 65 && value_19 <= 90) || (value_19 >= 97 && value_19 <= 122) || value_19 == 95;
|
|
}
|
|
value_14 = value_17 || (value_16 >= 48 && value_16 <= 57);
|
|
}
|
|
value_8 = !value_14;
|
|
}
|
|
if (value_8) {
|
|
int64_t after = source_SkipSpace(head, (int64_t)((uint64_t)at + UINT64_C(7)));
|
|
if (after < end && (uint8_t)head.data[after] != 35) {
|
|
return TargetModifier_Arguments;
|
|
}
|
|
count = (int32_t)((uint32_t)count + 1u);
|
|
at = (int64_t)((uint64_t)at + UINT64_C(7));
|
|
} else {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
if (count > 1) {
|
|
return TargetModifier_Duplicate;
|
|
}
|
|
if (count == 1) {
|
|
return TargetModifier_Target;
|
|
}
|
|
return TargetModifier_None;
|
|
}
|