亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tree.cc.bak

?? C語言前端編譯器,yacc/lex編寫,可自行修改代碼.
?? BAK
?? 第 1 頁 / 共 2 頁
字號(hào):
// Copyright 2002 by Keith Vallerio.
// All rights reserved.

#include "tree.h"
#include "database.h"

// utility function: stores values in 'a' or 'b' in 'out'
void vector_merge (RVector<string> a, RVector<string> b,RVector<string> &out)
{
	out.clear();
	MAP (x, a.size()) {
		out.push_back(a[x]);
	}
	MAP (x, b.size()) {
		out.push_back(b[x]);
	}
}

// Constructors
TreeNode::TreeNode () :
	name_(), whitespace_(), subtree_size_(0), parent_(-1), children_()
{
}

TreeNode::TreeNode (string str, string space) :
	name_(str), whitespace_(space), subtree_size_(0), parent_(-1), children_()
{
}

// Returns next tree node which is actually in the source code
// (This is equivalent to saying 'get next leaf node')
long DB::get_next_literal (long tn)
{
	for (long i = tn + 1; i < tree_node_.size(); i++) {
		if (tree_node_[i].subtree_size() == 1)
			return i;
	}
	return -1;
}

// Returns first ancestor of node 'n' with name 's'
long DB::get_ancestor (long n, string s)
{
	long i = n;
	while (tree_node_[i].parent() != -1) {
		if (tree_node_[i].name() == s)
			return i;
		i = tree_node_[i].parent();
	}
	return -1;
}

// Returns first child of 'n' which is a variable
string DB::get_first_var_child (long n, long curr_function)
{
	long i = n - tree_node_[n].subtree_size() + 1;
	string ret_val;

	while (i < n) {
		string str = create_var_name (tree_node_[i].name(), curr_function);
		if ((var_map(str)) != -1) {
			ret_val = str;
			i = n;
		}
		i++;
	}
	return ret_val;
}

// generates a variable name with appropriate extension
// __0 for globals, __# for local variables where # is the function number
string DB::create_var_name (string s, long f)
{
	string tmp_str = s + "__" + to_string(0);

	// first check if 's' is a global variable
	if (var_map_.find(tmp_str) != var_map_.end()) {
		return tmp_str;
	} else {
		return (s + "__" + to_string(f));
	}
}

// Return child index if node 'n' has a child with name 's'
long DB::has_child (long n, string s)
{
	long i = n - tree_node_[n].subtree_size() + 1;

	while (i < n) {
		if (tree_node_[i].name() == s) {
			return i;
		}
		i++;
	}
	return -1;
}

// Get name of child 'c' of node 'n' (starts at 0)
string DB::node_child_name (long n, long c)
{
	Rassert (c < (tree_node_[n].children()).size());
	long t = tree_node_[n].child(c);
	return (tree_node_[t].name());
}

// get the name the parent of node 'n' 
string DB::node_parent_name (long n)
{
	if (tree_node_[n].parent() != -1) 
		return tree_node_[tree_node_[n].parent()].name();
	else
		return (string(""));
}

// adds a node to the abstract syntax tree (AST)
void DB::add_tree_node (string str, int num_subtrees, string space)
{
	RVector<long> node_list;
	tree_node_.push_back(TreeNode(str, space));

	// These two lines find space for the new node
	long last_node = tree_node_.size() - 1;
	long size = 1;

//cout << "\ntoken:(" << last_node << ")  " << str << endl;

	// These lines determine the immediate children of the new node
	// and the size of the whole subtree.  To accomplish this, get
	// the first child and add children and subtrees as long as there
	// are more subtrees to be added.  This also sets the parent
	// value for the children.
	long c = last_node - 1;
	MAP (x, num_subtrees) {
		node_list.push_back(c);
		tree_node_[c].add_parent(last_node);

		size += tree_node_[c].subtree_size();
		c -= tree_node_[c].subtree_size();
	}

	// add the children to the new node
	for (int i = node_list.size() - 1; i >= 0; i--) {
		tree_node_[last_node].add_child(node_list[i]);
	}

	tree_node_[last_node].set_subtree_size(size);
}

// Analyze the tree.  (Does a significant amount of processing.)
void DB::interpret_tree()
{
	// These 2 vars record when we start/end analyzing a function
	long curr_function = 0;
	long curr_function_end = 0;

	// These 3 vectors record when we start/end analyzing a function call
	RVector<long> func_call;
	RVector<long> func_call_end;
	RVector<string> func_call_name;

	//These strings store info on variable names and type info
	string type, str;
	RVector<string> stype_full, stype_one, stype_all;

	// Add a special function for global definitions
	func_def_name_list_.push_back("global_defs");

	//**********************************************************
	// FOR EACH NODE IN THE TREE...
	//-----------------------------
	// Pass through tree once.  Take actions based on current node (x)
	// and current state (variables listed above)
	//**********************************************************
	MAP (x, tree_node_.size()) {
//cout << tree_node_[x].name() << endl;

		/////////////////////////////
		// Cleanup section goes first
		//---------------------------
		// Determine if end of func def or func call is reached
		// and adjust variables accordingly.
		///////////////////////////// 
		// End of func def -> set curr_function to zero
		if (x > curr_function_end) {
			curr_function = 0;
		}
		// If currently analyzing a function
		if (func_call.size()) {
			// If we reached the end of the most recent func call
			if (x > func_call_end[func_call_end.size() - 1]) {
				// Add function call to curr_functions func_call list.
				// Make sure it has the correct number of commas.
				// And pop func_call stacks.
				function_[curr_function].add_action(
						func_call_name[func_call.size()-1], FN_END, x-1);
				if (tree_node_[func_call_end[func_call.size()-1]].subtree_size() 
								!= 5) {
					function_[curr_function].balance_func_call_commas(
										func_call[func_call.size()-1]);
				}
				func_call.pop_back();
				func_call_end.pop_back();
				func_call_name.pop_back();
			}
		}

		/////////////////////////////
		// Analysis
		//---------
		// Analyze current node in this section
		///////////////////////////// 

		// creates a variable name...checks to see if it's a global first
		str = create_var_name (tree_node_[x].name(), curr_function);

		// inside a struct declaration throw out variables and data types
		if (get_ancestor(x, "struct_declaration_list") != -1) {

		// undefined structs
		} else if (tree_node_[x].name() == "struct") {
			long next = get_next_literal(x);
			if (tree_node_[get_next_literal(next)].name() == ";") {			
//				cout << tree_node_[next].name() << endl;			
				undefined_structs_.insert("struct " + tree_node_[next].name());
			}

		// Handle identifiers (funcs, params, vars, user-defined data types
		} else if (node_parent_name(x) == "identifier") {
			long a1,a2,a3;
			if ((a1 = get_ancestor (x, "function")) != -1) {
				// function def/decl parameters
				if ((a2 = get_ancestor (x, "parameter_list")) != -1) {
					Rassert(curr_function);
					vector_merge(stype_one, stype_all, stype_full);
					add_parameter(curr_function, str, type, stype_full);

				// function definition
				} else if ((a3 = get_ancestor (x, "function_definition")) != -1) {
					Rassert(!curr_function);
					vector_merge(stype_one, stype_all, stype_full);
					curr_function = 
								add_function(tree_node_[x].name(),type,stype_full);
					curr_function_end = a3;
					set_function_defined (curr_function);
					func_def_name_list_.push_back(tree_node_[x].name());

				// function declaration
				} else {
					Rassert(!curr_function);
					vector_merge(stype_one, stype_all, stype_full);
					curr_function = 
								add_function(tree_node_[x].name(),type, stype_full);
					curr_function_end = get_ancestor (x, "declaration");
				}

			// don't count user-defined data types as variables!!!
			} else if ((type_map_lookup(tree_node_[x].name())) != -1) {
//				cout << tree_node_[x].name() << " DATA TYPE...not a variable\n";

			// variable declaration
			} else if ((a1 = get_ancestor (x, "declaration")) != -1) { 
				long arr_size = 1;

				// if it's an array, try to determine size
				if ((a2 = get_ancestor (x, "array_decl")) != -1) {
					long tmp_x = x;
					bool done = false;
//					cout << "Array:  " << str << "  ";
					while (!done) {
						long tn = get_next_literal(tmp_x);
						Rassert(tn != -1);
						if (tree_node_[tn].name() == "[") {
							tn = get_next_literal(tn);
							long tmp_val = Conv(tree_node_[tn].name());
							arr_size *= tmp_val;
//							cout << tree_node_[tn].name() << " ";
							tn = get_next_literal(tn);

// If calculation embedded in [], then just give up on guessing array size
							if (tree_node_[tn].name() != "]") {
								done = true;
								arr_size = ArgPack::ap().pointer_size();
							}
							tmp_x = tn;
						} else {
							done = true;
						}
					}
//					cout << " is " << arr_size << endl;
				}
				if ((type_map_lookup(str)) == -1) {
					vector_merge(stype_one, stype_all, stype_full);
					add_variable (curr_function, str, type, stype_full, arr_size);
					function_[curr_function].add_action(str, VAR_DECL, x);
				}
			}

		// variable usage (including inside of a function call)
		} else if ((var_map(str)) != -1) {
			if (func_call.size()) {
				long tmp = func_call[func_call.size() - 1];
				Rassert(var_map(str) != -1);
				add_func_call_arg(curr_function, tmp, var_map(str), VAR);
			}
			function_[curr_function].add_var_use (str);
			function_[curr_function].add_action (str, VAR_USE, x);
			//添加函數(shù)返回參數(shù)  return后的變量
			/*
			int cup2=get_ancestor(x,"jump_statement");
			if(cup>=0){ 
			   long cup1 = cup2 - tree_node_[cup2].subtree_size() + 1;
			   if(cup1>=0 && tree_node_[cup1].name()=="return")
			     //add_parameter(curr_function, str, type, stype_full);
			     function_[curr_function].add_parameter(var_map_.find(str));
			}
			*/
			
			
			//添加以下代碼,為了分辨出條件還是執(zhí)行體,并同時(shí)去掉上一語句
			//int cup=get_ancestor(x,"expr");
			//string bottle="";
			//if(cup>=0)bottle=node_parent_name(cup);
			//if(bottle=="selection_statement"||bottle=="iteration_statement")
			//   function_[curr_function].add_action (str, VAR_USE_COND, x);
		        // else function_[curr_function].add_action (str, VAR_USE, x);

		// function call
		} else if ((func_map(tree_node_[x].name())) != -1) {
			// fn_call_root is the root node of the func call subtree
			long fn_call_root = get_ancestor (x, "function_call");
			if (fn_call_root != -1) {
				if (func_call.size()) {
					long fc_num = func_call[func_call.size() - 1];
					long fnum = func_map(tree_node_[x].name());
					Rassert(fnum != -1);
					add_func_call_arg(curr_function, fc_num, fnum, FUNC);
				}
				string fn_call_name = tree_node_[x].name();
				function_[curr_function].add_action(fn_call_name, FN_START, x);
				func_call.push_back(
							add_func_call(curr_function,fn_call_name,fn_call_root,x));
				func_call_end.push_back(fn_call_root);
				func_call_name.push_back(fn_call_name);
			}

		// storage class specifiers (adjectives for data types)
		} else if ((tree_node_[x].name() == "extern") || 
						(tree_node_[x].name() == "static") ||
						(tree_node_[x].name() == "const") || 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区在线影院| 久久久久久麻豆| 精品午夜久久福利影院| 中文字幕不卡在线观看| 91精品啪在线观看国产60岁| 国产成+人+日韩+欧美+亚洲| 亚洲高清视频中文字幕| 久久久久久久综合色一本| 色婷婷久久综合| 国产成人精品aa毛片| 亚洲午夜羞羞片| 国产人妖乱国产精品人妖| 欧美一区二区不卡视频| 99久久综合99久久综合网站| 久久99九九99精品| 亚洲专区一二三| 国产欧美一区视频| 精品久久久久久久久久久久久久久| 91视视频在线观看入口直接观看www | 国产欧美精品国产国产专区| 色一区在线观看| 成人精品gif动图一区| 国产精品第13页| 精品日韩欧美在线| 欧美无砖专区一中文字| 国产成人午夜精品影院观看视频 | 亚洲精品视频在线看| 久久久亚洲高清| 3d动漫精品啪啪1区2区免费| 欧美专区亚洲专区| 99国产精品99久久久久久| 国产精品1区2区| 久久精品国产成人一区二区三区 | 成人视屏免费看| 久久精品国产精品青草| 中文字幕日韩av资源站| 亚洲国产成人一区二区三区| 日韩三级伦理片妻子的秘密按摩| 欧美日韩国产片| 欧美性欧美巨大黑白大战| 久久精品99久久久| 久久精品国产亚洲5555| 天天色图综合网| 丝袜a∨在线一区二区三区不卡| 一区二区激情小说| 国产精品免费人成网站| 亚洲天堂成人网| 国产精品美女久久福利网站| 日本一区二区三区免费乱视频| 久久色.com| 日韩欧美综合在线| 久久综合久久99| 久久精品夜色噜噜亚洲a∨| 久久综合九色综合欧美就去吻 | 久久一区二区三区四区| 国产欧美一区二区精品性色| 久久久噜噜噜久久中文字幕色伊伊 | 国产精品动漫网站| 国产精品婷婷午夜在线观看| 亚洲欧美色综合| 亚洲自拍欧美精品| 日韩—二三区免费观看av| 日本亚洲天堂网| 男人的天堂亚洲一区| 国产久卡久卡久卡久卡视频精品| 国产麻豆精品视频| 一本大道久久a久久精品综合| 色94色欧美sute亚洲线路二| 欧美三级日韩三级| 26uuu久久综合| 国产精品青草综合久久久久99| 亚洲制服丝袜av| 天天av天天翘天天综合网| 亚洲国产日产av| 国产很黄免费观看久久| 北条麻妃一区二区三区| 欧美日韩国产区一| 日韩精品一区二区三区视频| 精品国产91洋老外米糕| 亚洲免费在线观看视频| 丝袜亚洲另类欧美综合| 国产福利一区二区三区视频在线| av毛片久久久久**hd| 成人国产精品免费观看视频| 91在线观看美女| 日韩一区二区电影在线| 中文字幕的久久| 午夜精品免费在线观看| 国产一区二区调教| 欧美日韩高清一区二区三区| 久久免费的精品国产v∧| 亚洲一区av在线| 国产一区 二区 三区一级| 一本一本久久a久久精品综合麻豆| 日本丶国产丶欧美色综合| 在线综合+亚洲+欧美中文字幕| 久久精品日韩一区二区三区| 亚洲免费在线电影| 日韩中文欧美在线| 成人aa视频在线观看| 欧美日韩在线三级| 成人免费在线播放视频| 久久成人羞羞网站| 欧美区一区二区三区| 国产精品久久久一本精品| 国模套图日韩精品一区二区| 色哟哟亚洲精品| 国产精品视频线看| 精品视频色一区| 欧美日本韩国一区二区三区视频| 国产精品久久午夜| 久久精品国内一区二区三区| 欧美视频在线观看一区二区| 国产欧美日韩不卡| 国产一区二区三区国产| 欧美日本国产一区| 精品国产一区二区在线观看| 日韩电影在线一区二区三区| 成人黄色小视频在线观看| 国产亚洲成aⅴ人片在线观看| 爽好久久久欧美精品| 欧美日韩精品高清| 亚洲天堂a在线| 日本va欧美va瓶| 欧美日韩亚洲综合一区二区三区| 国产精品每日更新| 懂色av一区二区三区蜜臀| 精品国产一二三| 激情六月婷婷久久| 欧美猛男gaygay网站| 国产精品免费看片| 成人av电影免费观看| 久久综合久久99| 国产美女主播视频一区| 亚洲精品在线电影| 国产丶欧美丶日本不卡视频| 91精品国产免费久久综合| 一区二区三区高清在线| 99久久精品免费观看| 国产精品理论片| 色综合色狠狠天天综合色| 成人免费在线视频| 91成人在线免费观看| 亚洲欧美精品午睡沙发| 在线观看免费亚洲| 亚洲精品老司机| 欧美无乱码久久久免费午夜一区| 亚洲老司机在线| 色婷婷综合激情| 日本不卡一区二区三区| 91精品久久久久久久99蜜桃| 舔着乳尖日韩一区| 51精品国自产在线| 日本人妖一区二区| 精品国产一区二区国模嫣然| 国产精品夜夜嗨| 精品国产亚洲在线| 国产91清纯白嫩初高中在线观看| 精品999久久久| 成人黄色电影在线 | 五月婷婷色综合| 欧美一区二区三区成人| 精品在线亚洲视频| 欧美激情中文不卡| 色综合欧美在线视频区| 婷婷开心久久网| 日韩美女视频一区二区在线观看| 国产一区二区三区在线看麻豆| 国产女同互慰高潮91漫画| 国产在线国偷精品产拍免费yy| 国产三级精品视频| 日本精品一区二区三区高清| 亚洲成在线观看| 精品999在线播放| 成人午夜电影网站| 一区二区日韩电影| 欧美日韩国产一级二级| 国产剧情一区二区三区| 亚洲视频在线观看三级| 日韩一区二区三区视频| 国产成人午夜99999| 亚洲午夜久久久久久久久电影院 | 国产精品不卡在线观看| 亚洲另类中文字| 欧美一区二区福利在线| 久久99日本精品| 亚洲午夜免费视频| 欧美精品一区二区三区很污很色的| www.视频一区| 日本不卡视频一二三区| 亚洲欧美日韩国产成人精品影院| 欧美一区二区三区免费| 91论坛在线播放| 精品综合久久久久久8888| 亚洲一卡二卡三卡四卡| 久久久精品黄色| 日韩一区二区三区观看| 91网上在线视频| 国产成人精品三级麻豆| 午夜国产不卡在线观看视频|