-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfc3966.py
30 lines (29 loc) · 2.07 KB
/
rfc3966.py
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
import rfc5234
from qwer import *
visualSeparator = qwer('[-().]')
phonedigit = qwer('(?:', rule('rfc5234.DIGIT'), '|(?:', rule('visualSeparator'), ')?)')
globalNumberDigits = qwer('\+(?:', rule('phonedigit'), ')*', rule('rfc5234.DIGIT'), '(?:', rule('phonedigit'), ')*')
alphanum = qwer('(?:', rule('rfc5234.ALPHA'), '|', rule('rfc5234.DIGIT'), ')')
pname = qwer('(?:', rule('alphanum'), '|-)+')
paramUnreserved = qwer('[]$&+/:[]')
mark = qwer('[-!\'()*._~]')
unreserved = qwer('(?:', rule('alphanum'), '|', rule('mark'), ')')
pctEncoded = qwer('%', rule('rfc5234.HEXDIG'), rule('rfc5234.HEXDIG'))
paramchar = qwer('(?:', rule('paramUnreserved'), '|', rule('unreserved'), '|', rule('pctEncoded'), ')')
pvalue = qwer('(?:', rule('paramchar'), ')+')
parameter = qwer(';', rule('pname'), '(?:=', rule('pvalue'), ')?')
extension = qwer(';ext=(?:', rule('phonedigit'), ')+')
reserved = qwer('[$&+,/:;=?@]')
uric = qwer('(?:', rule('reserved'), '|', rule('unreserved'), '|', rule('pctEncoded'), ')')
isdnSubaddress = qwer(';isub=(?:', rule('uric'), ')+')
par = qwer('(?:', rule('parameter'), '|', rule('extension'), '|', rule('isdnSubaddress'), ')')
globalNumber = qwer(rule('globalNumberDigits'), '(?:', rule('par'), ')*')
phonedigitHex = qwer('(?:', rule('rfc5234.HEXDIG'), '|\*|#|(?:', rule('visualSeparator'), ')?)')
localNumberDigits = qwer('(?:', rule('phonedigitHex'), ')*(?:', rule('rfc5234.HEXDIG'), '|\*|#)(?:', rule('phonedigitHex'), ')*')
domainlabel = qwer('(?:', rule('alphanum'), '|', rule('alphanum'), '(?:', rule('alphanum'), '|-)*', rule('alphanum'), ')')
toplabel = qwer('(?:', rule('rfc5234.ALPHA'), '|', rule('rfc5234.ALPHA'), '(?:', rule('alphanum'), '|-)*', rule('alphanum'), ')')
domainname = qwer('(?:', rule('domainlabel'), '\.)*', rule('toplabel'), '\.?')
descriptor = qwer('(?:', rule('domainname'), '|', rule('globalNumberDigits'), ')')
context = qwer(';phone-context=', rule('descriptor'))
localNumber = qwer(rule('localNumberDigits'), '(?:', rule('par'), ')*', rule('context'), '(?:', rule('par'), ')*')
telephoneSubscriber = qwer('(?:', rule('globalNumber'), '|', rule('localNumber'), ')')