AST_expr* readASTExpr(BufferedReader* reader) { uint8_t type = reader->readByte(); if (VERBOSITY("parsing") >= 2) printf("type = %d\n", type); if (type == 0) return NULL; uint8_t checkbyte = reader->readByte(); assert(checkbyte == 0xae); switch (type) { case AST_TYPE::Attribute: return read_attribute(reader); case AST_TYPE::BinOp: return read_binop(reader); case AST_TYPE::BoolOp: return read_boolop(reader); case AST_TYPE::Call: return read_call(reader); case AST_TYPE::Compare: return read_compare(reader); case AST_TYPE::Dict: return read_dict(reader); case AST_TYPE::DictComp: return read_dictcomp(reader); case AST_TYPE::IfExp: return read_ifexp(reader); case AST_TYPE::Index: return read_index(reader); case AST_TYPE::Lambda: return read_lambda(reader); case AST_TYPE::List: return read_list(reader); case AST_TYPE::ListComp: return read_listcomp(reader); case AST_TYPE::Name: return read_name(reader); case AST_TYPE::Num: return read_num(reader); case AST_TYPE::Repr: return read_repr(reader); case AST_TYPE::Slice: return read_slice(reader); case AST_TYPE::Str: return read_str(reader); case AST_TYPE::Subscript: return read_subscript(reader); case AST_TYPE::Tuple: return read_tuple(reader); case AST_TYPE::UnaryOp: return read_unaryop(reader); default: fprintf(stderr, "Unknown expr node type (parser.cpp:" STRINGIFY(__LINE__) "): %d\n", type); abort(); break; } }
PCFOP * read_instr(struct PCFState * st, const char * line, uint32_t iptr) { char buf[LINE_MAX], *bitr; buf[0] = '\0'; bitr = buf; assert(line[0] == '('); line++; while((line[0] != ' ') && (line[0] != ')')) { bitr[0] = line[0]; line++; bitr++; } bitr[0] = '\0'; if(strcmp(buf, "LABEL") == 0) return read_label(line, st, iptr); else if(strcmp(buf, "INITBASE") == 0) return read_initbase(line); else if(strcmp(buf, "CONST") == 0) return read_const(line); else if(strcmp(buf, "GATE") == 0) return read_gate(line); else if(strcmp(buf, "BITS") == 0) return read_bits(line); else if(strcmp(buf, "MKPTR") == 0) return read_mkptr(line); else if(strcmp(buf, "COPY") == 0) return read_copy(line); else if(strcmp(buf, "COPY-INDIR") == 0) return read_copy_indir(line); else if(strcmp(buf, "INDIR-COPY") == 0) return read_indir_copy(line); else if(strcmp(buf, "CALL") == 0) return read_call(line); else if(strcmp(buf, "RET") == 0) return read_ret(line); else if(strcmp(buf, "BRANCH") == 0) return read_branch(line); else if(strcmp(buf, "CLEAR") == 0) return read_clear(line); else if(strcmp(buf, "JOIN") == 0) return read_join(line); else if(strcmp(buf, "ADD") == 0) return read_add(line); else if(strcmp(buf, "MUL") == 0) return read_mul(line); assert(0); }