Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
36837892
Commit
36837892
authored
Apr 14, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Clean up and add comments to makeqstrdata.
parent
bc9ec500
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/makeqstrdata.py
+9
-2
9 additions, 2 deletions
py/makeqstrdata.py
with
9 additions
and
2 deletions
py/makeqstrdata.py
+
9
−
2
View file @
36837892
...
@@ -25,13 +25,20 @@ def compute_hash(qstr):
...
@@ -25,13 +25,20 @@ def compute_hash(qstr):
return
hash
&
0xffff
return
hash
&
0xffff
# given a list of (name,regex) pairs, find the first one that matches the given line
# 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
:
for
name
,
regex
in
regexs
:
match
=
re
.
match
(
regex
,
line
)
match
=
re
.
match
(
regex
,
line
)
if
match
:
if
match
:
return
name
,
match
return
name
,
match
return
None
,
None
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
):
def
do_work
(
infiles
):
# read the qstrs in from the input files
# read the qstrs in from the input files
qstrs
=
{}
qstrs
=
{}
...
@@ -47,7 +54,7 @@ def do_work(infiles):
...
@@ -47,7 +54,7 @@ def do_work(infiles):
continue
continue
# work out what kind of line it is
# 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
:
if
match_kind
is
None
:
# unknown line format
# unknown line format
print
(
'
({}:{}) bad qstr format, got {}
'
.
format
(
infile
,
line_number
,
line
),
file
=
sys
.
stderr
)
print
(
'
({}:{}) bad qstr format, got {}
'
.
format
(
infile
,
line_number
,
line
),
file
=
sys
.
stderr
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment