core/types.nim
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 |
import lexbase, critbits, asyncdispatch, asynchttpserver type MinTokenKind* = enum tkError, tkEof, tkString, tkInt, tkFloat, tkBracketLe, tkBracketRi, tkSymbol, tkTrue, tkFalse MinKind* = enum minInt, minFloat, minQuotation, minString, minSymbol, minBool MinScope* = object symbols*: CritBitTree[MinOperator] sigils*: CritBitTree[MinOperator] parent*: ref MinScope name*: string stack*: MinStack MinValue* = object line*: int column*: int filename*: string case kind*: MinKind of minInt: intVal*: BiggestInt of minFloat: floatVal*: BiggestFloat of minQuotation: qVal*: seq[MinValue] scope*: ref MinScope of minString: strVal*: string of minSymbol: symVal*: string of minBool: boolVal*: bool MinEventKind* = enum ## enumeration of all events that may occur when parsing eMinError, ## an error ocurred during parsing eMinEof, ## end of file reached eMinString, ## a string literal eMinInt, ## an integer literal eMinFloat, ## a float literal eMinQuotationStart, ## start of an array: the ``(`` token eMinQuotationEnd ## start of an array: the ``)`` token MinParserError* = enum ## enumeration that lists all errors that can occur errNone, ## no error errInvalidToken, ## invalid token errStringExpected, ## string expected errBracketRiExpected, ## ``)`` expected errQuoteExpected, ## ``"`` or ``'`` expected errEOC_Expected, ## ``*/`` expected errEofExpected, ## EOF expected errExprExpected MinParserState* = enum stateEof, stateStart, stateQuotation, stateExpectValue MinParser* = object of BaseLexer a*: string token*: MinTokenKind state*: seq[MinParserState] kind*: MinEventKind err*: MinParserError filename*: string MinStack* = seq[MinValue] MinInterpreter* = object stack*: MinStack pwd*: string scope*: ref MinScope parser*: MinParser currSym*: MinValue filename*: string debugging*: bool evaluating*: bool unsafe*: bool link*: ref MinLink MinLink* = object hosts*: CritBitTree[string] name*: string address*: string port*: Port server*: AsyncHttpServer interpreter*: MinInterpreter In* = var MinInterpreter Val* = var MinValue MinOperator* = proc (i: In) {.gcsafe, closure.} MinSigil* = proc (i: In, sym: string) MinParsingError* = ref object of ValueError MinUndefinedError* = ref object of ValueError MinInvalidError* = ref object of ValueError MinEmptyStackError* = ref object of ValueError MinOutOfBoundsError* = ref object of ValueError MinServerError* = ref object of SystemError code*: HttpCode MinRuntimeError* = ref object of SystemError qVal*: seq[MinValue] proc isNotNil*[T](obj: T): bool = return not obj.isNil |