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

Side by Side Diff: Parser/firstsets.c

Issue 3353: make built-in tokenizer available via Python C API
Patch Set: Created 4 years, 10 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Parser/acceler.c ('k') | Parser/grammar1.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* Computation of FIRST stets */ 2 /* Computation of FIRST stets */
3 3
4 #include "pgenheaders.h" 4 #include "pgenheaders.h"
5 #include "grammar.h" 5 #include "grammar.h"
6 #include "token.h" 6 #include "token.h"
7 7
8 extern int Py_DebugFlag; 8 extern int Py_DebugFlag;
9 9
10 /* Forward */ 10 /* Forward */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 break; 73 break;
74 } 74 }
75 if (j >= nsyms) { /* New label */ 75 if (j >= nsyms) { /* New label */
76 sym = (int *)PyObject_REALLOC(sym, 76 sym = (int *)PyObject_REALLOC(sym,
77 sizeof(int) * (nsyms + 1)); 77 sizeof(int) * (nsyms + 1));
78 if (sym == NULL) 78 if (sym == NULL)
79 Py_FatalError( 79 Py_FatalError(
80 "no mem to resize sym in calcfirstset"); 80 "no mem to resize sym in calcfirstset");
81 sym[nsyms++] = a->a_lbl; 81 sym[nsyms++] = a->a_lbl;
82 type = l0[a->a_lbl].lb_type; 82 type = l0[a->a_lbl].lb_type;
83 if (ISNONTERMINAL(type)) { 83 if (PYTOK_ISNONTERMINAL(type)) {
84 d1 = PyGrammar_FindDFA(g, type); 84 d1 = PyGrammar_FindDFA(g, type);
85 if (d1->d_first == dummy) { 85 if (d1->d_first == dummy) {
86 fprintf(stderr, 86 fprintf(stderr,
87 "Left-recursion below '%s'\n", 87 "Left-recursion below '%s'\n",
88 d->d_name); 88 d->d_name);
89 } 89 }
90 else { 90 else {
91 if (d1->d_first == NULL) 91 if (d1->d_first == NULL)
92 calcfirstset(g, d1); 92 calcfirstset(g, d1);
93 mergebitset(result, 93 mergebitset(result,
94 d1->d_first, nbits); 94 d1->d_first, nbits);
95 } 95 }
96 } 96 }
97 else if (ISTERMINAL(type)) { 97 else if (PYTOK_ISTERMINAL(type)) {
98 addbit(result, a->a_lbl); 98 addbit(result, a->a_lbl);
99 } 99 }
100 } 100 }
101 } 101 }
102 d->d_first = result; 102 d->d_first = result;
103 if (Py_DebugFlag) { 103 if (Py_DebugFlag) {
104 printf("FIRST set for '%s': {", d->d_name); 104 printf("FIRST set for '%s': {", d->d_name);
105 for (i = 0; i < nbits; i++) { 105 for (i = 0; i < nbits; i++) {
106 if (testbit(result, i)) 106 if (testbit(result, i))
107 printf(" %s", PyGrammar_LabelRepr(&l0[i])); 107 printf(" %s", PyGrammar_LabelRepr(&l0[i]));
108 } 108 }
109 printf(" }\n"); 109 printf(" }\n");
110 } 110 }
111 111
112 PyObject_FREE(sym); 112 PyObject_FREE(sym);
113 } 113 }
OLDNEW
« no previous file with comments | « Parser/acceler.c ('k') | Parser/grammar1.c » ('j') | no next file with comments »

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