diff options
author | Juergen Bocklage-Ryannel <juergen@ryannel.org> | 2018-03-07 18:54:26 +0100 |
---|---|---|
committer | Juergen Bocklage-Ryannel <juergen@ryannel.org> | 2018-03-07 18:54:26 +0100 |
commit | 7a06dde5e8c28173b8509786d11f1fae5e7a3506 (patch) | |
tree | d25789ba5b56c9248d479050d466f264ff745bd7 /qface/idl/listener.py | |
parent | 183aeabc79e8d0791d9b6583923a3bd091663686 (diff) | |
download | qtivi-qface-7a06dde5e8c28173b8509786d11f1fae5e7a3506.tar.gz |
add initial support for profiles and a map with a value type only.
e.g. map<Station>. The key type is defined by the generator.
Diffstat (limited to 'qface/idl/listener.py')
-rw-r--r-- | qface/idl/listener.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/qface/idl/listener.py b/qface/idl/listener.py index 4e9e720..7c3010e 100644 --- a/qface/idl/listener.py +++ b/qface/idl/listener.py @@ -23,25 +23,24 @@ contextMap = {} class QFaceListener(TListener): def __init__(self, system, profile=EProfile.BASIC): - super(QFaceListener, self).__init__() + super().__init__() self.lang_features = get_features(profile) self.system = system or System() # type:System - def is_supported(feature, report=True): + def check_support(self, feature, report=True): if feature not in self.lang_features and report: click.secho('Unsuported language feature: {}'.format(EFeature.IMPORT), fg='red') return False return True - class DomainListener(QFaceListener): """The domain listener is called by the parser to fill the domain data struture. As a result a system is passed back""" def __init__(self, system, profile=EProfile.BASIC): - super(QFaceListener, self).__init__(system, profile) + super().__init__(system, profile) contextMap.clear() self.module = None # type:Module self.interface = None # type:Interface @@ -77,6 +76,14 @@ class DomainListener(QFaceListener): type.name = 'list' type.nested = TypeSymbol("", type) self.parse_type(ctxSymbol, type.nested) + elif ctx.typeSymbol().mapTypeSymbol(): + self.check_support(EFeature.MAPS) + # type:TParser.ListTypeSymbolContext + ctxSymbol = ctx.typeSymbol().mapTypeSymbol() + type.is_map = True + type.name = 'map' + type.nested = TypeSymbol("", type) + self.parse_type(ctxSymbol, type.nested) elif ctx.typeSymbol().modelTypeSymbol(): # type:TParser.ModelTypeSymbolContext ctxSymbol = ctx.typeSymbol().modelTypeSymbol() @@ -205,12 +212,12 @@ class DomainListener(QFaceListener): self.property.readonly = bool(modifier.is_readonly) self.property.const = bool(modifier.is_const) - if ctx.value: - try: - value = yaml.load(ctx.value.text, Loader=Loader) - self.property._value = value - except yaml.YAMLError as exc: - click.secho(exc, fg='red') + # if ctx.value: + # try: + # value = yaml.load(ctx.value.text, Loader=Loader) + # self.property._value = value + # except yaml.YAMLError as exc: + # click.secho(exc, fg='red') self.parse_annotations(ctx, self.property) self.parse_type(ctx, self.property.type) @@ -250,10 +257,10 @@ class DomainListener(QFaceListener): def enterImportSymbol(self, ctx: TParser.ImportSymbolContext): assert self.module - if self.is_supported(EFeature.IMPORT): - name = ctx.name.text - version = ctx.version.text - self.module._importMap[name] = '{0} {1}'.format(name, version) + self.check_support(EFeature.IMPORT) + name = ctx.name.text + version = ctx.version.text + self.module._importMap[name] = '{0} {1}'.format(name, version) def exitImportSymbol(self, ctx: TParser.ImportSymbolContext): pass |