Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
36837892
Commit
36837892
authored
Apr 14, 2014
by
Damien George
Browse files
py: Clean up and add comments to makeqstrdata.
parent
bc9ec500
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/makeqstrdata.py
View file @
36837892
...
...
@@ -25,13 +25,20 @@ def compute_hash(qstr):
return
hash
&
0xffff
# given a list of (name,regex) pairs, find the first one that matches the given line
def
re_match
(
regexs
,
line
):
def
re_match
_first
(
regexs
,
line
):
for
name
,
regex
in
regexs
:
match
=
re
.
match
(
regex
,
line
)
if
match
:
return
name
,
match
return
None
,
None
# regexs to recognise lines that the CPP emits
# use a list so that matching order is honoured
cpp_regexs
=
[
(
'qstr'
,
r
'Q\((.+)\)$'
),
(
'cdecl'
,
r
'(typedef|extern) [A-Za-z0-9_* ]+;$'
)
]
def
do_work
(
infiles
):
# read the qstrs in from the input files
qstrs
=
{}
...
...
@@ -47,7 +54,7 @@ def do_work(infiles):
continue
# work out what kind of line it is
match_kind
,
match
=
re_match
([(
'qstr'
,
r
'Q\((.+)\)$'
),
(
'cdecl'
,
r
'(typedef|extern) [A-Za-z0-9_* ]+;$'
)]
,
line
)
match_kind
,
match
=
re_match
_first
(
cpp_regexs
,
line
)
if
match_kind
is
None
:
# unknown line format
print
(
'({}:{}) bad qstr format, got {}'
.
format
(
infile
,
line_number
,
line
),
file
=
sys
.
stderr
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment