/*\ * 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 \*/ #ifndef _LB2C_H #define _LB2C_H #define COMMENT_CHAR '\'' #define COMMENT_STR "REM" #define LET_STR "LET" #define DIM_STR "DIM" #define DECLARE_STR "DECLARE" #define STATEMENT_STR "STATEMENT" #define FUNCTION_STR "FUNCTION" #include #include typedef enum { UNKNOWN, STRING, DOUBLE, HANDLE, LVALUE, KEYWORD, LABEL, VAR_ARG } Type; typedef struct _label_tag { jmp_buf jmp; char *name; } Label; typedef struct _variable_tag { Type type; char *name; void *data; int rows; int columns; } Variable; typedef struct _arg_tag { int literal; int reference; union { Type type; char *string; } arg; } Arg; typedef struct _statement_tag { char *name; int dirty; Arg *arg; int arg_size; } Statement; typedef struct _function_tag { char *name; int dirty; Type type; Arg *arg; int arg_size; } Function; int get_line(char *buf, int size, FILE *f); char *skip_space(char *buf); char *skip_symbol(char *buf); char *skip_expr(char *buf); char *skip_param(char *buf); char *skip_string(char *buf); char *skip_string_lit(char *buf); char *skip_bool(char *buf); char *skip_vararg(char *buf); void peek_expr(char *buf, Type *type); int add_label(char *ptr); int add_variable(char *ptr); int add_statement(char *ptr); int add_function_decl(char *ptr); int check_assignment(char *buf); int lookup_label(char *name); int lookup_variable(char *name); int lookup_function(char *name); void translate_line(FILE *f, char *ptr); void translate_assignment(FILE *f, char *ptr); void translate_label(FILE *f, int i); void translate_statement(FILE *f, char *ptr); void translate_variable(FILE *f, char *ptr); void translate_function(FILE *f, char *ptr, int i); void translate_string(FILE *f, char *ptr); void translate_expr(FILE *f, char *ptr); void translate_bool(FILE *f, char *ptr); void translate_vararg(FILE *f, char *ptr); void translate_vararg_ref(FILE *f, char *ptr); void output_statement_table(FILE *f); void output_label_table(FILE *f); void output_var_table(FILE *f); void output_function_table(FILE *f); extern Variable *var_table; extern int var_table_capacity; extern int var_table_size; extern Label *label_table; extern int label_table_capacity; extern int label_table_size; extern Statement *statement_table; extern int statement_table_capacity; extern int statement_table_size; extern Function *function_table; extern int function_table_capacity; extern int function_table_size; extern int current_line; #endif