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 |
import lexbase, critbits 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*: int of minFloat: floatVal*: float 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] MinParsingError* = ref object of ValueError MinUndefinedError* = ref object of ValueError MinRuntimeError* = ref object of SystemError qVal*: seq[MinValue] MinInterpreter* = object stack*: MinStack pwd*: string scope*: ref MinScope parser*: MinParser currSym*: MinValue filename*: string debugging*: bool evaluating*: bool unsafe*: bool In* = var MinInterpreter MinOperator* = proc (i: var MinInterpreter) MinSigil* = proc (i: var MinInterpreter, sym: string) MinError* = enum errSystem, errParser, errGeneric, errEmptyStack, errNoQuotation, errUndefined, errIncorrect, errRuntime, errTwoNumbersRequired, errDivisionByZero proc isNotNil*[T](obj: T): bool = return not obj.isNil |