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
5124a940
Commit
5124a940
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/lexer: Convert mp_uint_t to size_t where appropriate.
parent
d87c6b67
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/lexer.c
+8
-8
8 additions, 8 deletions
py/lexer.c
py/lexer.h
+7
-7
7 additions, 7 deletions
py/lexer.h
with
15 additions
and
15 deletions
py/lexer.c
+
8
−
8
View file @
5124a940
...
...
@@ -157,7 +157,7 @@ STATIC void next_char(mp_lexer_t *lex) {
}
}
STATIC
void
indent_push
(
mp_lexer_t
*
lex
,
mp_uint
_t
indent
)
{
STATIC
void
indent_push
(
mp_lexer_t
*
lex
,
size
_t
indent
)
{
if
(
lex
->
num_indent_level
>=
lex
->
alloc_indent_level
)
{
// TODO use m_renew_maybe and somehow indicate an error if it fails... probably by using MP_TOKEN_MEMORY_ERROR
lex
->
indent_level
=
m_renew
(
uint16_t
,
lex
->
indent_level
,
lex
->
alloc_indent_level
,
lex
->
alloc_indent_level
+
MICROPY_ALLOC_LEXEL_INDENT_INC
);
...
...
@@ -166,7 +166,7 @@ STATIC void indent_push(mp_lexer_t *lex, mp_uint_t indent) {
lex
->
indent_level
[
lex
->
num_indent_level
++
]
=
indent
;
}
STATIC
mp_uint
_t
indent_top
(
mp_lexer_t
*
lex
)
{
STATIC
size
_t
indent_top
(
mp_lexer_t
*
lex
)
{
return
lex
->
indent_level
[
lex
->
num_indent_level
-
1
];
}
...
...
@@ -263,7 +263,7 @@ STATIC const char *const tok_kw[] = {
// This is called with CUR_CHAR() before first hex digit, and should return with
// it pointing to last hex digit
// num_digits must be greater than zero
STATIC
bool
get_hex
(
mp_lexer_t
*
lex
,
mp_uint
_t
num_digits
,
mp_uint_t
*
result
)
{
STATIC
bool
get_hex
(
mp_lexer_t
*
lex
,
size
_t
num_digits
,
mp_uint_t
*
result
)
{
mp_uint_t
num
=
0
;
while
(
num_digits
--
!=
0
)
{
next_char
(
lex
);
...
...
@@ -354,7 +354,7 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) {
default:
if
(
c
>=
'0'
&&
c
<=
'7'
)
{
// Octal sequence, 1-3 chars
mp_uint
_t
digits
=
3
;
size
_t
digits
=
3
;
mp_uint_t
num
=
c
-
'0'
;
while
(
is_following_odigit
(
lex
)
&&
--
digits
!=
0
)
{
next_char
(
lex
);
...
...
@@ -458,7 +458,7 @@ void mp_lexer_to_next(mp_lexer_t *lex) {
}
else
if
(
had_physical_newline
&&
lex
->
nested_bracket_level
==
0
)
{
lex
->
tok_kind
=
MP_TOKEN_NEWLINE
;
mp_uint
_t
num_spaces
=
lex
->
column
-
1
;
size
_t
num_spaces
=
lex
->
column
-
1
;
if
(
num_spaces
==
indent_top
(
lex
))
{
}
else
if
(
num_spaces
>
indent_top
(
lex
))
{
indent_push
(
lex
,
num_spaces
);
...
...
@@ -622,7 +622,7 @@ void mp_lexer_to_next(mp_lexer_t *lex) {
// search for encoded delimiter or operator
const
char
*
t
=
tok_enc
;
mp_uint
_t
tok_enc_index
=
0
;
size
_t
tok_enc_index
=
0
;
for
(;
*
t
!=
0
&&
!
is_char
(
lex
,
*
t
);
t
+=
1
)
{
if
(
*
t
==
'e'
||
*
t
==
'c'
)
{
t
+=
1
;
...
...
@@ -644,7 +644,7 @@ void mp_lexer_to_next(mp_lexer_t *lex) {
// get the maximum characters for a valid token
t
+=
1
;
mp_uint
_t
t_index
=
tok_enc_index
;
size
_t
t_index
=
tok_enc_index
;
for
(;;)
{
for
(;
*
t
==
'e'
;
t
+=
1
)
{
t
+=
1
;
...
...
@@ -762,7 +762,7 @@ mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) {
return
lex
;
}
mp_lexer_t
*
mp_lexer_new_from_str_len
(
qstr
src_name
,
const
char
*
str
,
mp_uint
_t
len
,
mp_uint
_t
free_len
)
{
mp_lexer_t
*
mp_lexer_new_from_str_len
(
qstr
src_name
,
const
char
*
str
,
size
_t
len
,
size
_t
free_len
)
{
mp_reader_t
reader
;
if
(
!
mp_reader_new_mem
(
&
reader
,
(
const
byte
*
)
str
,
len
,
free_len
))
{
return
NULL
;
...
...
This diff is collapsed.
Click to expand it.
py/lexer.h
+
7
−
7
View file @
5124a940
...
...
@@ -151,24 +151,24 @@ typedef struct _mp_lexer_t {
unichar
chr0
,
chr1
,
chr2
;
// current cached characters from source
mp_uint
_t
line
;
// current source line
mp_uint
_t
column
;
// current source column
size
_t
line
;
// current source line
size
_t
column
;
// current source column
mp_int_t
emit_dent
;
// non-zero when there are INDENT/DEDENT tokens to emit
mp_int_t
nested_bracket_level
;
// >0 when there are nested brackets over multiple lines
mp_uint
_t
alloc_indent_level
;
mp_uint
_t
num_indent_level
;
size
_t
alloc_indent_level
;
size
_t
num_indent_level
;
uint16_t
*
indent_level
;
mp_uint
_t
tok_line
;
// token source line
mp_uint
_t
tok_column
;
// token source column
size
_t
tok_line
;
// token source line
size
_t
tok_column
;
// token source column
mp_token_kind_t
tok_kind
;
// token kind
vstr_t
vstr
;
// token data
}
mp_lexer_t
;
mp_lexer_t
*
mp_lexer_new
(
qstr
src_name
,
mp_reader_t
reader
);
mp_lexer_t
*
mp_lexer_new_from_str_len
(
qstr
src_name
,
const
char
*
str
,
mp_uint
_t
len
,
mp_uint
_t
free_len
);
mp_lexer_t
*
mp_lexer_new_from_str_len
(
qstr
src_name
,
const
char
*
str
,
size
_t
len
,
size
_t
free_len
);
void
mp_lexer_free
(
mp_lexer_t
*
lex
);
void
mp_lexer_to_next
(
mp_lexer_t
*
lex
);
...
...
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