This repository has been archived by the owner on Aug 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprof_compiled.py
73 lines (59 loc) · 1.63 KB
/
prof_compiled.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
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
68
69
70
71
72
73
# File automatically generated by RBNF.
from rbnf.std.common import (recover_codes)
from rbnf.bootstrap import loader as ruiko
ulang = ruiko.Language('ulang')
@ulang
class pattern(ruiko.Lexer):
@staticmethod
def regex():
return ['[^/\\sa-z]+']
@ulang
class url(ruiko.Parser):
@staticmethod
def bnf():
return ruiko.Bind(
'result',
ruiko.And([
ruiko.Or([ruiko.C('https:'),
ruiko.C('http:')]),
ruiko.C('//'),
ruiko.Seq(ruiko.N('pattern'), 1, -1),
ruiko.Seq(
ruiko.And([ruiko.C('/'), ruiko.N('pattern')]), 0, -1),
ruiko.Seq(ruiko.C('/'), 0, 1)
]))
@staticmethod
def rewrite(state):
(result, ) = map(state.ctx.get, ('result', ))
return result
@ulang
class text(ruiko.Parser):
@staticmethod
def bnf():
return ruiko.Seq(
ruiko.Or([
ruiko.Push('urls', ruiko.Named('url')),
ruiko.AnyNot(ruiko.Named('url'))
]), 1, -1)
@staticmethod
def rewrite(state):
(urls, ) = map(state.ctx.get, ('urls', ))
return tuple((recover_codes(each) for each in urls))
@ulang
class pattern(ruiko.Lexer):
@staticmethod
def regex():
return ['[a-zA-Z0-9_]+']
@ulang
class space(ruiko.Lexer):
@staticmethod
def regex():
return ['\\s+']
ulang.ignore()
ulang.build()
ulang.as_fixed()
_impl = ulang.implementation
from rbnf.core.State import State
_ze_exp = text.match
lexer = ulang.lexer
ze_exp = lambda text: _ze_exp(tuple(lexer(text)), State(_impl))