Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
09415ff0
Unverified
Kaydet (Commit)
09415ff0
authored
Nis 23, 2019
tarafından
Inada Naoki
Kaydeden (comit)
GitHub
Nis 23, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix warnings by adding more const (GH-12924)
üst
57491347
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
23 deletions
+18
-23
grammar.h
Include/grammar.h
+1
-1
parsermodule.c
Modules/parsermodule.c
+1
-2
acceler.c
Parser/acceler.c
+7
-9
grammar1.c
Parser/grammar1.c
+2
-3
parser.c
Parser/parser.c
+6
-7
parser.h
Parser/parser.h
+1
-1
No files found.
Include/grammar.h
Dosyayı görüntüle @
09415ff0
...
...
@@ -66,7 +66,7 @@ typedef struct {
}
grammar
;
/* FUNCTIONS */
dfa
*
PyGrammar_FindDFA
(
grammar
*
g
,
int
type
);
const
dfa
*
PyGrammar_FindDFA
(
grammar
*
g
,
int
type
);
const
char
*
PyGrammar_LabelRepr
(
label
*
lb
);
void
PyGrammar_AddAccelerators
(
grammar
*
g
);
void
PyGrammar_RemoveAccelerators
(
grammar
*
);
...
...
Modules/parsermodule.c
Dosyayı görüntüle @
09415ff0
...
...
@@ -644,7 +644,6 @@ validate_node(node *tree)
{
int
type
=
TYPE
(
tree
);
int
nch
=
NCH
(
tree
);
dfa
*
nt_dfa
;
state
*
dfa_state
;
int
pos
,
arc
;
...
...
@@ -654,7 +653,7 @@ validate_node(node *tree)
PyErr_Format
(
parser_error
,
"Unrecognized node type %d."
,
TYPE
(
tree
));
return
0
;
}
nt_dfa
=
&
_PyParser_Grammar
.
g_dfa
[
type
];
const
dfa
*
nt_dfa
=
&
_PyParser_Grammar
.
g_dfa
[
type
];
REQ
(
tree
,
nt_dfa
->
d_type
);
/* Run the DFA for this nonterminal. */
...
...
Parser/acceler.c
Dosyayı görüntüle @
09415ff0
...
...
@@ -17,15 +17,14 @@
#include "parser.h"
/* Forward references */
static
void
fixdfa
(
grammar
*
,
dfa
*
);
static
void
fixdfa
(
grammar
*
,
const
dfa
*
);
static
void
fixstate
(
grammar
*
,
state
*
);
void
PyGrammar_AddAccelerators
(
grammar
*
g
)
{
dfa
*
d
;
int
i
;
d
=
g
->
g_dfa
;
const
dfa
*
d
=
g
->
g_dfa
;
for
(
i
=
g
->
g_ndfas
;
--
i
>=
0
;
d
++
)
fixdfa
(
g
,
d
);
g
->
g_accel
=
1
;
...
...
@@ -34,10 +33,9 @@ PyGrammar_AddAccelerators(grammar *g)
void
PyGrammar_RemoveAccelerators
(
grammar
*
g
)
{
dfa
*
d
;
int
i
;
g
->
g_accel
=
0
;
d
=
g
->
g_dfa
;
const
dfa
*
d
=
g
->
g_dfa
;
for
(
i
=
g
->
g_ndfas
;
--
i
>=
0
;
d
++
)
{
state
*
s
;
int
j
;
...
...
@@ -51,7 +49,7 @@ PyGrammar_RemoveAccelerators(grammar *g)
}
static
void
fixdfa
(
grammar
*
g
,
dfa
*
d
)
fixdfa
(
grammar
*
g
,
const
dfa
*
d
)
{
state
*
s
;
int
j
;
...
...
@@ -63,7 +61,7 @@ fixdfa(grammar *g, dfa *d)
static
void
fixstate
(
grammar
*
g
,
state
*
s
)
{
arc
*
a
;
const
arc
*
a
;
int
k
;
int
*
accel
;
int
nl
=
g
->
g_ll
.
ll_nlabels
;
...
...
@@ -78,14 +76,14 @@ fixstate(grammar *g, state *s)
a
=
s
->
s_arc
;
for
(
k
=
s
->
s_narcs
;
--
k
>=
0
;
a
++
)
{
int
lbl
=
a
->
a_lbl
;
label
*
l
=
&
g
->
g_ll
.
ll_label
[
lbl
];
const
label
*
l
=
&
g
->
g_ll
.
ll_label
[
lbl
];
int
type
=
l
->
lb_type
;
if
(
a
->
a_arrow
>=
(
1
<<
7
))
{
printf
(
"XXX too many states!
\n
"
);
continue
;
}
if
(
ISNONTERMINAL
(
type
))
{
dfa
*
d1
=
PyGrammar_FindDFA
(
g
,
type
);
const
dfa
*
d1
=
PyGrammar_FindDFA
(
g
,
type
);
int
ibit
;
if
(
type
-
NT_OFFSET
>=
(
1
<<
7
))
{
printf
(
"XXX too high nonterminal number!
\n
"
);
...
...
Parser/grammar1.c
Dosyayı görüntüle @
09415ff0
...
...
@@ -7,12 +7,11 @@
/* Return the DFA for the given type */
dfa
*
const
dfa
*
PyGrammar_FindDFA
(
grammar
*
g
,
int
type
)
{
dfa
*
d
;
/* Massive speed-up */
d
=
&
g
->
g_dfa
[
type
-
NT_OFFSET
];
const
dfa
*
d
=
&
g
->
g_dfa
[
type
-
NT_OFFSET
];
assert
(
d
->
d_type
==
type
);
return
d
;
}
...
...
Parser/parser.c
Dosyayı görüntüle @
09415ff0
...
...
@@ -35,7 +35,7 @@ s_reset(stack *s)
#define s_empty(s) ((s)->s_top == &(s)->s_base[MAXSTACK])
static
int
s_push
(
stack
*
s
,
dfa
*
d
,
node
*
parent
)
s_push
(
stack
*
s
,
const
dfa
*
d
,
node
*
parent
)
{
stackentry
*
top
;
if
(
s
->
s_top
==
s
->
s_base
)
{
...
...
@@ -119,7 +119,7 @@ shift(stack *s, int type, char *str, int newstate, int lineno, int col_offset,
}
static
int
push
(
stack
*
s
,
int
type
,
dfa
*
d
,
int
newstate
,
int
lineno
,
int
col_offset
,
push
(
stack
*
s
,
int
type
,
const
dfa
*
d
,
int
newstate
,
int
lineno
,
int
col_offset
,
int
end_lineno
,
int
end_col_offset
)
{
int
err
;
...
...
@@ -144,7 +144,7 @@ classify(parser_state *ps, int type, const char *str)
int
n
=
g
->
g_ll
.
ll_nlabels
;
if
(
type
==
NAME
)
{
label
*
l
=
g
->
g_ll
.
ll_label
;
const
label
*
l
=
g
->
g_ll
.
ll_label
;
int
i
;
for
(
i
=
n
;
i
>
0
;
i
--
,
l
++
)
{
if
(
l
->
lb_type
!=
NAME
||
l
->
lb_str
==
NULL
||
...
...
@@ -168,7 +168,7 @@ classify(parser_state *ps, int type, const char *str)
}
{
label
*
l
=
g
->
g_ll
.
ll_label
;
const
label
*
l
=
g
->
g_ll
.
ll_label
;
int
i
;
for
(
i
=
n
;
i
>
0
;
i
--
,
l
++
)
{
if
(
l
->
lb_type
==
type
&&
l
->
lb_str
==
NULL
)
{
...
...
@@ -246,7 +246,7 @@ PyParser_AddToken(parser_state *ps, int type, char *str,
/* Loop until the token is shifted or an error occurred */
for
(;;)
{
/* Fetch the current dfa and state */
dfa
*
d
=
ps
->
p_stack
.
s_top
->
s_dfa
;
const
dfa
*
d
=
ps
->
p_stack
.
s_top
->
s_dfa
;
state
*
s
=
&
d
->
d_state
[
ps
->
p_stack
.
s_top
->
s_state
];
D
(
printf
(
" DFA '%s', state %d:"
,
...
...
@@ -260,7 +260,6 @@ PyParser_AddToken(parser_state *ps, int type, char *str,
/* Push non-terminal */
int
nt
=
(
x
>>
8
)
+
NT_OFFSET
;
int
arrow
=
x
&
((
1
<<
7
)
-
1
);
dfa
*
d1
;
if
(
nt
==
func_body_suite
&&
!
(
ps
->
p_flags
&
PyCF_TYPE_COMMENTS
))
{
/* When parsing type comments is not requested,
we can provide better errors about bad indentation
...
...
@@ -268,7 +267,7 @@ PyParser_AddToken(parser_state *ps, int type, char *str,
D
(
printf
(
" [switch func_body_suite to suite]"
));
nt
=
suite
;
}
d1
=
PyGrammar_FindDFA
(
const
dfa
*
d1
=
PyGrammar_FindDFA
(
ps
->
p_grammar
,
nt
);
if
((
err
=
push
(
&
ps
->
p_stack
,
nt
,
d1
,
arrow
,
lineno
,
col_offset
,
...
...
Parser/parser.h
Dosyayı görüntüle @
09415ff0
...
...
@@ -11,7 +11,7 @@ extern "C" {
typedef
struct
{
int
s_state
;
/* State in current DFA */
dfa
*
s_dfa
;
/* Current DFA */
const
dfa
*
s_dfa
;
/* Current DFA */
struct
_node
*
s_parent
;
/* Where to add next node */
}
stackentry
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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