mscregexp.py 1.59 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
# -*- coding: utf-8 -*-
'''
In this module are defined the lexical rules of MSC.

This rules can be used with QT Regular Expresion

'''
from PySide.QtCore import QRegExp

letter = "[a-zA-Z]"
u""" Lexical rule for letter """

decimal_digit = "[0-9]"
u""" decimal_digit declaration """

national = "[`¤\{}~^]"
u"""National declaration"""
alphanumeric = letter + '|' + decimal_digit + '|' + national
full_stop = "[.]"
underline = "_"


other_character = """[?%+-!/*"=]"""
special = "[@$()\[\]<>#,;:]"
space = "[\s\t]"
apostrophe = "'"
qualifier_left = '<<'
qualifier_right = '>>'

Name = ("(?:" + letter +
        '|' + decimal_digit +
        '|' + full_stop +
        '|' + underline +
        ')+')
u"""Name declaration"""


NameErrorMsg = ("Only letters(a-z, A-Z), decimal digits(0-9), full stop (.), "
                "and underline(_) is allowed")

Text = ('(?:' + alphanumeric +
        '|' + other_character +
        '|' + special +
        '|' + full_stop +
        '|' + underline +
        '|' + space +
        '|' + apostrophe + ')*')
u"""Text declaration"""

Qualifier = qualifier_left + Text + qualifier_right
u"""Qualifier declaration"""

InstanceKind = ('(' + Name + ')?' + '\s?' +
                '(' + Qualifier + ')?' + '\s?' + Name)
u"""InstanceKind declaration"""

MscNameRegExp = QRegExp(Name)
u"""QRegExp created with :py:data:`Name`"""

MscTextRegExp = QRegExp(Text)
u"""QRegExp created with :py:data:`Text`"""

MscQualifierRegExp = QRegExp(Qualifier)
u"""QRegExp created with :py:data:`Qualifier`"""

MscInstanceKindRegExp = QRegExp(InstanceKind)
u"""QRegExp created with :py:data:`InstanceKind`"""