2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2013-11-04 16:17:01 +01:00
|
|
|
gbc_trans.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-11-04 16:17:01 +01:00
|
|
|
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-11-04 16:17:01 +01:00
|
|
|
This program 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, or (at your option)
|
|
|
|
any later version.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-11-04 16:17:01 +01:00
|
|
|
This program 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.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-11-04 16:17:01 +01:00
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GBC_TRANS_H
|
|
|
|
#define __GBC_TRANS_H
|
|
|
|
|
|
|
|
#include "gbc_type.h"
|
|
|
|
#include "gb_reserved.h"
|
|
|
|
#include "gbc_read.h"
|
|
|
|
#include "gb_limit.h"
|
|
|
|
|
|
|
|
#include "gbc_trans_common.h"
|
|
|
|
|
|
|
|
enum {
|
2013-11-04 16:17:01 +01:00
|
|
|
TT_NOTHING = 0,
|
|
|
|
TT_DO_NOT_CHECK_AS = 1,
|
|
|
|
TT_CAN_EMBED = 2,
|
|
|
|
TT_CAN_ARRAY = 4,
|
|
|
|
TT_CAN_NEW = 8
|
|
|
|
};
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
enum {
|
2013-11-04 16:17:01 +01:00
|
|
|
TS_MODE_READ = 1,
|
|
|
|
TS_MODE_WRITE = 2,
|
|
|
|
TS_MODE_APPEND = 4,
|
|
|
|
TS_MODE_CREATE = 8,
|
|
|
|
TS_MODE_DIRECT = 16,
|
|
|
|
TS_MODE_LINE = 32,
|
|
|
|
TS_MODE_WATCH = 64,
|
|
|
|
TS_MODE_PIPE = 128,
|
|
|
|
TS_MODE_MEMORY = 256,
|
|
|
|
TS_MODE_STRING = 512
|
|
|
|
};
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
enum {
|
2013-11-04 16:17:01 +01:00
|
|
|
TS_EXEC_NONE = 0,
|
|
|
|
TS_EXEC_READ = 1,
|
|
|
|
TS_EXEC_WRITE = 2,
|
|
|
|
TS_EXEC_TERM = 4,
|
|
|
|
TS_EXEC_STRING = 8,
|
2009-05-22 16:52:36 +02:00
|
|
|
TS_EXEC_WAIT = 16
|
2013-11-04 16:17:01 +01:00
|
|
|
};
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
enum {
|
2013-11-04 16:17:01 +01:00
|
|
|
TS_SUBR_PRINT,
|
|
|
|
TS_SUBR_INPUT,
|
|
|
|
TS_SUBR_WRITE,
|
|
|
|
TS_SUBR_WRITE_BYTES,
|
|
|
|
TS_SUBR_READ,
|
|
|
|
TS_SUBR_READ_BYTES,
|
|
|
|
TS_SUBR_OPEN,
|
|
|
|
TS_SUBR_CLOSE,
|
|
|
|
TS_SUBR_SEEK,
|
|
|
|
TS_SUBR_LINE_INPUT,
|
|
|
|
TS_SUBR_FLUSH,
|
|
|
|
TS_SUBR_EXEC,
|
|
|
|
TS_SUBR_SHELL,
|
|
|
|
TS_SUBR_WAIT,
|
|
|
|
TS_SUBR_KILL,
|
|
|
|
TS_SUBR_MOVE,
|
|
|
|
TS_SUBR_MKDIR,
|
|
|
|
TS_SUBR_RMDIR,
|
|
|
|
TS_SUBR_ARRAY,
|
|
|
|
TS_SUBR_COLLECTION,
|
|
|
|
TS_SUBR_COPY,
|
|
|
|
TS_SUBR_LINK,
|
|
|
|
TS_SUBR_ERROR,
|
|
|
|
TS_SUBR_LOCK,
|
|
|
|
TS_SUBR_UNLOCK,
|
2014-03-09 18:51:52 +01:00
|
|
|
TS_SUBR_LOCK_WAIT,
|
2013-11-04 16:17:01 +01:00
|
|
|
TS_SUBR_INPUT_FROM,
|
|
|
|
TS_SUBR_OUTPUT_TO,
|
|
|
|
TS_SUBR_DEBUG,
|
|
|
|
TS_SUBR_SLEEP,
|
|
|
|
TS_SUBR_RANDOMIZE,
|
|
|
|
TS_SUBR_ERROR_TO,
|
|
|
|
TS_SUBR_LEFT,
|
|
|
|
TS_SUBR_MID,
|
2009-09-17 22:58:27 +02:00
|
|
|
TS_SUBR_OPEN_MEMORY,
|
2012-01-15 09:54:57 +01:00
|
|
|
TS_SUBR_CHMOD,
|
|
|
|
TS_SUBR_CHOWN,
|
|
|
|
TS_SUBR_CHGRP
|
2013-11-04 16:17:01 +01:00
|
|
|
};
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
enum {
|
2013-11-04 16:17:01 +01:00
|
|
|
TSO_SUBR_SCAN
|
|
|
|
};
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
enum {
|
2013-11-04 16:17:01 +01:00
|
|
|
TS_NONE = -1,
|
|
|
|
TS_STDIN = 0,
|
|
|
|
TS_STDOUT = 1,
|
|
|
|
TS_STDERR = 2
|
|
|
|
};
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#define TS_NO_SUBR ((void (*)())-1)
|
|
|
|
|
|
|
|
#ifndef __GBC_TRANS_C
|
|
|
|
EXTERN int TRANS_in_affectation;
|
2012-03-02 23:05:55 +01:00
|
|
|
EXTERN bool TRANS_in_try;
|
2009-09-20 19:32:12 +02:00
|
|
|
//EXTERN int TRANS_in_expression;
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif
|
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
#define TRANS_newline() (PATTERN_is_newline(*JOB->current) ? JOB->line = PATTERN_index(*JOB->current) + 1, JOB->current++, TRUE : FALSE)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_reset(void);
|
|
|
|
/*PUBLIC bool TRANS_type(bool check_as, bool square, bool array, bool new, TRANS_DECL *result);*/
|
|
|
|
bool TRANS_type(int flag, TRANS_DECL *result);
|
|
|
|
bool TRANS_get_number(int index, TRANS_NUMBER *result);
|
|
|
|
bool TRANS_check_declaration(void);
|
|
|
|
PATTERN *TRANS_get_constant_value(TRANS_DECL *decl, PATTERN *current);
|
|
|
|
|
|
|
|
void TRANS_want(int reserved, char *msg);
|
2010-05-05 22:58:55 +02:00
|
|
|
void TRANS_want_newline(void);
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_ignore(int reserved);
|
2010-05-28 08:24:14 +02:00
|
|
|
//int TRANS_get_class(PATTERN pattern);
|
2009-07-08 21:57:50 +02:00
|
|
|
bool TRANS_is_end_function(bool is_proc, PATTERN *look);
|
2008-01-19 18:52:05 +01:00
|
|
|
char *TRANS_get_num_desc(int num);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-29 02:11:55 +02:00
|
|
|
#define TRANS_is(_reserved) (PATTERN_is(*JOB->current, (_reserved)) ? JOB->current++, TRUE : FALSE)
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
/* trans_code.c */
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_code(void);
|
2012-12-22 01:23:51 +01:00
|
|
|
#define TRANS_has_init_var(_decl) ((_decl)->is_new || (_decl)->init)
|
2009-07-08 21:57:50 +02:00
|
|
|
bool TRANS_init_var(TRANS_DECL *decl);
|
|
|
|
void TRANS_statement(void);
|
|
|
|
void TRANS_init_optional(TRANS_PARAM *param);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* trans_expr.c */
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_expression(bool check);
|
|
|
|
void TRANS_ignore_expression();
|
|
|
|
void TRANS_reference(void);
|
|
|
|
bool TRANS_affectation(bool check);
|
|
|
|
void TRANS_operation(short op, short nparam, bool output, PATTERN previous);
|
|
|
|
void TRANS_new(void);
|
2009-09-20 19:32:12 +02:00
|
|
|
TYPE TRANS_variable_get_type(void);
|
|
|
|
void TRANS_class(int index);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* trans_tree.c */
|
|
|
|
|
|
|
|
#define RS_UNARY (-1)
|
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
//TRANS_TREE *TRANS_tree(bool check_statement);
|
|
|
|
void TRANS_tree(bool check_statement, TRANS_TREE **result, int *count);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* trans_ctrl.c */
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_control_init(void);
|
|
|
|
void TRANS_control_exit(void);
|
|
|
|
|
|
|
|
void TRANS_if(void);
|
|
|
|
void TRANS_else(void);
|
|
|
|
void TRANS_endif(void);
|
|
|
|
void TRANS_goto(void);
|
2012-03-04 00:57:36 +01:00
|
|
|
void TRANS_gosub(void);
|
2012-05-21 03:09:35 +02:00
|
|
|
void TRANS_on_goto_gosub(void);
|
2010-05-22 20:02:34 +02:00
|
|
|
void TRANS_do(int type);
|
|
|
|
void TRANS_loop(int type);
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_select(void);
|
|
|
|
void TRANS_case(void);
|
|
|
|
void TRANS_default(void);
|
|
|
|
void TRANS_end_select(void);
|
|
|
|
void TRANS_break(void);
|
|
|
|
void TRANS_continue(void);
|
|
|
|
void TRANS_return(void);
|
|
|
|
void TRANS_for(void);
|
|
|
|
void TRANS_for_each(void);
|
|
|
|
void TRANS_next(void);
|
|
|
|
void TRANS_try(void);
|
|
|
|
void TRANS_finally(void);
|
|
|
|
void TRANS_catch(void);
|
|
|
|
void TRANS_label(void);
|
|
|
|
void TRANS_with(void);
|
|
|
|
void TRANS_use_with(void);
|
|
|
|
void TRANS_end_with(void);
|
|
|
|
void TRANS_raise(void);
|
2012-03-02 23:05:55 +01:00
|
|
|
void TRANS_stop(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* trans_subr.c */
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_subr(int subr, int nparam);
|
|
|
|
|
|
|
|
void TRANS_print(void);
|
|
|
|
void TRANS_input(void);
|
|
|
|
void TRANS_read(void);
|
2009-09-20 19:32:12 +02:00
|
|
|
void TRANS_read_old(void);
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_write(void);
|
|
|
|
void TRANS_open(void);
|
|
|
|
void TRANS_pipe(void);
|
2009-09-17 22:58:27 +02:00
|
|
|
void TRANS_memory(void);
|
2013-11-04 16:17:01 +01:00
|
|
|
void TRANS_open_string(void);
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_close(void);
|
|
|
|
void TRANS_lock(void);
|
|
|
|
void TRANS_unlock(void);
|
|
|
|
void TRANS_seek(void);
|
|
|
|
void TRANS_line_input(void);
|
|
|
|
void TRANS_flush(void);
|
|
|
|
void TRANS_quit(void);
|
|
|
|
void TRANS_exec(void);
|
|
|
|
void TRANS_shell(void);
|
|
|
|
void TRANS_wait(void);
|
|
|
|
void TRANS_sleep(void);
|
|
|
|
void TRANS_kill(void);
|
|
|
|
void TRANS_move(void);
|
2012-01-15 09:54:57 +01:00
|
|
|
void TRANS_chmod(void);
|
|
|
|
void TRANS_chown(void);
|
|
|
|
void TRANS_chgrp(void);
|
2009-07-08 21:57:50 +02:00
|
|
|
void TRANS_inc(void);
|
|
|
|
void TRANS_dec(void);
|
|
|
|
void TRANS_swap(void);
|
|
|
|
void TRANS_mkdir(void);
|
|
|
|
void TRANS_rmdir(void);
|
|
|
|
void TRANS_use(void);
|
|
|
|
void TRANS_copy(void);
|
|
|
|
void TRANS_link(void);
|
|
|
|
void TRANS_input_from(void);
|
|
|
|
void TRANS_output_to(void);
|
|
|
|
void TRANS_debug(void);
|
|
|
|
void TRANS_error(void);
|
|
|
|
void TRANS_scan(void);
|
|
|
|
void TRANS_randomize(void);
|
|
|
|
void TRANS_mid(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|