?? globals.h
字號:
/****************************************************/
/* File: globals.h */
/* Global types and vars for TINY compiler */
/* must come before other include files */
/* Compiler Construction: Principles and Practice */
/* Kenneth C. Louden */
/****************************************************/
#ifndef _GLOBALS_H_
#define _GLOBALS_H_
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
/* MAXRESERVED = the number of reserved words */
#define MAXRESERVED 6
typedef enum
/* book-keeping tokens */
{ENDFILE,ERROR,
/* reserved words */
IF,ELSE,RETURN,WHILE,
/* multicharacter tokens */
ID,NUM,
/* type*/
INT,VOID,
/* special symbols + - * / < <= > >= == != = ; , ( ) [ ] { } */ PLUS,MINUS,TIMES,OVER,LT,LTEQ,GT,GTEQ,EQ,NOEQ,ASSIGN,SEMI,COMMA,LPAREN,RPAREN,LBRA,RBRA,LBRACE,RBRACE
} TokenType;
extern FILE* source;
extern FILE* listing;
extern FILE* code;
extern int lineno;
/**************************************************/
/*********** Syntax tree for parsing ************/
/**************************************************/
typedef enum {StmtK,ExpK,DecK,ParamK} NodeKind;
typedef enum {CompoundK,SelectionK,IterationK,ReturnK,ExpressionK} StmtKind;
typedef enum {OpK,ConstK,IdK,AssignK,CallK} ExpKind;
typedef enum {Var,Array,Null} ParamKind;
typedef enum {ArrayK,VarK,FunK} DecKind; //declaration kind treenode ;
#define MAXCHILDREN 3
typedef struct treeNode
{ struct treeNode * child[MAXCHILDREN];
struct treeNode * sibling;
int lineno;
NodeKind nodekind;
union { StmtKind stmt; ExpKind exp; DecKind dec;ParamKind param;} kind;
union { TokenType op;
int val;
char * type;
char * name; } attr;
} TreeNode;
extern int EchoSource;
extern int TraceScan;
extern int TraceParse;
extern int Error;
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -