/*\ * LBPP - A GNU Compiler Compiler (GCC) Liberty Basic Frontend * Copyright (C) 2001 Anthony Liguori * * LBPP is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * LBPP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \*/ #include #include #include #include #include "lbpp.h" void output_variable(FILE *f, Variable *var) { fprintf(f, "add_variable(cxt, \"%s\", ", var->name); if (var->type == STRING) { fprintf(f, "STRING"); } else if (var->type == DOUBLE) { fprintf(f, "DOUBLE"); } fprintf(f, ", %d, %d);\n", var->rows, var->columns); } void output_var_table(FILE *f) { int i; for (i = 0; i < var_table_size; ++i) { fprintf(f, "lb_add_var(cxt, \"%s\", ", var_table[i].name); switch (var_table[i].type) { case UNKNOWN: fprintf(f, "UNKNOWN"); break; case STRING: fprintf(f, " STRING"); break; case DOUBLE: fprintf(f, " DOUBLE"); break; case HANDLE: fprintf(f, " HANDLE"); break; case LVALUE: fprintf(f, " LVALUE"); break; case KEYWORD: fprintf(f, " KEYWORD"); break; case LABEL: fprintf(f, " LABEL"); break; default: break; } fprintf(f, ", %d, %d);\n", var_table[i].rows, var_table[i].columns); } } void output_label_table(FILE *f) { int i; for (i = 0; i < label_table_size; ++i) { fprintf(f, "lb_add_label(cxt, \"%s\");\n", label_table[i].name); } } void output_statement_table(FILE *f) { int i; for (i = 0; i < statement_table_size; i++) { int j; Statement *stmt = &statement_table[i]; if (stmt->dirty) { fprintf(f, "*"); } fprintf(f, "statement_table[%d] = [%s] ", i, stmt->name); for (j = 0; j < stmt->arg_size; j++) { if (stmt->arg[j].literal) { fprintf(f, "%s ", stmt->arg[j].arg.string); } else { switch (stmt->arg[j].arg.type) { case STRING: fprintf(f, " "); break; case DOUBLE: fprintf(f, " "); break; case HANDLE: fprintf(f, " "); break; case LVALUE: fprintf(f, " "); break; case KEYWORD: fprintf(f, " "); break; case LABEL: fprintf(f, "