diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-05-17 10:43:30 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-05-17 10:43:30 +1200 |
commit | e4feba54330e1afcfb8d48bce8c474659aba281c (patch) | |
tree | e3b7369a66f309e8228aac26a4fe8f5e932debcf /libpathod/language/message.py | |
parent | 2ee60783b694b6a8555a6afbef21dc1f2ca1f8b9 (diff) | |
download | mitmproxy-e4feba54330e1afcfb8d48bce8c474659aba281c.tar.gz mitmproxy-e4feba54330e1afcfb8d48bce8c474659aba281c.tar.bz2 mitmproxy-e4feba54330e1afcfb8d48bce8c474659aba281c.zip |
Introduce and enfoce uniqueness constraints for language components
Diffstat (limited to 'libpathod/language/message.py')
-rw-r--r-- | libpathod/language/message.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libpathod/language/message.py b/libpathod/language/message.py index b5ef7045..dbc0cfdd 100644 --- a/libpathod/language/message.py +++ b/libpathod/language/message.py @@ -1,5 +1,5 @@ import abc -from . import actions +from . import actions, exceptions LOG_TRUNCATE = 1024 @@ -9,6 +9,17 @@ class Message(object): logattrs = [] def __init__(self, tokens): + track = set([]) + for i in tokens: + if i.unique_name: + if i.unique_name in track: + raise exceptions.ParseException( + "Message has multiple %s clauses, " + "but should only have one." % i.unique_name, + 0, 0 + ) + else: + track.add(i.unique_name) self.tokens = tokens def toks(self, klass): |