⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fblist.c

📁 c编译器实现
💻 C
字号:
/* *  FBCC - A simple C compiler. *  *  Copyright (c) 1996 Fabrice Bellard * *  Contact addresses: *  mail: Fabrice Bellard, 451 chemin du mas de Matour, 34790 Grabels, France *  email: bellard@email.enst.fr *  url: http://www.enst.fr/~bellard * *  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 of the License, 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. */#include <stdlib.h>#include <stdio.h>#include <string.h>#include "fbcc.h"LIST *mk_int(int a,LIST *tl){	 LIST *l;	 l=malloc(sizeof(LIST));	 l->type=LIST_INT;	 l->data.val=a;	 l->tl=tl;	 return l;}LIST *mk_tag(int a,LIST *tl){	 LIST *l;	 l=malloc(sizeof(LIST));	 l->type=LIST_TAG;	 l->data.val=a;	 l->tl=tl;	 return l;}LIST *mk_list(LIST *list,LIST *tl){	 LIST *l;	 l=malloc(sizeof(LIST));	 l->type=LIST_LIST;	 l->data.list=list;	 l->tl=tl;	 return l;}LIST *mk_buf(char *buf,int buf_size,LIST *tl){	 LIST *l;	 l=malloc(sizeof(LIST)+buf_size-1);	 l->type=LIST_STR;	 l->data.buf_size=buf_size;	 memcpy(l->str,buf,buf_size);	 l->tl=tl;	 return l;}LIST *mk_str(char *str,LIST *tl){	 return mk_buf(str,strlen(str)+1,tl);}LIST *mk_sym(SYM *s,LIST *tl){	 LIST *l;	 l=malloc(sizeof(LIST));	 l->type=LIST_SYM;	 l->data.sym=s;	 l->tl=tl;	 return l;}int hd_tag(LIST *l){	 if (l==NULL || l->type!=LIST_TAG) Error_Internal("'hd_tag': type incorrect");	 return l->data.val;}int hd_int(LIST *l){	 if (l==NULL || l->type!=LIST_INT) Error_Internal("'hd_int': type incorrect");	 return l->data.val;}LIST *hd_list(LIST *l){	 if (l==NULL || l->type!=LIST_LIST) Error_Internal("'hd_list': type incorrect");	 return l->data.list;}char *hd_str(LIST *l){	 if (l==NULL || l->type!=LIST_STR) Error_Internal("'hd_str': type incorrect");	 return l->str;}SYM *hd_sym(LIST *l){	 if (l==NULL || l->type!=LIST_SYM) Error_Internal("'hd_sym': type incorrect");	 return l->data.sym;}void put_int(LIST *l,int a){	 if (l->type!=LIST_INT) Error_Internal("'put_int': type incorrect");	 l->data.val=a;}void put_tag(LIST *l,int a){	 if (l->type!=LIST_TAG) Error_Internal("'put_tag': type incorrect");	 l->data.val=a;}void put_list(LIST *l,LIST *a){	 if (l->type!=LIST_LIST) Error_Internal("'put_tag': type incorrect");	 l->data.list=a;}LIST *tl(LIST *l) {	 if (l==NULL) Error_Internal("'tl' appel

⌨️ 快捷键说明

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