src/parser.c
// Evalutes the String and places the result in Result
Evalutes the String and places the result in Result
Evalutes the String and places the result in Result
void Parser_Evaluate(char * String, ParserResult_t * Result) {
    if (String == NULL || Result == NULL) {
        Result -> Success = false;
        Result -> Message = "String or Result is NULL";
        return;
    }
    uint32_t StringLength = strlen(String);
    if (0 == StringLength) {
        Result -> Success = false;
        Result -> Message = "Length of String is 0";
        return;
    }
    Parser_t Parser;
    Parser.String = String;
    Parser.StringLength = strlen(String);
    Parser.HasResult = false;
    Parser.Cursor = -1;
    Parser.Int32Result = 0;
    int32_t Int32Result = 0;
    bool ParseIsOkay = true;
    while (_HasNextChar( & Parser) && ParseIsOkay) {
        char CurrentChar = _NextChar( & Parser);
        if ('0' <= CurrentChar && CurrentChar <= '9') {
            int32_t IntValue;
            bool DidGetValue = _TryGet_int32_t( & Parser, & IntValue);
            if (DidGetValue) {
                Int32Result += IntValue;
            } else {
                ParseIsOkay = false;
            }
        } else if (CurrentChar == '-') {
        }
    }
    if (ParseIsOkay) {
        Result -> Success = true;
        Result -> Message = "Successfully evalutes to int32_t value.";
        Result -> Int32Result = Int32Result;
    } else {
        Result -> Success = true;
        Result -> Message = "Parser failed: unknown error";
        Result -> Int32Result = 0; 
    }
    Result -> Success = ParseIsOkay;
    return;
}
void Parser_Evaluate ( char * String , ParserResult_t * Result ) { if ( String == NULL || Result == NULL ) { Result -> Success = false ; Result -> Message = " " ; return ; } uint32_t StringLength = strlen ( String ) ; if ( 0 == StringLength ) { Result -> Success = false ; Result -> Message = " " ; return ; } Parser_t Parser ; Parser . String = String ; Parser . StringLength = strlen ( String ) ; Parser . HasResult = false ; Parser . Cursor = -1 ; Parser . Int32Result = 0 ; int32_t Int32Result = 0 ; bool ParseIsOkay = true ; while ( _HasNextChar ( & Parser ) && ParseIsOkay ) { char CurrentChar = _NextChar ( & Parser ) ; if ( ' ' <= CurrentChar && CurrentChar <= ' ' ) { int32_t IntValue ; bool DidGetValue = _TryGet_int32_t ( & Parser , & IntValue ) ; if ( DidGetValue ) { Int32Result += IntValue ; } else { ParseIsOkay = false ; } } else if ( CurrentChar == ' ' ) { } } if ( ParseIsOkay ) { Result -> Success = true ; Result -> Message = " " ; Result -> Int32Result = Int32Result ; } else { Result -> Success = true ; Result -> Message = " " ; Result -> Int32Result = 0 ; } Result -> Success = ParseIsOkay ; return ; }
Evalutes the String and places the result in Result
Evalutes the String and places the result in Result
// Parser state variables: // clear it just in case