/* Generated by Nim Compiler v1.6.10 */
#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__jTxk7Uc2dfr9aTDL2dZhO9ag tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag;
typedef struct RootObj RootObj;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g;
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
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__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ 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__jTxk7Uc2dfr9aTDL2dZhO9ag {
  RootObj Sup;
NI bufpos;
NCSTRING buf;
NimStringDesc* bufStorage;
NI bufLen;
tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g* stream;
NI lineNumber;
NI sentinel;
NI lineStart;
NI offsetBase;
};
typedef NU8 tyEnum_TLLStreamKind__jVcKY16LbOamXE9bxXUD6pQ;
typedef struct {
N_NIMCALL_PTR(NI, ClP_0) (tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g* s, void* buf, NI bufLen, void* ClE_0);
void* ClE_0;
} tyProc__9cZV5JMJLsdOPMv55VbpOVg;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (void* ClE_0);
void* ClE_0;
} tyProc__HzVCwACFYM9cx9aV62PdjtuA;
struct tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g {
  RootObj Sup;
tyEnum_TLLStreamKind__jVcKY16LbOamXE9bxXUD6pQ kind;
FILE* f;
NimStringDesc* s;
NI rd;
NI wr;
NI lineOffset;
tyProc__9cZV5JMJLsdOPMv55VbpOVg 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__jTxk7Uc2dfr9aTDL2dZhO9ag* L);
static N_INLINE(void, moveMem__system_1731)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(NI, llStreamRead__llstream_177)(tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* L);
N_LIB_PRIVATE N_NIMCALL(NI, fillBaseLexer__nimlexbase_75)(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag* L, NI pos);
N_LIB_PRIVATE N_NIMCALL(void, llStreamClose__llstream_110)(tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g* s);
extern TNimType NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_;
N_LIB_PRIVATE TNimType NTItbaselexer__jTxk7Uc2dfr9aTDL2dZhO9ag_;
extern TNimType NTIint__rR5Bzr1D5krxoo1NcNyeMA_;
extern TNimType NTIcstring__S9agCYBinaYZnGWcjTdxclg_;
extern TNimType NTIstring__77mFvmsOLKik79ci2hXkHEg_;
extern TNimType NTIpllstream__WO3j4yVQ0yN0aRCt9bFEbtg_;
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_1731)(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__jTxk7Uc2dfr9aTDL2dZhO9ag* 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_1731(((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__jTxk7Uc2dfr9aTDL2dZhO9ag* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* L, tyObject_TLLStream__a5oZYQ9aTktYME2449ayEi6g* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* 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__jTxk7Uc2dfr9aTDL2dZhO9ag* L) {
	llStreamClose__llstream_110((*L).stream);
}
N_LIB_PRIVATE N_NIMCALL(void, atmnimlexbasedotnim_DatInit000)(void) {
static TNimNode* TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[9];
static TNimNode TM__jNFaG9cOzyJSKBcIonhGRGw_0[10];
NTItbaselexer__jTxk7Uc2dfr9aTDL2dZhO9ag_.size = sizeof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag);
NTItbaselexer__jTxk7Uc2dfr9aTDL2dZhO9ag_.align = NIM_ALIGNOF(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag);
NTItbaselexer__jTxk7Uc2dfr9aTDL2dZhO9ag_.kind = 17;
NTItbaselexer__jTxk7Uc2dfr9aTDL2dZhO9ag_.base = (&NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_);
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[0] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[1];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[1].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[1].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, bufpos);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[1].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[1].name = "bufpos";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[1] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[2];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[2].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[2].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, buf);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[2].typ = (&NTIcstring__S9agCYBinaYZnGWcjTdxclg_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[2].name = "buf";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[2] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[3];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[3].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[3].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, bufStorage);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[3].typ = (&NTIstring__77mFvmsOLKik79ci2hXkHEg_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[3].name = "bufStorage";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[3] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[4];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[4].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[4].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, bufLen);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[4].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[4].name = "bufLen";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[4] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[5];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[5].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[5].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, stream);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[5].typ = (&NTIpllstream__WO3j4yVQ0yN0aRCt9bFEbtg_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[5].name = "stream";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[5] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[6];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[6].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[6].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, lineNumber);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[6].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[6].name = "lineNumber";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[6] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[7];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[7].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[7].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, sentinel);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[7].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[7].name = "sentinel";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[7] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[8];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[8].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[8].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, lineStart);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[8].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[8].name = "lineStart";
TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[8] = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[9];
TM__jNFaG9cOzyJSKBcIonhGRGw_0[9].kind = 1;
TM__jNFaG9cOzyJSKBcIonhGRGw_0[9].offset = offsetof(tyObject_TBaseLexer__jTxk7Uc2dfr9aTDL2dZhO9ag, offsetBase);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[9].typ = (&NTIint__rR5Bzr1D5krxoo1NcNyeMA_);
TM__jNFaG9cOzyJSKBcIonhGRGw_0[9].name = "offsetBase";
TM__jNFaG9cOzyJSKBcIonhGRGw_0[0].len = 9; TM__jNFaG9cOzyJSKBcIonhGRGw_0[0].kind = 2; TM__jNFaG9cOzyJSKBcIonhGRGw_0[0].sons = &TM__jNFaG9cOzyJSKBcIonhGRGw_2_9[0];
NTItbaselexer__jTxk7Uc2dfr9aTDL2dZhO9ag_.node = &TM__jNFaG9cOzyJSKBcIonhGRGw_0[0];
}

