static void skipList(bfFile bf) { int len,i; unsigned char type; bfread(bf,&type,1); len=readDword(bf); switch (type) { default: break; case 1: //byte bfseek(bf,len,SEEK_CUR); break; case 2: //short bfseek(bf,len*2,SEEK_CUR); break; case 3: //int bfseek(bf,len*4,SEEK_CUR); break; case 4: //long bfseek(bf,len*8,SEEK_CUR); break; case 5: //float bfseek(bf,len*4,SEEK_CUR); break; case 6: //double bfseek(bf,len*8,SEEK_CUR); break; case 7: //byte array for (i=0;i<len;i++) { int slen=readDword(bf); bfseek(bf,slen,SEEK_CUR); } break; case 8: //string for (i=0;i<len;i++) { int slen=readWord(bf); bfseek(bf,slen,SEEK_CUR); } break; case 9: //list for (i=0;i<len;i++) skipList(bf); break; case 10: //compound for (i=0;i<len;i++) skipCompound(bf); break; case 11: //int array for (i=0;i<len;i++) { int slen=readDword(bf); bfseek(bf,slen*4,SEEK_CUR); } break; } }
static void skipType(bfFile bf,int type) { int len; switch (type) { default: break; case 1: //byte bfseek(bf,1,SEEK_CUR); break; case 2: //short bfseek(bf,2,SEEK_CUR); break; case 3: //int bfseek(bf,4,SEEK_CUR); break; case 4: //long bfseek(bf,8,SEEK_CUR); break; case 5: //float bfseek(bf,4,SEEK_CUR); break; case 6: //double bfseek(bf,8,SEEK_CUR); break; case 7: //byte array len=readDword(bf); bfseek(bf,len,SEEK_CUR); break; case 8: //string len=readWord(bf); bfseek(bf,len,SEEK_CUR); break; case 9: //list skipList(bf); break; case 10: //compound skipCompound(bf); break; case 11: //int array len=readDword(bf); bfseek(bf,len*4,SEEK_CUR); break; } }
bool ClParserParser:: skipExpression(bool *assign) { bool expression = false; error_code_ = 0; parse_.skipSpace(); while (! parse_.eof()) { /* <expression> := <unary_operator> <expression> */ if (! expression && strchr(parser_unary_operator_chars, parse_.getCharAt()) != nullptr) { skipUnaryOperator(); if (! skipExpression(assign)) return false; if (*assign) { error_code_ = int(ClErr::INVALID_LVALUE_FOR_ASSIGNMENT); return false; } expression = true; } /* <expression> := '(' <expression> ')' */ else if (! expression && parse_.isChar('(')) { bool assign1 = false; parse_.skipChar(); if (! skipExpression(&assign1) && error_code_ != int(ClErr::INVALID_CHARACTER)) return false; error_code_ = 0; parse_.skipSpace(); if (! parse_.isChar(')')) { error_code_ = int(ClErr::MISSING_CLOSE_ROUND_BRACKET); return false; } parse_.skipChar(); expression = true; } /* <expression> := <numeric_value> */ else if (! expression && (parse_.isDigit() || parse_.isChar('.'))) { if (! skipNumericValue()) return false; expression = true; } /* <expression> := <string_value> */ else if (! expression && parse_.isOneOf(parser_string_chars)) { if (! skipStringValue()) return false; expression = true; } /* <expression> := <array_value> */ else if (! expression && parse_.isChar('[')) { parse_.skipChar(); if (! skipArray()) return false; expression = true; } /* <expression> := <dict_value> */ else if (! expression && parse_.isString("{{")) { parse_.skipChars(2); if (! skipDictionary()) return false; expression = true; } /* <expression> := <list_value> */ else if (! expression && parse_.isChar('{')) { parse_.skipChar(); if (! skipList()) return false; expression = true; } /* <expression> := <expression> <binary_operator> <expression> */ else if (expression && parse_.isOneOf(parser_binary_operator_chars)) { bool assign1 = false; skipBinaryOperator(&assign1); if (error_code_ != 0) return false; if (! skipExpression(assign)) return false; if (! assign1 && *assign) { error_code_ = int(ClErr::INVALID_LVALUE_FOR_ASSIGNMENT); return false; } if (assign1) *assign = true; expression = true; } /* <expression> := <expression> '?' <expression> ':' <expression> */ else if (expression && parse_.isChar('?')) { bool assign1 = false; bool assign2 = false; parse_.skipChar(); if (! skipExpression(&assign1) && error_code_ != int(ClErr::INVALID_CHARACTER)) return false; error_code_ = 0; parse_.skipSpace(); if (! parse_.isChar(':')) { error_code_ = int(ClErr::MISSING_COLON_OPERATOR); return false; } parse_.skipChar(); if (! skipExpression(&assign2)) return false; expression = true; *assign = assign1 | assign2; } /* <expression> := <expression> '[' <expression> ',' .... ']' */ else if (expression && parse_.isChar('[')) { parse_.skipChar(); if (! skipArray()) return false; expression = true; } /* <expression> := <expression> ',' <expression> */ else if (expression && parse_.isChar(',')) { bool assign1 = false; ClParserStackMgrInst->push(CL_PARSER_OP_COMMA); ClParserStackMgrInst->toNext(); parse_.skipChar(); if (! skipExpression(&assign1)) return false; expression = true; } /* <expression> := <variable> */ /* <expression> := <variable> '.' <variable> '.' <...> */ /* <expression> := <variable> '[' <expression> ',' .... ']' */ /* <expression> := <function> '(' <expression> ',' .... ')' */ /* <expression> := <type> '(' <expression> ',' .... ')' */ else if (! expression && (parse_.isAlpha() || parse_.isChar('_'))) { skipIdentifier(); if (error_code_ != 0) return false; parse_.skipSpace(); if (parse_.isChar('(')) { parse_.skipChar(); if (! skipArgList()) return false; expression = true; } else { if (parse_.isChar('[')) { parse_.skipChar(); if (! skipArray()) return false; parse_.skipSpace(); } while (parse_.isChar('.')) { parse_.skipChar(); parse_.skipSpace(); skipIdentifier(); if (error_code_ != 0) return false; if (parse_.isChar('[')) { parse_.skipChar(); if (! skipArray()) return false; parse_.skipSpace(); } } expression = true; } } else { error_code_ = int(ClErr::INVALID_CHARACTER); return false; } parse_.skipSpace(); } if (! expression) { error_code_ = int(ClErr::NULL_EXPRESSION); return false; } return true; }