/* Generated by Nim Compiler v1.6.14 */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <string.h>
#include <stdio.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
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ;
typedef struct RootObj RootObj;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg;
typedef NU8 tyEnum_TNimKind__pspQAsqJLrw3jEKBD9bxmyQ;
typedef NU8 tySet_tyEnum_TNimTypeFlag__Yt5hq6z2IoHhKZrzIVrc1w;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
NI align;
tyEnum_TNimKind__pspQAsqJLrw3jEKBD9bxmyQ kind;
tySet_tyEnum_TNimTypeFlag__Yt5hq6z2IoHhKZrzIVrc1w flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__rrp49bl1h9aEkXfXp9bNg0yZw;
struct TNimNode {
tyEnum_TNimNodeKind__rrp49bl1h9aEkXfXp9bNg0yZw kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct RootObj {
TNimType* m_type;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ {
  RootObj Sup;
NI bufpos;
NCSTRING buf;
NimStringDesc* bufStorage;
NI bufLen;
tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg* stream;
NI lineNumber;
NI sentinel;
NI lineStart;
NI offsetBase;
};
typedef NU8 tyEnum_TLLStreamKind__ChicJ77mD7SkMUxz402udA;
typedef struct {
N_NIMCALL_PTR(NI, ClP_0) (tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg* s, void* buf, NI bufLen, void* ClE_0);
void* ClE_0;
} tyProc__M3d9crIwWf7vcamB5Yms8GQ;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (void* ClE_0);
void* ClE_0;
} tyProc__HzVCwACFYM9cx9aV62PdjtuA;
struct tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg {
  RootObj Sup;
tyEnum_TLLStreamKind__ChicJ77mD7SkMUxz402udA kind;
FILE* f;
NimStringDesc* s;
NI rd;
NI wr;
NI lineOffset;
tyProc__M3d9crIwWf7vcamB5Yms8GQ repl;
tyProc__HzVCwACFYM9cx9aV62PdjtuA onPrompt;
};
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_LIB_PRIVATE N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s);
N_LIB_PRIVATE N_NIMCALL(void, fillBuffer__nimlexbase_45)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L);
static N_INLINE(void, moveMem__system_1737)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(NI, llStreamRead__llstream_177)(tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg* s, void* buf, NI bufLen);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
N_LIB_PRIVATE N_NIMCALL(void, skipUTF8BOM__nimlexbase_108)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L);
N_LIB_PRIVATE N_NIMCALL(NI, fillBaseLexer__nimlexbase_75)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L, NI pos);
N_LIB_PRIVATE N_NIMCALL(void, llStreamClose__llstream_110)(tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg* s);
extern TNimType NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_;
N_LIB_PRIVATE TNimType NTItbaselexer__nATxPlDiRTsKxaL2wN88sQ_;
extern TNimType NTIint__rR5Bzr1D5krxoo1NcNyeMA_;
extern TNimType NTIcstring__S9agCYBinaYZnGWcjTdxclg_;
extern TNimType NTIstring__77mFvmsOLKik79ci2hXkHEg_;
extern TNimType NTIpllstream__SsgpDxDUYERcJKu2LMHotQ_;
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s) {
	NCSTRING result;
	result = (NCSTRING)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (s == ((NimStringDesc*) NIM_NIL));
		if (T3_) goto LA4_;
		T3_ = ((*s).Sup.len == ((NI) 0));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = "";
	}
	goto LA1_;
	LA5_: ;
	{
		result = ((NCSTRING) ((*s).data));
	}
	LA1_: ;
	return result;
}
static N_INLINE(void, moveMem__system_1737)(void* dest, void* source, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memmove(dest, source, ((size_t) (size)));
}
N_LIB_PRIVATE N_NIMCALL(void, fillBuffer__nimlexbase_45)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L) {
	NI charsRead;
	NI toCopy;
	NI s;
	NI oldBufLen;
	charsRead = (NI)0;
	toCopy = (NI)0;
	s = (NI)0;
	oldBufLen = (NI)0;
	toCopy = (NI)((NI)((*L).bufLen - (*L).sentinel) - ((NI) 1));
	{
		if (!(((NI) 0) < toCopy)) goto LA3_;
		moveMem__system_1737(((void*) ((&(*L).buf[((NI) 0)]))), ((void*) ((&(*L).buf[(NI)((*L).sentinel + ((NI) 1))]))), ((NI) (toCopy)));
	}
	LA3_: ;
	charsRead = llStreamRead__llstream_177((*L).stream, ((void*) ((&(*L).buf[toCopy]))), (NI)((*L).sentinel + ((NI) 1)));
	s = (NI)(toCopy + charsRead);
	{
		if (!(charsRead < (NI)((*L).sentinel + ((NI) 1)))) goto LA7_;
		(*L).buf[s] = 0;
		(*L).sentinel = s;
	}
	goto LA5_;
	LA7_: ;
	{
		s -= ((NI) 1);
		{
			while (1) {
				{
					while (1) {
						NIM_BOOL T14_;
						T14_ = (NIM_BOOL)0;
						T14_ = (((NI) 0) <= s);
						if (!(T14_)) goto LA15_;
						T14_ = !((((NU8)((*L).buf[s])) == ((NU8)(13)) || ((NU8)((*L).buf[s])) == ((NU8)(10))));
						LA15_: ;
						if (!T14_) goto LA13;
						s -= ((NI) 1);
					} LA13: ;
				}
				{
					if (!(((NI) 0) <= s)) goto LA18_;
					(*L).sentinel = s;
					goto LA10;
				}
				goto LA16_;
				LA18_: ;
				{
					oldBufLen = (*L).bufLen;
					(*L).bufLen = (NI)((*L).bufLen * ((NI) 2));
					unsureAsgnRef((void**) (&(*L).bufStorage), setLengthStr((*L).bufStorage, ((NI) ((*L).bufLen))));
					(*L).buf = nimToCStringConv((*L).bufStorage);
					charsRead = llStreamRead__llstream_177((*L).stream, ((void*) ((&(*L).buf[oldBufLen]))), oldBufLen);
					{
						if (!(charsRead < oldBufLen)) goto LA23_;
						(*L).buf[(NI)(oldBufLen + charsRead)] = 0;
						(*L).sentinel = (NI)(oldBufLen + charsRead);
						goto LA10;
					}
					LA23_: ;
					s = (NI)((*L).bufLen - ((NI) 1));
				}
				LA16_: ;
			}
		} LA10: ;
	}
	LA5_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, skipUTF8BOM__nimlexbase_108)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L) {
	{
		NIM_BOOL T3_;
		NIM_BOOL T4_;
		T3_ = (NIM_BOOL)0;
		T4_ = (NIM_BOOL)0;
		T4_ = ((NU8)((*L).buf[((NI) 0)]) == (NU8)(239));
		if (!(T4_)) goto LA5_;
		T4_ = ((NU8)((*L).buf[((NI) 1)]) == (NU8)(187));
		LA5_: ;
		T3_ = T4_;
		if (!(T3_)) goto LA6_;
		T3_ = ((NU8)((*L).buf[((NI) 2)]) == (NU8)(191));
		LA6_: ;
		if (!T3_) goto LA7_;
		(*L).bufpos += ((NI) 3);
		(*L).lineStart += ((NI) 3);
	}
	LA7_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, openBaseLexer__nimlexbase_25)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L, tyObject_TLLStream__7Xg7qwR6egjB3ej43ivLqg* inputstream, NI bufLen) {
	(*L).bufpos = ((NI) 0);
	(*L).offsetBase = ((NI) 0);
	unsureAsgnRef((void**) (&(*L).bufStorage), mnewString(((NI) (bufLen))));
	(*L).buf = nimToCStringConv((*L).bufStorage);
	(*L).bufLen = bufLen;
	(*L).sentinel = (NI)(bufLen - ((NI) 1));
	(*L).lineStart = ((NI) 0);
	(*L).lineNumber = ((NI) 1);
	unsureAsgnRef((void**) (&(*L).stream), inputstream);
	fillBuffer__nimlexbase_45(L);
	skipUTF8BOM__nimlexbase_108(L);
}
N_LIB_PRIVATE N_NIMCALL(NI, getColNumber__nimlexbase_34)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L, NI pos) {
	NI result;
	result = (NI)0;
	result = ((NI)(pos - (*L).lineStart) > 0? ((NI)(pos - (*L).lineStart)) : -((NI)(pos - (*L).lineStart)));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fillBaseLexer__nimlexbase_75)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L, NI pos) {
	NI result;
	result = (NI)0;
	{
		if (!(pos < (*L).sentinel)) goto LA3_;
		result = (NI)(pos + ((NI) 1));
	}
	goto LA1_;
	LA3_: ;
	{
		fillBuffer__nimlexbase_45(L);
		(*L).offsetBase += (NI)(pos + ((NI) 1));
		(*L).bufpos = ((NI) 0);
		result = ((NI) 0);
	}
	LA1_: ;
	(*L).lineStart = result;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, handleCR__nimlexbase_37)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L, NI pos) {
	NI result;
	result = (NI)0;
	(*L).lineNumber += ((NI) 1);
	result = fillBaseLexer__nimlexbase_75(L, pos);
	{
		if (!((NU8)((*L).buf[result]) == (NU8)(10))) goto LA3_;
		result = fillBaseLexer__nimlexbase_75(L, result);
	}
	LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, handleLF__nimlexbase_40)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L, NI pos) {
	NI result;
	result = (NI)0;
	(*L).lineNumber += ((NI) 1);
	result = fillBaseLexer__nimlexbase_75(L, pos);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, closeBaseLexer__nimlexbase_29)(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ* L) {
	llStreamClose__llstream_110((*L).stream);
}
N_LIB_PRIVATE N_NIMCALL(void, atmnimlexbasedotnim_DatInit000)(void) {
static TNimNode* TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[9];
static TNimNode TM__rZFvJ0pPfPjkF5gMPj0ilw_0[10];
NTItbaselexer__nATxPlDiRTsKxaL2wN88sQ_.size = sizeof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ);
NTItbaselexer__nATxPlDiRTsKxaL2wN88sQ_.align = NIM_ALIGNOF(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ);
NTItbaselexer__nATxPlDiRTsKxaL2wN88sQ_.kind = 17;
NTItbaselexer__nATxPlDiRTsKxaL2wN88sQ_.base = (&NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[0] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[1];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[1].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[1].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, bufpos);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[1].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[1].name = "bufpos";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[1] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[2];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[2].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[2].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, buf);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[2].typ = (&NTIcstring__S9agCYBinaYZnGWcjTdxclg_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[2].name = "buf";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[2] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[3];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[3].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[3].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, bufStorage);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[3].typ = (&NTIstring__77mFvmsOLKik79ci2hXkHEg_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[3].name = "bufStorage";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[3] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[4];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[4].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[4].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, bufLen);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[4].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[4].name = "bufLen";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[4] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[5];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[5].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[5].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, stream);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[5].typ = (&NTIpllstream__SsgpDxDUYERcJKu2LMHotQ_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[5].name = "stream";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[5] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[6];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[6].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[6].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, lineNumber);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[6].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[6].name = "lineNumber";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[6] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[7];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[7].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[7].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, sentinel);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[7].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[7].name = "sentinel";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[7] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[8];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[8].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[8].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, lineStart);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[8].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[8].name = "lineStart";
TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[8] = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[9];
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[9].kind = 1;
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[9].offset = offsetof(tyObject_TBaseLexer__nATxPlDiRTsKxaL2wN88sQ, offsetBase);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[9].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[9].name = "offsetBase";
TM__rZFvJ0pPfPjkF5gMPj0ilw_0[0].len = 9; TM__rZFvJ0pPfPjkF5gMPj0ilw_0[0].kind = 2; TM__rZFvJ0pPfPjkF5gMPj0ilw_0[0].sons = &TM__rZFvJ0pPfPjkF5gMPj0ilw_2_9[0];
NTItbaselexer__nATxPlDiRTsKxaL2wN88sQ_.node = &TM__rZFvJ0pPfPjkF5gMPj0ilw_0[0];
}

