Personal tools
You are here: Home Projects C++ Cfront releases Release 1.0 Source cfront src repr.c
Document Actions

repr.c

by Paul McJones last modified 2007-02-02 09:34

Click here to get the file

Size 3.3 kB - File type text/x-csrc

File contents

/* @(#) repr.c 1.3 1/27/86 17:49:25 */ 
/*ident	"@(#)cfront:src/repr.c	1.3" */
/**************************************************************************

	repr.c: stage main (views: main err)
*/

#include "cfront.h"

char* oper_name(TOK op)
/*
	return the string representation of operator "op"
*/
{
	switch (op) {
	default:	error('i',"oper_name(%k)",op);
	case CM:	return "_comma";
	case NEW:	return "_new";
	case DELETE:	return "_delete";
	case MUL:	return "_mul";
	case DIV:	return "_div";
	case MOD:	return "_mod";
	case UPLUS:
	case PLUS:	return "_plus";
	case MINUS:
	case UMINUS:	return "_minus";
	case LS:	return "_lshift";
	case RS:	return "_rshift";
	case EQ:	return "_eq";
	case NE:	return "_ne";
	case LT:	return "_lt";
	case GT:	return "_gt";
	case LE:	return "_le";
	case GE:	return "_ge";
	case AND:
	case ADDROF:	return "_and";
	case OR:	return "_or";
	case ER:	return "_er";
	case ANDAND:	return "_andand";
	case OROR:	return "_oror";
	case NOT:	return "_not";
	case COMPL:	return "_compl";
	case INCR:	return "_incr";
	case DECR:	return "_decr";
	case CALL:	return "_call";
	case DEREF:	return "_vec";
	case ASSIGN:	return "_assign";
	case ASPLUS:	return "_asplus";
	case ASMINUS:	return "_asminus";
	case ASMUL:	return "_asmul";
	case ASDIV:	return "_asdiv";
	case ASMOD:	return "_asmod";
	case ASLS:	return "_asls";
	case ASRS:	return "_asrs";
	case ASAND:	return "_asand";
	case ASOR:	return "_asor";
	case ASER:	return "_aser";
	case SIZEOF:	return "sizeof";
	}
}

#define new_op(ss,v) keys[v]=ss

void otbl_init()
/*
	operator representation table
*/
{
	new_op("->",REF);
	new_op("." ,DOT);
	new_op("!" ,NOT);
	new_op("~" ,COMPL);
	new_op("++",INCR);
	new_op("--",DECR);
	new_op("*" ,MUL);
	new_op("&" ,AND);
	new_op("&" ,ADDROF);
	new_op("&" ,G_ADDROF);
	new_op("/" ,DIV);
	new_op("%" ,MOD);
	new_op("+" ,PLUS);
	new_op("-" ,MINUS);
	new_op("-" ,UMINUS);
	new_op("<<",LS);
	new_op(">>",RS);
	new_op("<" ,LT);
	new_op(">" ,GT);
	new_op("<=",LE);
	new_op(">=",GE);
	new_op("==",EQ);
	new_op("!=",NE);
	new_op("^" ,ER);
	new_op("|" ,OR);
	new_op("&&",ANDAND);
	new_op("||",OROR);
	new_op("?" ,QUEST);
	new_op(":" ,COLON);
	new_op("=" ,ASSIGN);
	new_op("," ,CM);

	new_op(";" ,SM);
	new_op("{" ,LC);
	new_op("}" ,RC);
	new_op("(" ,LP);
	new_op(")" ,RP);
	new_op("[" ,LB);
	new_op("]" ,RB);

	new_op("+=",ASPLUS);
	new_op("-=",ASMINUS);
	new_op("*=",ASMUL);
	new_op("/=",ASDIV);
	new_op("%=",ASMOD);
	new_op("&=",ASAND);
	new_op("|=",ASOR);
	new_op("^=",ASER);
	new_op(">>=",ASRS);
	new_op("<<=",ASLS);

	new_op("sizeof",SIZEOF);
	new_op("new",NEW);
	new_op("delete",DELETE);

	new_op("0" ,ZERO);
	new_op("," ,ELIST);
	new_op("[]" ,DEREF);
	new_op("expression list", ELIST);
	new_op("function call", CALL);
	new_op("generated function call",G_CALL);
	new_op("inline function call",ICALL);
	new_op("cast",CAST);
	new_op("inline argument",ANAME);

	new_op("class", COBJ);
	new_op("enum", EOBJ);
	new_op("union", ANON);

	new_op("function",FCT);
	new_op("pointer",PTR);
	new_op("reference",RPTR);
	new_op("vector",VEC);
	new_op("identifier",ID);
	new_op("name",NAME);
	new_op("...",ELLIPSIS);
	new_op("::",MEM);
	new_op("type name",TYPE);
	new_op("{}",BLOCK);
	new_op("pair",PAIR);
	new_op("declaration",DCL);
	new_op("character constant",CCON);
	new_op("integer constant",ICON);
	new_op("float constant",FCON);
	new_op("string",STRING);
}
« June 2013 »
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: