Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(60)

Unified Diff: Parser/grammar.c

Issue 3353: make built-in tokenizer available via Python C API
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Parser/grammar1.c ('k') | Parser/listnode.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Parser/grammar.c
+++ b/Parser/grammar.c
@@ -149,7 +149,7 @@ translabel(grammar *g, label *lb)
if (Py_DebugFlag)
printf("Translating label %s ...\n", PyGrammar_LabelRepr(lb));
- if (lb->lb_type == NAME) {
+ if (lb->lb_type == PYTOK_NAME) {
for (i = 0; i < g->g_ndfas; i++) {
if (strcmp(lb->lb_str, g->g_dfa[i].d_name) == 0) {
if (Py_DebugFlag)
@@ -163,7 +163,7 @@ translabel(grammar *g, label *lb)
return;
}
}
- for (i = 0; i < (int)N_TOKENS; i++) {
+ for (i = 0; i < (int)PYTOK_N_TOKENS; i++) {
if (strcmp(lb->lb_str, _PyParser_TokenNames[i]) == 0) {
if (Py_DebugFlag)
printf("Label %s is terminal %d.\n",
@@ -174,11 +174,11 @@ translabel(grammar *g, label *lb)
return;
}
}
- printf("Can't translate NAME label '%s'\n", lb->lb_str);
+ printf("Can't translate PYTOK_NAME label '%s'\n", lb->lb_str);
return;
}
- if (lb->lb_type == STRING) {
+ if (lb->lb_type == PYTOK_STRING) {
if (isalpha(Py_CHARMASK(lb->lb_str[1])) ||
lb->lb_str[1] == '_') {
char *p;
@@ -187,7 +187,7 @@ translabel(grammar *g, label *lb)
size_t name_len;
if (Py_DebugFlag)
printf("Label %s is a keyword\n", lb->lb_str);
- lb->lb_type = NAME;
+ lb->lb_type = PYTOK_NAME;
src = lb->lb_str + 1;
p = strchr(src, '\'');
if (p)
@@ -206,42 +206,42 @@ translabel(grammar *g, label *lb)
}
else if (lb->lb_str[2] == lb->lb_str[0]) {
int type = (int) PyToken_OneChar(lb->lb_str[1]);
- if (type != OP) {
+ if (type != PYTOK_OP) {
lb->lb_type = type;
free(lb->lb_str);
lb->lb_str = NULL;
}
else
- printf("Unknown OP label %s\n",
+ printf("Unknown PYTOK_OP label %s\n",
lb->lb_str);
}
else if (lb->lb_str[2] && lb->lb_str[3] == lb->lb_str[0]) {
int type = (int) PyToken_TwoChars(lb->lb_str[1],
lb->lb_str[2]);
- if (type != OP) {
+ if (type != PYTOK_OP) {
lb->lb_type = type;
free(lb->lb_str);
lb->lb_str = NULL;
}
else
- printf("Unknown OP label %s\n",
+ printf("Unknown PYTOK_OP label %s\n",
lb->lb_str);
}
else if (lb->lb_str[2] && lb->lb_str[3] && lb->lb_str[4] == lb->lb_str[0]) {
int type = (int) PyToken_ThreeChars(lb->lb_str[1],
lb->lb_str[2],
lb->lb_str[3]);
- if (type != OP) {
+ if (type != PYTOK_OP) {
lb->lb_type = type;
free(lb->lb_str);
lb->lb_str = NULL;
}
else
- printf("Unknown OP label %s\n",
+ printf("Unknown PYTOK_OP label %s\n",
lb->lb_str);
}
else
- printf("Can't translate STRING label %s\n",
+ printf("Can't translate PYTOK_STRING label %s\n",
lb->lb_str);
}
else
« no previous file with comments | « Parser/grammar1.c ('k') | Parser/listnode.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+