1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
/* Generated by Nim Compiler v2.2.0 */
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
typedef struct tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw;
typedef struct tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct TNimTypeV2 {
void* destructor;
NI size;
NI16 align;
NI16 depth;
NU32* display;
void* traceImpl;
void* typeInfoV1;
NI flags;
void* vTable[SEQ_DECL_SIZE];
};
struct RootObj {
TNimTypeV2* m_type;
};
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw {
RootObj Sup;
NI bufpos;
NCSTRING buf;
NimStringV2 bufStorage;
NI bufLen;
tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* stream;
NI lineNumber;
NI sentinel;
NI lineStart;
NI offsetBase;
};
N_LIB_PRIVATE N_NIMCALL(void, eqsink___system_u2606)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_NIMCALL(NimStringV2, mnewString)(NI len_p0);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___llstream_u114)(tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg** dest_p0, tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* src_p1, NIM_BOOL cyclic_p2);
N_LIB_PRIVATE N_NIMCALL(void, fillBuffer__nimlexbase_u46)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0);
static N_INLINE(void, moveMem__system_u1717)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NIMCALL(NI, llStreamRead__llstream_u287)(tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* s_p0, void* buf_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(void, setLengthStrV2)(NimStringV2* s_p0, NI newLen_p1);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, skipUTF8BOM__nimlexbase_u113)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0);
N_LIB_PRIVATE N_NIMCALL(NI, fillBaseLexer__nimlexbase_u78)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0, NI pos_p1);
N_LIB_PRIVATE N_NIMCALL(void, llStreamClose__llstream_u213)(tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* s_p0);
extern NIM_BOOL nimInErrorMode__system_u4310;
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0) {
NCSTRING result;
{
if (!(s_p0.len == ((NI)0))) goto LA3_;
result = "";
}
goto LA1_;
LA3_: ;
{
result = ((NCSTRING) ((*s_p0.p).data));
}
LA1_: ;
return result;
}
static N_INLINE(void, moveMem__system_u1717)(void* dest_p0, void* source_p1, NI size_p2) {
void* T1_;
T1_ = (void*)0;
T1_ = memmove(dest_p0, source_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (&nimInErrorMode__system_u4310);
return result;
}
N_LIB_PRIVATE N_NIMCALL(void, fillBuffer__nimlexbase_u46)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0) {
NI charsRead;
NI toCopy;
NI s;
NI oldBufLen;
tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* T6_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
charsRead = (NI)0;
toCopy = (NI)0;
s = (NI)0;
oldBufLen = (NI)0;
toCopy = (NI)((NI)((*L_p0).bufLen - (*L_p0).sentinel) - ((NI)1));
{
void* T5_;
if (!(((NI)0) < toCopy)) goto LA3_;
T5_ = (void*)0;
T5_ = ((void*) ((&(*L_p0).buf[((NI)0)])));
moveMem__system_u1717(T5_, ((void*) ((&(*L_p0).buf[(NI)((*L_p0).sentinel + ((NI)1))]))), (toCopy));
}
LA3_: ;
T6_ = NIM_NIL;
T6_ = (*L_p0).stream;
charsRead = llStreamRead__llstream_u287(T6_, ((void*) ((&(*L_p0).buf[toCopy]))), (NI)((*L_p0).sentinel + ((NI)1)));
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
s = (NI)(toCopy + charsRead);
{
if (!(charsRead < (NI)((*L_p0).sentinel + ((NI)1)))) goto LA9_;
(*L_p0).buf[s] = 0;
(*L_p0).sentinel = s;
}
goto LA7_;
LA9_: ;
{
s -= ((NI)1);
{
while (1) {
{
while (1) {
NIM_BOOL T16_;
T16_ = (NIM_BOOL)0;
T16_ = (((NI)0) <= s);
if (!(T16_)) goto LA17_;
T16_ = !((((NU8)((*L_p0).buf[s])) == ((NU8)(13)) || ((NU8)((*L_p0).buf[s])) == ((NU8)(10))));
LA17_: ;
if (!T16_) goto LA15;
s -= ((NI)1);
} LA15: ;
}
{
if (!(((NI)0) <= s)) goto LA20_;
(*L_p0).sentinel = s;
goto LA12;
}
goto LA18_;
LA20_: ;
{
tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* T23_;
oldBufLen = (*L_p0).bufLen;
(*L_p0).bufLen = (NI)((*L_p0).bufLen * ((NI)2));
setLengthStrV2((&(*L_p0).bufStorage), ((*L_p0).bufLen));
(*L_p0).buf = nimToCStringConv((*L_p0).bufStorage);
T23_ = NIM_NIL;
T23_ = (*L_p0).stream;
charsRead = llStreamRead__llstream_u287(T23_, ((void*) ((&(*L_p0).buf[oldBufLen]))), oldBufLen);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
{
if (!(charsRead < oldBufLen)) goto LA26_;
(*L_p0).buf[(NI)(oldBufLen + charsRead)] = 0;
(*L_p0).sentinel = (NI)(oldBufLen + charsRead);
goto LA12;
}
LA26_: ;
s = (NI)((*L_p0).bufLen - ((NI)1));
}
LA18_: ;
}
} LA12: ;
}
LA7_: ;
}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, skipUTF8BOM__nimlexbase_u113)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0) {
{
NIM_BOOL T3_;
NIM_BOOL T4_;
T3_ = (NIM_BOOL)0;
T4_ = (NIM_BOOL)0;
T4_ = ((NU8)((*L_p0).buf[((NI)0)]) == (NU8)(239));
if (!(T4_)) goto LA5_;
T4_ = ((NU8)((*L_p0).buf[((NI)1)]) == (NU8)(187));
LA5_: ;
T3_ = T4_;
if (!(T3_)) goto LA6_;
T3_ = ((NU8)((*L_p0).buf[((NI)2)]) == (NU8)(191));
LA6_: ;
if (!T3_) goto LA7_;
(*L_p0).bufpos += ((NI)3);
(*L_p0).lineStart += ((NI)3);
}
LA7_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, openBaseLexer__nimlexbase_u26)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0, tyObject_TLLStream__FoDsO8lsQbcCVaLehnuOYg* inputstream_p1, NI bufLen_p2) {
NimStringV2 T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
(*L_p0).bufpos = ((NI)0);
(*L_p0).offsetBase = ((NI)0);
T1_.len = 0; T1_.p = NIM_NIL;
T1_ = mnewString((bufLen_p2));
eqsink___system_u2606((&(*L_p0).bufStorage), T1_);
(*L_p0).buf = nimToCStringConv((*L_p0).bufStorage);
(*L_p0).bufLen = bufLen_p2;
(*L_p0).sentinel = (NI)(bufLen_p2 - ((NI)1));
(*L_p0).lineStart = ((NI)0);
(*L_p0).lineNumber = ((NI)1);
eqcopy___llstream_u114(&(*L_p0).stream, inputstream_p1, NIM_TRUE);
fillBuffer__nimlexbase_u46(L_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
skipUTF8BOM__nimlexbase_u113(L_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI, getColNumber__nimlexbase_u35)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0, NI pos_p1) {
NI result;
result = ((NI)(pos_p1 - (*L_p0).lineStart) > 0? ((NI)(pos_p1 - (*L_p0).lineStart)) : -((NI)(pos_p1 - (*L_p0).lineStart)));
return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fillBaseLexer__nimlexbase_u78)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0, NI pos_p1) {
NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
result = (NI)0;
{
if (!(pos_p1 < (*L_p0).sentinel)) goto LA3_;
result = (NI)(pos_p1 + ((NI)1));
}
goto LA1_;
LA3_: ;
{
fillBuffer__nimlexbase_u46(L_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
(*L_p0).offsetBase += (NI)(pos_p1 + ((NI)1));
(*L_p0).bufpos = ((NI)0);
result = ((NI)0);
}
LA1_: ;
(*L_p0).lineStart = result;
}BeforeRet_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, handleCR__nimlexbase_u38)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0, NI pos_p1) {
NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
result = (NI)0;
(*L_p0).lineNumber += ((NI)1);
result = fillBaseLexer__nimlexbase_u78(L_p0, pos_p1);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
{
if (!((NU8)((*L_p0).buf[result]) == (NU8)(10))) goto LA3_;
result = fillBaseLexer__nimlexbase_u78(L_p0, result);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}
LA3_: ;
}BeforeRet_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, handleLF__nimlexbase_u41)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0, NI pos_p1) {
NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
result = (NI)0;
(*L_p0).lineNumber += ((NI)1);
result = fillBaseLexer__nimlexbase_u78(L_p0, pos_p1);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}BeforeRet_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(void, closeBaseLexer__nimlexbase_u30)(tyObject_TBaseLexer__bW0Cb4KmUu6wcIZW6Cp0nw* L_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
llStreamClose__llstream_u213((*L_p0).stream);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}BeforeRet_: ;
}
|