eval_trans_tree.c

来自「Gambas is a graphical development enviro」· C语言 代码 · 共 135 行

C
135
字号
/***************************************************************************  trans_tree.c  Convert expression to a tree  (c) 2000-2003 Beno顃 Minisini <gambas@users.sourceforge.net>  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 1, or (at your option)  any later version.  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.  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., 675 Mass Ave, Cambridge, MA 02139, USA.***************************************************************************/#define __TRANS_TREE_C#include "gb_common.h"#include "gb_error.h"#include "gb_reserved.h"#include "eval_trans.h"#include "eval_read.h"#include "eval.h"/*#define DEBUG*/PRIVATE short level;PRIVATE PATTERN *current;/*PRIVATE PATTERN last_pattern;*/PRIVATE void analyze_expr(short priority, short op_main);PRIVATE void inc_level(){  level++;  if (level > MAX_EXPR_LEVEL)   THROW("Expression too complex");}PRIVATE void dec_level(){  level--;}PRIVATE void add_pattern(PATTERN pattern){  PATTERN *node;  short index;  index = (short)ARRAY_count(EVAL->tree);  if (index >= MAX_EXPR_PATTERN)    THROW("Expression too complex");  node = ARRAY_add(&EVAL->tree);  *node = pattern;  /*last_pattern = pattern;*/  /*#ifdef DEBUG  READ_dump_pattern(&pattern);  #endif*/}PRIVATE void remove_last_pattern(){  if (!ARRAY_count(EVAL->tree))    return;  ARRAY_remove_last(&EVAL->tree);}PRIVATE PATTERN get_last_pattern(int dep){  short index;  index = (short)ARRAY_count(EVAL->tree);  if (index < dep)    return NULL_PATTERN;  return EVAL->tree[index - dep];}PRIVATE void change_last_pattern(int dep, PATTERN pattern){  short index;  index = (short)ARRAY_count(EVAL->tree);  if (index < dep)    return;  EVAL->tree[index - dep] = pattern;}PRIVATE void check_last_first(int dep){  if (PATTERN_is_identifier(get_last_pattern(dep)))    change_last_pattern(dep, PATTERN_set_flag(get_last_pattern(dep), RT_FIRST));}PRIVATE void add_reserved_pattern(int reserved){  add_pattern(PATTERN_make(RT_RESERVED, reserved));}PRIVATE void add_operator_output(short op, short nparam, boolean has_output){  PATTERN pattern;  long index;  SYMBOL *sym;  /*     A QUOI SERT CE TEST ?     add_operator() peut 阾re appel

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?