| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- // =================================================================================================================
- // @parseSuffix
- // "Parser-function", parses a SCPI Suffix Program Data (<SUFFIX PROGRAM DATA>)
- // References:
- // "7.7.3 <SUFFIX PROGRAM DATA>", [1]
- // "7.7.3.2 Encoding Syntax", [1]
- // Parameters:
- // @xObj - parser context, must be prepared by @prepareParserContext
- // ... before each call. If it is needed to continue the processing, the
- // ... @bKeepContext parameter duing the call @prepareParserContext must
- // ... be set to 'true', and otherwise, to restart parsing the parameter
- // ... must be set to 'false'.
- // Returns:
- // eParserStatus_failed - error, can not parse data as a string;
- // eParserStatus_success - success, the string has been successfully parsed;
- // eParserStatus_need_data - warning, the string can not be parsed due to
- // there no enough data to process.
- eParserStatus_t parseSuffix( xParseEntry_t * xObj )
- {
- sParseEntry_t * pObj = (sParseEntry_t*)xObj;
- eParserStatus_t status = eParserStatus_invalid;
-
- if( NULL != pObj && NULL != pObj->str && 0 != ((ptrdiff_t)pObj->tail - (ptrdiff_t)pObj->head)
- && pObj->str != pObj->tail )
- {
- status = eParserStatus_need_data; // forward status set: the default 'eParserStatus_invalid' shall
- // ... not be returned due to the context will be changed.
- // if the context has been cleaned up
- if( ! pObj->bContextKept )
- {
- pObj->parseSuffix.whiteAllowed = true; // enable white-character by default
- }
- // walk til the end of the buffer
- while( pObj->str != pObj->tail )
- {
- char character = *(pObj->str++);
- // Check if the white-character is allowed in current state:
- if( pObj->parseDemicalNumber.whiteAllowed )
- {
- // Check if the character is a white-character:
- if( scpi_iswhite( character ) )
- {
- // skip character
- continue;
- }
- }
- }
- }
- return status;
- }
|