--- /dev/null
+Use non-NULL default values in the PEG parser keyword list to overcome a bug that was preventing\r
+Python from being properly compiled when using the XLC compiler. Patch by Pablo Galindo.\r
#endif
static const int n_keyword_lists = 15;
static KeywordToken *reserved_keywords[] = {
- NULL,
- NULL,
+ (KeywordToken[]) {{NULL, -1}},
+ (KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {
{"if", 510},
{"in", 518},
{"nonlocal", 509},
{NULL, -1},
},
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
+ (KeywordToken[]) {{NULL, -1}},
+ (KeywordToken[]) {{NULL, -1}},
+ (KeywordToken[]) {{NULL, -1}},
+ (KeywordToken[]) {{NULL, -1}},
+ (KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {
{"__peg_parser__", 531},
{NULL, -1},
static int
_get_keyword_or_name_type(Parser *p, const char *name, int name_len)
{
- if (name_len >= p->n_keyword_lists || p->keywords[name_len] == NULL) {
+ assert(name_len != 0);
+ if (name_len >= p->n_keyword_lists ||
+ p->keywords[name_len] == NULL ||
+ p->keywords[name_len]->type == -1) {
return NAME;
}
- for (KeywordToken *k = p->keywords[name_len]; k->type != -1; k++) {
+ for (KeywordToken *k = p->keywords[name_len]; k != NULL && k->type != -1; k++) {
if (strncmp(k->str, name, name_len) == 0) {
return k->type;
}
num_groups = max(groups) + 1 if groups else 1
for keywords_length in range(num_groups):
if keywords_length not in groups.keys():
- self.print("NULL,")
+ self.print("(KeywordToken[]) {{NULL, -1}},")
else:
self.print("(KeywordToken[]) {")
with self.indent():