diff options
Diffstat (limited to 'qface/idl/profile.py')
-rw-r--r-- | qface/idl/profile.py | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/qface/idl/profile.py b/qface/idl/profile.py index 4b376c9..eeade91 100644 --- a/qface/idl/profile.py +++ b/qface/idl/profile.py @@ -1,36 +1,46 @@ # Copyright (c) Pelagicore AB 2016 +""" +A profile is a set of features describing a qface language profile. +The language profile tells the parser which language aspects are +supported for the particular choosen profile. + +from profile import get_features, EProfile, EFeature + +features = get_features(EProfile.ADVANCED) + +if EFeature.CONST_OPERATION in features: + # parse this aspect of the language + +""" from enum import Enum class EFeature(Enum): - CONST_PROPERTY = 'const_property' + CONST_OPERATION = 'const_operation' EXTEND_INTERFACE = 'extend_interface' + IMPORT = 'import' + MAPS = 'maps' class EProfile(Enum): BASIC = 'basic' ADVANCED = 'advanced' - ALL = 'advanced' - - -class Profile: - def __init__(self, features=set()): - self.features = features - - @staticmethod - def get_profile(cls, name): - if name is EProfile.BASIC: - return Profile(features=[ - ]) - if name is EProfile.ADVANCED: - return Profile(features=[ - EFeature.CONST_PROPERTY, - EFeature.EXTEND_INTERFACE - ]) - if name is EProfile.ALL: - return Profile(features=[ - ]) - return [] + FULL = 'full' + + +_profiles = { + EProfile.BASIC: set(), + EProfile.ADVANCED: set([ + EFeature.CONST_PROPERTY, + EFeature.EXTEND_INTERFACE, + EFeature.IMPORT, + EFeature.MAPS + ]), + EProfile.ALL: set(EFeature) +} + +def get_features(name): + return _profiles.get(name, set()) |