src/parser.c
// Parses an int32_t into the forward positions
Parses an int32_t into the forward positions
Parses an int32_t into the forward positions
bool _TryGet_int32_t(Parser_t * Parser, int32_t * ReturnValue) {
    char CurrentChar = _ThisChar(Parser);
    int32_t ParserStartIndex = Parser -> Cursor;
    uint32_t IntegerStringLength = 0;
    while ('0' <= CurrentChar && CurrentChar <= '9') {
        IntegerStringLength++;
        if (true == _HasNextChar(Parser)) {
            CurrentChar = _NextChar(Parser);
        } else {
            break;
        }
    }
    uint32_t PowerMultiplier = 1;
    int32_t Int32Result = 0;
    int32_t CurrentIndex = Parser -> Cursor;
    while (ParserStartIndex <= CurrentIndex) {
        char CharValue = Parser -> String[CurrentIndex];
        int32_t IntValue = CharValue - '0';
        Int32Result += IntValue * PowerMultiplier;
        PowerMultiplier *= 10;
        CurrentIndex--;
    }
    * ReturnValue = Int32Result;
    return true;
}
bool _TryGet_int32_t ( Parser_t * Parser , int32_t * ReturnValue ) { char CurrentChar = _ThisChar ( Parser ) ; int32_t ParserStartIndex = Parser -> Cursor ; uint32_t IntegerStringLength = 0 ; while ( ' ' <= CurrentChar && CurrentChar <= ' ' ) { IntegerStringLength ++ ; if ( true == _HasNextChar ( Parser ) ) { CurrentChar = _NextChar ( Parser ) ; } else { break ; } } uint32_t PowerMultiplier = 1 ; int32_t Int32Result = 0 ; int32_t CurrentIndex = Parser -> Cursor ; while ( ParserStartIndex <= CurrentIndex ) { char CharValue = Parser -> String [ CurrentIndex ] ; int32_t IntValue = CharValue - ' ' ; Int32Result += IntValue * PowerMultiplier ; PowerMultiplier *= 10 ; CurrentIndex -- ; } * ReturnValue = Int32Result ; return true ; }
Parses an int32_t into the forward positions
Parses an int32_t into the forward positions
// Save this index for later // Find the length of the integer string // Now compute the value going backwards