diff --git a/common/version.h b/common/version.h index 0219a92981a59faebc4b4ef20392a3de7a4d7a30..fb8bf9134e8d37091243d5ec51ac98d35f5dd994 100644 --- a/common/version.h +++ b/common/version.h @@ -10,6 +10,7 @@ * Baranyi, Botond * Beres, Szabolcs * Delic, Adam + * Knapp, Adam * Kovacs, Ferenc * Pandi, Krisztian * Raduly, Csaba @@ -163,4 +164,7 @@ public: #undef FIELD_NAME #undef FN +/* Enum to identify version types */ +enum version_t { UNKNOWN, LEGACY_CRL, LEGACY_CAX, DOT_SEPARATED /*current*/ }; + #endif diff --git a/common/version_internal.h b/common/version_internal.h index 26b8dead334b6717147843256824d20628a9b88b..1af7cd7617c34be05b691d5103ba0c3746a1d3b9 100644 --- a/common/version_internal.h +++ b/common/version_internal.h @@ -7,7 +7,9 @@ * * Contributors: * Balasko, Jeno + * Baranyi, Botond * Godar, Marton + * Knapp, Adam * Kovacs, Ferenc * Lovassy, Arpad * Raduly, Csaba diff --git a/compiler2/AST.cc b/compiler2/AST.cc index 9b76ab756aa181341b7f3085195976b23d8011d5..adf3babb09116cf2dba3cbdb1471730da4892323 100644 --- a/compiler2/AST.cc +++ b/compiler2/AST.cc @@ -32,6 +32,7 @@ #include <sstream> #include "../common/dbgnew.hh" +#include "../common/version.h" #include "AST.hh" #include "asn1/AST_asn1.hh" #include "Identifier.hh" @@ -1319,7 +1320,7 @@ namespace Common { control_ns_prefix(p_mt == MOD_ASN ? mcopystr("asn1") : NULL), // only ASN.1 modules have default control namespace (X.693 amd1, 16.9) used_namespaces(), type_conv_v(), product_number(NULL), - suffix(0), release(UINT_MAX), patch(UINT_MAX), build(UINT_MAX), extra(NULL), legacy_version(TUNKNOWN) + suffix(0), release(UINT_MAX), patch(UINT_MAX), build(UINT_MAX), extra(NULL), version_type(UNKNOWN) { if(!p_modid) FATAL_ERROR("NULL parameter: Common::Module::Module()"); @@ -1481,7 +1482,7 @@ namespace Common { if (release <= 999999 && patch < 30 && build < 100) { char *product_identifier = - get_product_identifier(product_number, suffix, release, patch, build, extra, legacy_version); + get_product_identifier(product_number, suffix, release, patch, build, extra, version_type); fprintf(stderr, " %s", product_identifier); Free(product_identifier); } @@ -1491,7 +1492,7 @@ namespace Common { char* Module::get_product_identifier(const char* product_number, const unsigned int suffix, unsigned int release, unsigned int patch, - unsigned int build, const char* extra, tribool legacy) + unsigned int build, const char* extra, enum version_t version_type) { expstring_t ret_val = memptystr(); if ( product_number == NULL @@ -1503,11 +1504,15 @@ namespace Common { return ret_val; } if (product_number != NULL) { - if (legacy != TTRUE && suffix != 0) { + if (version_type == DOT_SEPARATED) { + ret_val = mputprintf(ret_val, "%d.%d.%d", suffix, release, patch); + return ret_val; + } + if (version_type == LEGACY_CAX && suffix != 0) { ret_val = mputprintf(ret_val, "%d/", suffix); } ret_val = mputstr(ret_val, product_number); - if (legacy == TTRUE && suffix != 0) { + if (version_type == LEGACY_CRL && suffix != 0) { ret_val = mputprintf(ret_val, "/%d", suffix); } ret_val = mputc(ret_val, ' '); diff --git a/compiler2/AST.hh b/compiler2/AST.hh index 677132cd2f15005220ec588ca1c571fb6d589301..da35f6c065fbec08cfddd7a53e9414057fadb34b 100644 --- a/compiler2/AST.hh +++ b/compiler2/AST.hh @@ -13,6 +13,7 @@ * Cserveni, Akos * Czerman, Oliver * Delic, Adam + * Knapp, Adam * Forstner, Matyas * Gecse, Roland * Kovacs, Ferenc @@ -34,6 +35,7 @@ #include <set> #include <string> #include "../common/dbgnew.hh" +#include "../common/version.h" #include "../common/ModuleVersion.hh" #include "CompilerError.hh" @@ -253,7 +255,7 @@ namespace Common { unsigned int patch; unsigned int build; char* extra; - tribool legacy_version; + enum version_t version_type; /** @} */ friend class Ttcn::Module; @@ -369,7 +371,7 @@ namespace Common { void write_checksum(); static char* get_product_identifier(const char* product_number, const unsigned int suffix, unsigned int release, unsigned int patch, - unsigned int build, const char* extra=NULL, tribool legacy = TUNKNOWN); + unsigned int build, const char* extra=NULL, enum version_t version_type = UNKNOWN); ModuleVersion getVersion() const; protected: // *::Module need access /** Collects the set of visible modules into \a visible_mods. */ diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index cf5b3630101417daa7355417e2ee1bdc3c995c50..8c86d4ac621bb8990f27c8582b51c7954b8b43eb 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -11,6 +11,7 @@ * Baranyi, Botond * Beres, Szabolcs * Delic, Adam + * Knapp, Adam * Kovacs, Ferenc * Raduly, Csaba * Szabados, Kristof @@ -21,6 +22,7 @@ * ******************************************************************************/ #include "../../common/dbgnew.hh" +#include "../../common/version.h" #include "AST_ttcn3.hh" #include "../Identifier.hh" #include "../CompilerError.hh" @@ -2989,8 +2991,8 @@ namespace Ttcn { char* act_product_number; unsigned int act_suffix, act_rel, act_patch, act_build; char* extra_junk; - tribool legacy; - (void)ex.get_id(act_product_number, act_suffix, act_rel, act_patch, act_build, extra_junk, legacy); + enum version_t version_type; + (void)ex.get_id(act_product_number, act_suffix, act_rel, act_patch, act_build, extra_junk, version_type); if (release != UINT_MAX) { ex.error("Duplicate 'version' attribute"); @@ -3002,7 +3004,7 @@ namespace Ttcn { patch = act_patch; build = act_build; extra = mcopystr(extra_junk); - legacy_version = legacy; + this->version_type = version_type; } // Avoid propagating the attribute needlessly multi->delete_element(i--); @@ -3014,9 +3016,9 @@ namespace Ttcn { char* exp_product_number; unsigned int exp_suffix, exp_rel, exp_patch, exp_build; char* exp_extra; - tribool legacy; + enum version_t version_type; Common::Identifier *req_id = ex.get_id(exp_product_number, - exp_suffix, exp_rel, exp_patch, exp_build, exp_extra, legacy); + exp_suffix, exp_rel, exp_patch, exp_build, exp_extra, version_type); // We own req_id if (imp->has_impmod_withId(*req_id)) { Common::Module* m = modules->get_mod_byId(*req_id); @@ -3029,31 +3031,47 @@ namespace Ttcn { single = 0; break; } else if (exp_product_number == NULL && - m->product_number != NULL && strcmp(m->product_number, "") > 0){ + m->product_number != NULL && strlen(m->product_number) > 0){ ex.warning("Module '%s' requires module '%s' of any product" ", while it specifies '%s'", this->modid->get_dispname().c_str(), req_id->get_dispname().c_str(), m->product_number); } else if (m->product_number != NULL && exp_product_number != NULL) { bool prod_match = false; - if (legacy == m->legacy_version || (legacy != TFALSE && m->legacy_version != TFALSE)) { + if (version_type == m->version_type) { prod_match = (0 == strcmp(m->product_number, exp_product_number)); } - else if (legacy == TTRUE && m->legacy_version == TFALSE) { + else if (version_type == LEGACY_CRL && m->version_type == LEGACY_CAX) { prod_match = (0 == strcmp(exp_product_number, LEGACY_CRL_PRODNR_EXECUTOR) && 0 == strcmp(m->product_number, LEGACY_CAX_PRODNR_EXECUTOR)); } - else if (legacy == TFALSE && m->legacy_version == TTRUE) { + else if (version_type == LEGACY_CAX && m->version_type == LEGACY_CRL) { prod_match = (0 == strcmp(exp_product_number, LEGACY_CAX_PRODNR_EXECUTOR) && 0 == strcmp(m->product_number, LEGACY_CRL_PRODNR_EXECUTOR)); } + else if (version_type == LEGACY_CRL && m->version_type == DOT_SEPARATED) { + prod_match = (0 == strcmp(exp_product_number, LEGACY_CRL_PRODNR_EXECUTOR) && + 0 == strlen(m->product_number)); + } + else if (version_type == DOT_SEPARATED && m->version_type == LEGACY_CRL) { + prod_match = (0 == strlen(exp_product_number) && + 0 == strcmp(m->product_number, LEGACY_CRL_PRODNR_EXECUTOR)); + } + else if (version_type == LEGACY_CAX && m->version_type == DOT_SEPARATED) { + prod_match = (0 == strcmp(exp_product_number, LEGACY_CAX_PRODNR_EXECUTOR) && + 0 == strlen(m->product_number)); + } + else if (version_type == DOT_SEPARATED && m->version_type == LEGACY_CAX) { + prod_match = (0 == strlen(exp_product_number) && + 0 == strcmp(m->product_number, LEGACY_CAX_PRODNR_EXECUTOR)); + } if (!prod_match) { char *req_product_identifier = get_product_identifier(exp_product_number, - exp_suffix, exp_rel, exp_patch, exp_build, NULL, legacy); + exp_suffix, exp_rel, exp_patch, exp_build, NULL, version_type); char *mod_product_identifier = get_product_identifier(m->product_number, - m->suffix, m->release, m->patch, m->build, NULL, m->legacy_version); + m->suffix, m->release, m->patch, m->build, NULL, m->version_type); ex.error("Module '%s' requires version %s of module" " '%s', but only %s is available", @@ -3070,10 +3088,10 @@ namespace Ttcn { // unless the special version number is used if (m->suffix != exp_suffix && (m->suffix != UINT_MAX)) { char *req_product_identifier = - get_product_identifier(exp_product_number,exp_suffix, exp_rel, exp_patch, exp_build, NULL, legacy); + get_product_identifier(exp_product_number,exp_suffix, exp_rel, exp_patch, exp_build, NULL, version_type); char *mod_product_identifier = get_product_identifier(m->product_number, - m->suffix, m->release, m->patch, m->build, NULL, m->legacy_version); + m->suffix, m->release, m->patch, m->build, NULL, m->version_type); ex.error("Module '%s' requires version %s of module" " '%s', but only %s is available", @@ -3113,10 +3131,11 @@ namespace Ttcn { char* exp_product_number; unsigned int exp_suffix, exp_minor, exp_patch, exp_build; char* exp_extra; - tribool legacy; - (void)ex.get_id(exp_product_number, exp_suffix, exp_minor, exp_patch, exp_build, exp_extra, legacy); - if (exp_product_number != NULL && ((legacy != TTRUE && strcmp(exp_product_number, LEGACY_CAX_PRODNR_EXECUTOR) != 0) || - (legacy == TTRUE && strcmp(exp_product_number, LEGACY_CRL_PRODNR_EXECUTOR) != 0))) { + enum version_t version_type; + (void)ex.get_id(exp_product_number, exp_suffix, exp_minor, exp_patch, exp_build, exp_extra, version_type); + if (exp_product_number != NULL && ((version_type == LEGACY_CAX && strcmp(exp_product_number, LEGACY_CAX_PRODNR_EXECUTOR) != 0) || + (version_type == LEGACY_CRL && strcmp(exp_product_number, LEGACY_CRL_PRODNR_EXECUTOR) != 0) || + (version_type == DOT_SEPARATED && strlen(exp_product_number) != 0))) { ex.error("This module needs to be compiled with TITAN, but " " product number %s is not TITAN" , exp_product_number); @@ -3129,10 +3148,25 @@ namespace Ttcn { + exp_minor * 10000 + exp_patch * 100 + exp_build; if (expected_version > TTCN3_VERSION_MONOTONE) { char *exp_product_identifier = - get_product_identifier(exp_product_number, exp_suffix, exp_minor, exp_patch, exp_build, NULL, legacy); + get_product_identifier(exp_product_number, exp_suffix, exp_minor, exp_patch, exp_build, NULL, version_type); + char *tmp = "UNKNOWN"; + switch(version_type) { + case LEGACY_CRL: + tmp = LEGACY_CRL_PRODUCT_NUMBER; + break; + case LEGACY_CAX: + tmp = LEGACY_CAX_PRODUCT_NUMBER; + break; + case DOT_SEPARATED: + tmp = PRODUCT_NUMBER; + break; + default: + // Do nothing + break; + } ex.error("This module needs to be compiled with TITAN version" " %s or higher; version %s detected" - , exp_product_identifier, legacy == TTRUE ? LEGACY_CRL_PRODUCT_NUMBER : LEGACY_CAX_PRODUCT_NUMBER); + , exp_product_identifier, tmp); Free(exp_product_identifier); } multi->delete_element(i--); diff --git a/compiler2/ttcn3/Ttcnstuff.cc b/compiler2/ttcn3/Ttcnstuff.cc index 12467e7d19f4028e0b9cf33b0d9167adb97c02c0..8934d5563e80af882d9230107c9276e89bcd901e 100644 --- a/compiler2/ttcn3/Ttcnstuff.cc +++ b/compiler2/ttcn3/Ttcnstuff.cc @@ -9,6 +9,7 @@ * Balasko, Jeno * Baranyi, Botond * Delic, Adam + * Knapp, Adam * Kovacs, Ferenc * Raduly, Csaba * Szabados, Kristof @@ -2725,64 +2726,139 @@ namespace Ttcn { } ExtensionAttribute::ExtensionAttribute(const char* ABCClass, int type_number, - int sequence, int suffix, Identifier *ver, tribool legacy) + int sequence, int suffix, Identifier *ver, enum version_t version_type) : Location(), type_(VERSION), value_() { - if (ver == NULL) FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); + if (version_type != DOT_SEPARATED && ver == NULL) FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); value_.version_.module_ = NULL; - value_.version_.legacy_ = legacy; - - check_product_number(ABCClass, type_number, sequence); - parse_version(ver); - if (type_ != NONE) { - value_.version_.productNumber_ = - NULL == ABCClass ? NULL : mprintf("%s %d %d", ABCClass, type_number, sequence); - value_.version_.suffix_ = suffix; - delete ver; // "took care of it" - } + value_.version_.version_type_ = version_type; + + switch (version_type) { + case DOT_SEPARATED: + // In this case, 'type_number' and 'sequence' are used to pass the minor and patch part of the version + // major minor/release patch + if (suffix < 0 || type_number < 0 || sequence < 0) { + type_ = NONE; + return; + } + value_.version_.productNumber_ = mputc(value_.version_.productNumber_, '\0'); + value_.version_.suffix_ = suffix; + value_.version_.release_ = type_number; + value_.version_.patch_ = sequence; + value_.version_.build_ = 99; + value_.version_.extra_ = NULL; + break; + + case UNKNOWN: + case LEGACY_CRL: + case LEGACY_CAX: + check_product_number(ABCClass, type_number, sequence); + parse_version(ver); + if (type_ != NONE) { + value_.version_.productNumber_ = + NULL == ABCClass ? NULL : mprintf("%s %d %d", ABCClass, type_number, sequence); + value_.version_.suffix_ = suffix; + delete ver; // "took care of it" + } + break; + + default: + FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); + break; + } } ExtensionAttribute::ExtensionAttribute(Identifier *mod, const char* ABCClass, - int type_number, int sequence, int suffix, Identifier *ver, tribool legacy) + int type_number, int sequence, int suffix, Identifier *ver, enum version_t version_type) : Location(), type_(REQUIRES), value_() { - if (mod == NULL || ver == NULL) + if (version_type != DOT_SEPARATED && (mod == NULL || ver == NULL)) FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); // store the module identifier value_.version_.module_ = mod; - value_.version_.legacy_ = legacy; - - check_product_number(ABCClass, type_number, sequence); - parse_version(ver); - if (type_ == NONE) { // parse_version reported an error - value_.version_.module_ = NULL; // disown it; caller will free - value_.version_.suffix_ = suffix; - } else { - value_.version_.productNumber_ = - NULL == ABCClass ? NULL : mprintf("%s %d %d", ABCClass, type_number, sequence); - value_.version_.suffix_ = suffix; - delete ver; - } + value_.version_.version_type_ = version_type; + + switch (version_type) { + case DOT_SEPARATED: + // In this case, 'type_number' and 'sequence' are used to pass the minor and patch part of the version + // major minor/release patch + if (suffix < 0 || type_number < 0 || sequence < 0) { + type_ = NONE; + return; + } + value_.version_.productNumber_ = mputc(value_.version_.productNumber_, '\0'); + value_.version_.suffix_ = suffix; + value_.version_.release_ = type_number; + value_.version_.patch_ = sequence; + value_.version_.build_ = 99; + value_.version_.extra_ = NULL; + break; + + case UNKNOWN: + case LEGACY_CRL: + case LEGACY_CAX: + check_product_number(ABCClass, type_number, sequence); + parse_version(ver); + if (type_ == NONE) { // parse_version reported an error + value_.version_.module_ = NULL; // disown it; caller will free + value_.version_.suffix_ = suffix; + } else { + value_.version_.productNumber_ = + NULL == ABCClass ? NULL : mprintf("%s %d %d", ABCClass, type_number, sequence); + value_.version_.suffix_ = suffix; + delete ver; + } + break; + + default: + FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); + break; + } } ExtensionAttribute::ExtensionAttribute(const char* ABCClass, int type_number, - int sequence, int suffix, Identifier* ver, extension_t et, tribool legacy) + int sequence, int suffix, Identifier* ver, extension_t et, enum version_t version_type) : Location(), type_(et), value_() { - if (ver == NULL) FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); - value_.version_.legacy_ = legacy; + if (version_type != DOT_SEPARATED && ver == NULL) FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); + value_.version_.version_type_ = version_type; switch (et) { case REQ_TITAN: - check_product_number(ABCClass, type_number, sequence); - parse_version(ver); - if (type_ != NONE) { - value_.version_.productNumber_ = - NULL == ABCClass ? NULL : mprintf("%s %d %d", ABCClass, type_number, sequence); - value_.version_.suffix_ = suffix; - delete ver; // "took care of it" - } else { - value_.version_.suffix_ = suffix; + switch (version_type) { + case DOT_SEPARATED: + // In this case, 'type_number' and 'sequence' are used to pass the minor and patch part of the version + // major minor/release patch + if (suffix < 0 || type_number < 0 || sequence < 0) { + type_ = NONE; + return; + } + value_.version_.productNumber_ = mputc(value_.version_.productNumber_, '\0'); + value_.version_.suffix_ = suffix; + value_.version_.release_ = type_number; + value_.version_.patch_ = sequence; + value_.version_.build_ = 99; + value_.version_.extra_ = NULL; + break; + + case UNKNOWN: + case LEGACY_CRL: + case LEGACY_CAX: + check_product_number(ABCClass, type_number, sequence); + parse_version(ver); + if (type_ != NONE) { + value_.version_.productNumber_ = + NULL == ABCClass ? NULL : mprintf("%s %d %d", ABCClass, type_number, sequence); + value_.version_.suffix_ = suffix; + delete ver; // "took care of it" + } else { + value_.version_.suffix_ = suffix; + } + break; + + default: + FATAL_ERROR("ExtensionAttribute::ExtensionAttribute()"); + break; } break; @@ -2944,7 +3020,7 @@ namespace Ttcn { //FIXME ot is update -elni kell. Common::Identifier *ExtensionAttribute::get_id( char*& product_number, unsigned int& suffix, - unsigned int& rel, unsigned int& patch, unsigned int& bld, char*& extra, tribool& legacy) + unsigned int& rel, unsigned int& patch, unsigned int& bld, char*& extra, enum version_t& version_type) { if ( type_ != REQUIRES && type_ != REQ_TITAN && type_ != VERSION && type_ != VERSION_TEMPLATE) { @@ -2956,7 +3032,7 @@ namespace Ttcn { patch = value_.version_.patch_; bld = value_.version_.build_; extra = value_.version_.extra_; - legacy = value_.version_.legacy_; + version_type = value_.version_.version_type_; return value_.version_.module_; } diff --git a/compiler2/ttcn3/Ttcnstuff.hh b/compiler2/ttcn3/Ttcnstuff.hh index e630cb88adb91f889de0ff56a2da664821c91bb7..78a4bdeba6ed28544f42568c8cb35abd2078acd9 100644 --- a/compiler2/ttcn3/Ttcnstuff.hh +++ b/compiler2/ttcn3/Ttcnstuff.hh @@ -9,6 +9,7 @@ * Balasko, Jeno * Baranyi, Botond * Delic, Adam + * Knapp, Adam * Raduly, Csaba * Szabados, Kristof * Szabo, Bence Janos @@ -18,6 +19,7 @@ #ifndef TTCNSTUFF_H_ #define TTCNSTUFF_H_ +#include "../../common/version.h" #include "../Setting.hh" #include "../Type.hh" // for Common::Common::Type::MessageEncodingType_t #include "AST_ttcn3.hh" // For Def_Function_Base::prototype_t @@ -595,7 +597,7 @@ public: * becomes responsible for \p ver, otherwise the caller has to free it. */ ExtensionAttribute(const char* ABCClass, int type_number, int sequence, - int suffix, Identifier *ver, tribool legacy); + int suffix, Identifier *ver, enum version_t version_type); /** Constructor for the REQUIRES type * @@ -608,7 +610,7 @@ public: * If unsuccessful, freeing the identifiers remains the caller's duty. */ ExtensionAttribute(Identifier *mod, const char* ABCClass, int type_number, - int sequence, int suffix, Identifier *ver, tribool legacy); + int sequence, int suffix, Identifier *ver, enum version_t version_type); /** Constructor for the REQ_TITAN type or the VERSION_TEMPLATE type * @@ -621,7 +623,7 @@ public: * becomes responsible for \p ver, otherwise the caller has to free it. */ ExtensionAttribute(const char* ABCClass, int type_number, int sequence, - int suffix, Identifier* ver, extension_t et, tribool legacy); + int suffix, Identifier* ver, extension_t et, enum version_t version_type); ~ExtensionAttribute(); @@ -687,7 +689,7 @@ public: * @return pointer to the identifier of the module; the caller must not free */ Common::Identifier *get_id(char*& product_number, unsigned int& suffix, - unsigned int& rel, unsigned int& patch, unsigned int& bld, char*& extra, tribool& legacy); + unsigned int& rel, unsigned int& patch, unsigned int& bld, char*& extra, enum version_t& version_type); /// @} private: /// Attribute type. @@ -715,13 +717,13 @@ private: Types *anytypes_; struct { Common::Identifier *module_; - char* productNumber_; ///< "CRL 113 200" for legacy versions, "CAX 105 7730" for current versions + char* productNumber_; ///< "CRL 113 200" for CRL versions, "CAX 105 7730" for CAX versions, "" for current version unsigned int suffix_; ///< The "/3" unsigned int release_;///< release unsigned int patch_; ///< patch unsigned int build_; ///< build number char* extra_; ///< extra junk at the end, for titansim - tribool legacy_; ///< 'true' for legacy versions, 'false' for current versions, or 'unknown' + enum version_t version_type_; ///< possible values: UNKNOWN, LEGACY_CRL, LEGACY_CAX and DOT_SEPARATED for the current version } version_; PrintingType *pt_; } value_; diff --git a/compiler2/ttcn3/coding_attrib_p.y b/compiler2/ttcn3/coding_attrib_p.y index 1c013aae5f924125420cf129c8cadcf19715b918..f731593b6c7f20ee6e7217a06eccf38a4ae88eec 100644 --- a/compiler2/ttcn3/coding_attrib_p.y +++ b/compiler2/ttcn3/coding_attrib_p.y @@ -12,6 +12,7 @@ * Szabados, Kristof * Szabo, Janos Zoltan – initial implementation * Zalanyi, Balazs Andor + * Knapp, Adam * ******************************************************************************/ /* Parser for "extension" attributes of functions, external functions and @@ -20,6 +21,7 @@ %{ #include "../../common/dbgnew.hh" +#include "../../common/version.h" #include "../string.hh" #include "../Identifier.hh" #include "../Setting.hh" @@ -305,7 +307,7 @@ ExtensionAttribute: VersionAttribute: VersionKeyword IDentifier { // version R2D2 - $$ = new ExtensionAttribute(NULL, 0, 0, 0, $2, TUNKNOWN); // VERSION + $$ = new ExtensionAttribute(NULL, 0, 0, 0, $2, UNKNOWN); // VERSION $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s'", $2->get_name().c_str()); @@ -316,7 +318,7 @@ VersionKeyword IDentifier } | VersionKeyword '<' IDentifier '>' { // version <RnXnn> - $$ = new ExtensionAttribute(NULL, 0, 0, 0, $3, ExtensionAttribute::VERSION_TEMPLATE, TTRUE); + $$ = new ExtensionAttribute(NULL, 0, 0, 0, $3, ExtensionAttribute::VERSION_TEMPLATE, LEGACY_CRL); $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version template '<%s>'", $3->get_name().c_str()); @@ -327,7 +329,7 @@ VersionKeyword IDentifier } | VersionKeyword IDentifier Number Number IDentifier { // version CNL 113 200 R2D2 - $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, 0, $5, TUNKNOWN); // VERSION + $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, 0, $5, UNKNOWN); // VERSION $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d %s'", @@ -340,7 +342,7 @@ VersionKeyword IDentifier } | VersionKeyword IDentifier Number Number '<' IDentifier '>' { // version CNL 113 200 <RnXnn> - $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, 0, $6, ExtensionAttribute::VERSION_TEMPLATE, TTRUE); // VERSION + $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, 0, $6, ExtensionAttribute::VERSION_TEMPLATE, LEGACY_CRL); // VERSION $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d <%s>'", @@ -353,7 +355,7 @@ VersionKeyword IDentifier } | VersionKeyword IDentifier Number Number '/' Number IDentifier { // version CNL 113 200 / 1 R2D2 - $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, $6, $7, TTRUE); // VERSION + $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, $6, $7, LEGACY_CRL); // VERSION $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d / %d %s'", @@ -366,7 +368,7 @@ VersionKeyword IDentifier } | VersionKeyword Number '/' IDentifier Number Number IDentifier { // version 1 / CAX 105 7730 R2D2 - $$ = new ExtensionAttribute($4->get_dispname().c_str(), $5, $6, $2, $7, TFALSE); // VERSION + $$ = new ExtensionAttribute($4->get_dispname().c_str(), $5, $6, $2, $7, LEGACY_CAX); // VERSION $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%d / %s %d %d %s'", @@ -379,7 +381,7 @@ VersionKeyword IDentifier } | VersionKeyword IDentifier Number Number '/' Number '<' IDentifier '>' { // version CNL 113 200 / 1 <RnXnn> - $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, $6, $8, ExtensionAttribute::VERSION_TEMPLATE, TTRUE); // VERSION + $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, $6, $8, ExtensionAttribute::VERSION_TEMPLATE, LEGACY_CRL); // VERSION $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d / %d <%s>'", @@ -390,12 +392,22 @@ VersionKeyword IDentifier } delete $2; } +| VersionKeyword Number '.' Number '.' Number +{ // version 7 . 2 . 1 + $$ = new ExtensionAttribute(NULL, $4, $6, $2, NULL, DOT_SEPARATED); // VERSION + $$->set_location(coding_attrib_infile, @$); + if ($$->get_type() == ExtensionAttribute::NONE) { + $$->error("Incorrect version data '%d.%d.%d'", $2, $4, $6); + delete $$; + $$ = NULL; + } +} ; RequiresAttribute: RequiresKeyword IDentifier IDentifier { // module R1B - $$ = new ExtensionAttribute($2, NULL, 0, 0, 0, $3, TUNKNOWN); // REQUIRES + $$ = new ExtensionAttribute($2, NULL, 0, 0, 0, $3, UNKNOWN); // REQUIRES $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { /* parsing the version has failed */ @@ -408,7 +420,7 @@ RequiresKeyword IDentifier IDentifier } | RequiresKeyword IDentifier IDentifier Number Number IDentifier { // module CNL xxx xxx R1A - $$ = new ExtensionAttribute($2, $3->get_dispname().c_str(), $4, $5, 0, $6, TUNKNOWN); // REQUIRES + $$ = new ExtensionAttribute($2, $3->get_dispname().c_str(), $4, $5, 0, $6, UNKNOWN); // REQUIRES $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d %s'", @@ -422,7 +434,7 @@ RequiresKeyword IDentifier IDentifier } | RequiresKeyword IDentifier IDentifier Number Number '/' Number IDentifier { // module CNL xxx xxx / 1 R9A - $$ = new ExtensionAttribute($2, $3->get_dispname().c_str(), $4, $5, $7, $8, TTRUE); // REQUIRES + $$ = new ExtensionAttribute($2, $3->get_dispname().c_str(), $4, $5, $7, $8, LEGACY_CRL); // REQUIRES $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d / %d %s'", @@ -436,7 +448,7 @@ RequiresKeyword IDentifier IDentifier } | RequiresKeyword IDentifier Number '/' IDentifier Number Number IDentifier { // module 1 / CAX xxx xxx R9A - $$ = new ExtensionAttribute($2, $5->get_dispname().c_str(), $6, $7, $3, $8, TFALSE); // REQUIRES + $$ = new ExtensionAttribute($2, $5->get_dispname().c_str(), $6, $7, $3, $8, LEGACY_CAX); // REQUIRES $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%d / %s %d %d %s'", @@ -448,9 +460,20 @@ RequiresKeyword IDentifier IDentifier } delete $5; } +| RequiresKeyword IDentifier Number '.' Number '.' Number +{ // module 7 . 2 . 1 + $$ = new ExtensionAttribute($2, NULL, $5, $7, $3, NULL, DOT_SEPARATED); // REQUIRES + $$->set_location(coding_attrib_infile, @$); + if ($$->get_type() == ExtensionAttribute::NONE) { + $$->error("Incorrect version data '%d.%d.%d'", $3, $5, $7); + delete $2; + delete $$; + $$ = NULL; + } +} | ReqTitanKeyword IDentifier { // R1A - $$ = new ExtensionAttribute(NULL, 0, 0, 0, $2, ExtensionAttribute::REQ_TITAN, TUNKNOWN); + $$ = new ExtensionAttribute(NULL, 0, 0, 0, $2, ExtensionAttribute::REQ_TITAN, UNKNOWN); $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { /* parsing the version has failed */ @@ -462,7 +485,7 @@ RequiresKeyword IDentifier IDentifier } | ReqTitanKeyword IDentifier Number Number IDentifier { // CRL 113 200 R1A - $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, 0, $5, ExtensionAttribute::REQ_TITAN, TUNKNOWN); + $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, 0, $5, ExtensionAttribute::REQ_TITAN, UNKNOWN); $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d %s'", @@ -475,7 +498,7 @@ RequiresKeyword IDentifier IDentifier } | ReqTitanKeyword IDentifier Number Number '/' Number IDentifier { // CRL 113 200 / 2 R1A - $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, $6, $7, ExtensionAttribute::REQ_TITAN, TTRUE); + $$ = new ExtensionAttribute($2->get_dispname().c_str(), $3, $4, $6, $7, ExtensionAttribute::REQ_TITAN, LEGACY_CRL); $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%s %d %d / %d %s'", @@ -488,7 +511,7 @@ RequiresKeyword IDentifier IDentifier } | ReqTitanKeyword Number '/' IDentifier Number Number IDentifier { // 2 / CAX 105 7730 R1A - $$ = new ExtensionAttribute($4->get_dispname().c_str(), $5, $6, $2, $7, ExtensionAttribute::REQ_TITAN, TFALSE); + $$ = new ExtensionAttribute($4->get_dispname().c_str(), $5, $6, $2, $7, ExtensionAttribute::REQ_TITAN, LEGACY_CAX); $$->set_location(coding_attrib_infile, @$); if ($$->get_type() == ExtensionAttribute::NONE) { $$->error("Incorrect version data '%d / %s %d %d %s'", @@ -499,6 +522,16 @@ RequiresKeyword IDentifier IDentifier } delete $4; } +| ReqTitanKeyword Number '.' Number '.' Number +{ // 7 . 2 . 1 + $$ = new ExtensionAttribute(NULL, $4, $6, $2, NULL, ExtensionAttribute::REQ_TITAN, DOT_SEPARATED); + $$->set_location(coding_attrib_infile, @$); + if ($$->get_type() == ExtensionAttribute::NONE) { + $$->error("Incorrect version data '%d.%d.%d'", $2, $4, $6); + delete $$; + $$ = NULL; + } +} ; TransparentAttribute: TransparentKeyword diff --git a/function_test/Semantic_Analyser/ver/dot_separated_OK.ttcn b/function_test/Semantic_Analyser/ver/dot_separated_OK.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..2ce6c3f02d228f19477fadd4cdd9664c54bd8859 --- /dev/null +++ b/function_test/Semantic_Analyser/ver/dot_separated_OK.ttcn @@ -0,0 +1,16 @@ +/****************************************************************************** + * Copyright (c) 2000-2021 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + * + * Contributors: + * Knapp, Adam + * + ******************************************************************************/ +module dot_separated_OK { +} +with { + extension "version 7.2.1"; +} diff --git a/function_test/Semantic_Analyser/ver/high_titan_SE.ttcn b/function_test/Semantic_Analyser/ver/high_titan_SE.ttcn index 27c76032ba851482d0ac58e515f14d8cda02921d..26d3ed1b86975aa1db4f52c30ab3343a5f2e8647 100644 --- a/function_test/Semantic_Analyser/ver/high_titan_SE.ttcn +++ b/function_test/Semantic_Analyser/ver/high_titan_SE.ttcn @@ -7,6 +7,7 @@ * * Contributors: * Balasko, Jeno + * Knapp, Adam * Kovacs, Ferenc * Pandi, Krisztian * Raduly, Csaba @@ -88,4 +89,20 @@ with { extension "requiresTITAN R2R"; //^error: Incorrect version data// extension "requiresTITAN R2W"; //^error: Incorrect version data// + /* test major.minor.patch version format */ + extension "requiresTITAN 7.2.1"; /* This one must just pass */ + extension "requiresTITAN 7.1"; //^error: syntax error, unexpected $end, expecting '.'// + extension "requiresTITAN 1.0.1"; /* This one must just pass */ + extension "requiresTITAN 0.2.1"; /* This one must just pass, the next one must just fail */ + extension "requiresTITAN 77.2.1"; //^error: This module needs to be compiled with TITAN version 77.2.1 or higher; version 7.2.1 detected// + extension "requiresTITAN 99999999999.2.1"; //^error: This module needs to be compiled with TITAN version 1410065407.2.1 or higher; version 7.2.1 detected// + extension "requiresTITAN 77.22.1"; //^error: This module needs to be compiled with TITAN version 77.22.1 or higher; version 7.2.1 detected// + extension "requiresTITAN 6.22.1"; /* This one must just pass */ + extension "requiresTITAN 77.99999999999.1"; //^error: This module needs to be compiled with TITAN version 77.1410065407.1 or higher; version 7.2.1 detected// + extension "requiresTITAN 7.2.11"; //^error: This module needs to be compiled with TITAN version 7.2.11 or higher; version 7.2.1 detected// + extension "requiresTITAN 4.2.11"; /* This one must just pass */ + extension "requiresTITAN 77.2.99999999999"; //^error: This module needs to be compiled with TITAN version 77.2.1215752191 or higher; version 7.2.1 detected// + extension "requiresTITAN .2.1"; //^error: at or before token `.': syntax error, unexpected '.', expecting Identifier or Number// + extension "requiresTITAN 77..1"; //^error: at or before token `.': syntax error, unexpected '.', expecting Number// + } diff --git a/function_test/Semantic_Analyser/ver/importer_SE.ttcn b/function_test/Semantic_Analyser/ver/importer_SE.ttcn index 9d82b16770781608ce7f2c7252ba0c5745ead617..87a6b0d73827f13f8586b1791e36274f2d25d7e4 100644 --- a/function_test/Semantic_Analyser/ver/importer_SE.ttcn +++ b/function_test/Semantic_Analyser/ver/importer_SE.ttcn @@ -7,6 +7,7 @@ * * Contributors: * Balasko, Jeno + * Knapp, Adam * Raduly, Csaba * Szabados, Kristof * @@ -20,6 +21,7 @@ import from CRL_111_222_3_R2D_SE all; import from unreleased_SE all; import from noversion_SE all; import from titan_OK all; +import from dot_separated_OK all; } with { @@ -59,5 +61,11 @@ with { extension "requires titan_OK 7/CAX 105 7730 R2A"; extension "requires titan_OK CRL 113 200/7 R2A"; + + extension "requires titan_OK 7.1.0"; + extension "requires titan_OK 11.6.1"; //^error: Module 'importer' requires version 11.6.1 of module 'titan_OK', but only 7/CAX 105 7730 R2A is available// + + extension "requires dot_separated_OK 7.2.1" + extension "requires dot_separated_OK 33.4.5" //^error: Module 'importer' requires version 33.4.5 of module 'dot_separated_OK', but only 7.2.1 is available// }