Hot Search : Source embeded web remote control p2p game More...
Location : Home Search - INT 1
Search - INT 1 - List
此程序实现的是一个运算器,是在一个程序的基础上进行改进的,计算器中需要的运算以及操作对象: IF,AND,OR,<,<=,>,>=,<>,=,== 数字0-9,(,),+,-,*,/, SIN,COS,TAN,POW,EXP,ABS,SQRT,INT,LN,LOG,MIN,MAX.-this program is a computing device that is in a process of improvement based on the needs of calculator operation and the operation of Object : IF, AND, OR, lt; , Lt; =, Gt; , Gt; =, Lt; Gt; , =, == figures 0-9 ,(,), ,-,*,/, SIN, COS, TAN, POW, EXP, ABS, SQRT, INT, LN, LOG, MIN, MAX.
Date : 2008-10-13 Size : 45.19kb User : 天空

一、 实验内容 S语言的编译程序的词法分析部分实现 从左到右扫描每行S语言源程序的符号,拼成单词,换成内部表示(token) 二、 实验要求 要求实现编译器的以下功能:  组织源程序的输入  按规则拼写单词,并转换成二元形式  删除空格及无用符号(如回车符,字符常数的引号符等)  发现并定位错误  建立单词表、符号表、常数表等文件 三、 实现方法 数据结构 1、 输入 S语言源程序,为文本文件 2、 输出 词法分析程序的运行结果是:产生一个单词序列文件(token文件)和一个常数表、一个符号表文件,并输出错误信息。 (1) token文件结构 token文件用于存放从S语言源程序中扫描出来的一个个单词符号的机内表示,其文件结构如下: typedef struct token { nt label char name[30] int code int addr }token 说明:  label:单词序号;  name[30]:单词本身;  code:单词的编辑;  addr:地址,单词本身保留字时值为-1,为标识符成常数时为大于0常数,即该标识符成常数在符号表中的入口地址。 -one, Experiment S language compiler of lexical analysis to achieve whatever S scanning each line of source language symbols, makes up words, replaced internal said (token) 2, the experimental requirements call for compiler of the following functions :
Date : 2008-10-13 Size : 75.96kb User : 范鹏

(1) 给定一段符合Pascal子集语法的语言,能成功转换成C语言; (2) 一个简单的说明文档; (3) 2007.7.14之前上传到ftp:// C07:C07@10.11.3.71/upload,用学号建立自己的目录; (4) (可额外加分5分)若有出错处理功能,请在说明文档中写明可以处理哪几项错误。 注意事项: (1) 两人一组 (2) 可以使用词法、语法自动生成工具,windows下有Flex,Bison,Linux下有Lex,Yacc,Java的有Jlex,JavaCC,ANTLR等 (3) 不用考虑Pascal和C的关键词不同问题,即Pascal子集语言中假设不出现int,for等作为变量标志符 (4) read()和write()可用由scanf(),printf()等组成的语句转换。 (5) 如果有疑问可以发信给我 xpqiu@fudan.edu.cn.
Date : 2008-10-13 Size : 47.52kb User : cy

#include #include #include #define MAX 30 int table[5][6]; char stack[30]; int top=0; char buffer[MAX]; int buf=0; void start()//初始化预测分析表
Date : 2009-06-16 Size : 4.14kb User : bkssr@163.com

DL : 0
/*PL/0编译系统C版本头文件pl0.h*/ /* typedef enum { false, true } bool; */ #define norw 13 /*关键字个数*/ #define txmax 100 /*名字表容量*/ #define nmax 14 /*number的最大位数*/ #define al 10 /*符号的最大长度*/ #define amax 2047 /*地址上界*/ #define levmax 3 /*最大允许过程嵌套声明层数[0,levmax]*/ #define cxmax 200 /*最多的虚拟机代码数*/ /*符号*/ enum symbol{ nul, ident, number, plus, minus, times, slash, oddsym, eql, neq, lss, leq, gtr, geq, lparen, rparen, comma, semicolon, period, becomes, beginsym, endsym, ifsym, thensym, whilesym, writesym, readsym, dosym, callsym, constsym, varsym, procsym, }; #define symnum 32 /*名字表中的类型*/ enum object{ constant, variable, procedur, }; /*虚拟机代码*/ enum fct{ lit, opr, lod, sto, cal, inte, jmp, jpc, }; #define fctnum 8 /*虚拟机结构代码*/ struct instruction { /*454*/ enum fct f; // 虚拟机代码指令 int l; //引用层与声明层的层次差 int a; //根据f的不同而不同 }; FILE * fas; //输出名字表 FILE * fa; //输出虚拟机代码 FILE * fa1; //输出源文件及其各行对应的首地址 FILE * fa2; //输出结果 bool listswitch; //显示虚拟机代码与否 bool tableswitch; //显示名字与否 char ch; //获取字符的缓冲区,getch使用 enum symbol sym; //当前的符号 char id[al+1]; //当前ident,多出的一个字节用于存放0 int num; //当前number int cc,ll; //getch使用的计数器,cc表示当前字符(ch)的位置 int cx; //虚拟机代码指针,取值范围[0,cxmax-1] char line[81]; //读取行缓冲区 char a[al+1]; //临时符号,多出的一个字节用于存放0 struct instruction code[cxmax]; //存放虚拟机代码的数组 char word[norw][al]; //保留字 enum symbol wsym[norw]; //保留字对应的符号值 enum symbol ssym[256]; //单字符的符号值 char mnemonic[fctnum][5]; //虚拟机代码指令名称 bool declbegsys[symnum]; //表示声明开始的符号集合 bool statbegsys[symnum]; //表示语句开始的符号集合 bool facbegsys[symnum]; //表示因子开始的符号集合 //名字表结构 struct tablestruct { char name[al]; //名字 enum object kind; //类型:const,var,array or procedure int val; //数值,仅const使用 int level; //所须层,仅const不能用 int adr; //地址,仅const不能用 int size; //需要分配的数据空间,仅procedure使用 }; struct tablestruct table[txmax]; //名字表 FILE * fin; FILE * fout; char fname[al]; int err; //错误计数器 //当函数中发生fatal error时,返回-1告知调用它的函数,最终退出程序 #define getsymdo if(-1==getsym()) return -1 #define getchdo if(-1==getch()) return -1 #define testdo(a,b,c) if(-1==test(a,b,c)) return -1 #define gendo(a,b,c) if(-1==gen(a,b,c)) return -1 #define expressiondo(a,b,c) if(-1==expression(a,b,c)) return -1 #define factordo(a,b,c) if(-1==factor(a,b,c)) return -1 #define termdo(a,b,c) if(-1==term(a,b,c)) return -1 #define conditiondo(a,b,c) if(-1==condition(a,b,c)) return -1 #define statementdo(a,b,c) if(-1==statement(a,b,c)) return -1 #define constdeclarationdo(a,b,c) if(-1==constdeclaration(a,b,c)) return -1 #define vardeclarationdo(a,b,c) if(-1==vardeclaration(a,b,c)) return -1 void error(int n); int getsym(); int getch(); void init(); int gen(enum fct x,int y ,int z); int test(bool *s1,bool *s2,int n); int inset(int e,bool *s); int addset(bool *str,bool * s1,bool * s2,int n); int subset(bool *str,bool * s1,bool * s2,int n); int mulset(bool *str,bool * s1,bool * s2,int n); int block(int lev,int tx,bool * fsys); void interpret(); int factor(bool * fsys,int * ptx,int lev); int term(bool * fsys,int * ptx,int lev); int condition(bool * fsys,int * ptx,int lev); int expression(bool * fsys,int * ptx,int lev); int statement(bool * fsys,int * ptx,int lev); void listcode(int cx0); int vardeclaration(int *ptr, int lev,int *ptx); int constdeclaration(int *ptr, int lev,int *ptx); int position(char * idt,int tx); void enter(enum object k,int * ptx,int lev, int * pdx); int base(int l,int * s,int b)
Date : 2010-09-13 Size : 24.55kb User : xqq771084591

此程序实现的是一个运算器,是在一个程序的基础上进行改进的,计算器中需要的运算以及操作对象: IF,AND,OR,<,<=,>,>=,<>,=,== 数字0-9,(,),+,-,*,/, SIN,COS,TAN,POW,EXP,ABS,SQRT,INT,LN,LOG,MIN,MAX.-this program is a computing device that is in a process of improvement based on the needs of calculator operation and the operation of Object : IF, AND, OR, lt; , Lt; =, Gt; , Gt; =, Lt; Gt; , =, == figures 0-9 ,(,), ,-,*,/, SIN, COS, TAN, POW, EXP, ABS, SQRT, INT, LN, LOG, MIN, MAX.
Date : 2026-01-07 Size : 45kb User : 天空

(1) 给定一段符合Pascal子集语法的语言,能成功转换成C语言; (2) 一个简单的说明文档; (3) 2007.7.14之前上传到ftp:// C07:C07@10.11.3.71/upload,用学号建立自己的目录; (4) (可额外加分5分)若有出错处理功能,请在说明文档中写明可以处理哪几项错误。 注意事项: (1) 两人一组 (2) 可以使用词法、语法自动生成工具,windows下有Flex,Bison,Linux下有Lex,Yacc,Java的有Jlex,JavaCC,ANTLR等 (3) 不用考虑Pascal和C的关键词不同问题,即Pascal子集语言中假设不出现int,for等作为变量标志符 (4) read()和write()可用由scanf(),printf()等组成的语句转换。 (5) 如果有疑问可以发信给我 xpqiu@fudan.edu.cn.
Date : 2026-01-07 Size : 47kb User : cy

DL : 0
简单C编译器生成的目标代码是8086的汇编代码(16位),可以在一般的PC上被像MASM之类的汇编编译程序编译,生成可执行文件后,在DOS或Windows控制台下运行。 实现的语言定义如下: 语言类似于tiny语言,不支持过程调用,也就是只有一个main函数,无其他函数和全局变量 基本语句:注释语句(/*…*/),输入语句(int input(void) ),输出语句(void output(int) ),赋值语句。这里的输入输出语句实际上类似于函数调用,可以看作是本语言内部的函数 算术运算符:+、—、*、/ 数据类型:整数.-Simple C compiler generated object code is 8086 assembly code (16), the PC in general were such as MASM compilation compiler compiler to generate executable file, in DOS or Windows console run. The realization of the language are defined as follows: the language is similar to tiny language, do not support the procedure call, that is, there is only one main function, no other function and global variable basic statement: Note statement (/* ...* /), type the statement (int input (void )), the output statement (void output (int)), assignment statements. The input and output statements in fact similar to function calls, can be seen as a function of the language within the Arithmetic Operators: 2B !,-,*,/ data types: integer.
Date : 2026-01-07 Size : 403kb User : Tony

Syntax of TINY+ An EBNF grammar for TINY+ is as follows (Strings in bold are terminals): 1. program -> declarations stmt-sequence 2. declarations -> decl declarations |² 3. decl -> type-specifi er varlist 4. type-specifi er -> int | bool | string 5. varlist -> identifi er { , identifi er } 6. stmt-sequence -> statement { statement } 7. statement -> if-stmt | repeat-stmt | assign-stmt | read-stmt | write-stmt | while-stmt 8. while-stmt -> while bool-exp do stmt-sequence end 9. if-stmt -> if bool-exp then stmt-sequence [else stmt-sequence] end 10. repeat-stmt -> repeat stmt-sequence until bool-exp 11. assign-stmt -> identifi er := exp 12. read-stmt -> read identifi er 13. write-stmt -> write exp 14. exp -> arithmetic-exp | bool-exp | string-exp 15. arithmetic-exp -> term { addop term } 16. addop -> + | --Syntax of TINY+ An EBNF grammar for TINY+ is as follows (Strings in bold are terminals): 1. program-> declarations stmt-sequence 2. declarations-> decl declarations |² 3. decl-> type-specifi er varlist 4. type-specifi er-> int | bool | string 5. varlist-> identifi er { , identifi er } 6. stmt-sequence-> statement { statement } 7. statement-> if-stmt | repeat-stmt | assign-stmt | read-stmt | write-stmt | while-stmt 8. while-stmt-> while bool-exp do stmt-sequence end 9. if-stmt-> if bool-exp then stmt-sequence [else stmt-sequence] end 10. repeat-stmt-> repeat stmt-sequence until bool-exp 11. assign-stmt-> identifi er := exp 12. read-stmt-> read identifi er 13. write-stmt-> write exp 14. exp-> arithmetic-exp | bool-exp | string-exp 15. arithmetic-exp-> term { addop term } 16. addop->+ |-
Date : 2026-01-07 Size : 1.21mb User : gavinfeng

C语言词法分析器 by wpc_LK 这是一个简单的词法分析器,不能避免的存在错误请大家指出予以纠正,谢谢! 示例语句 include<stdio.h> int main{ int a=3,b=4,c if((a+b)==7)c=1 else c=0 return 0 } 输入 exit 退出程序。-C language lexical analyzer by wpc_LK This is a simple lexical analyzer can t avoid that there re some errors here,please correct, thank you! for exzample: include<stdio.h> int main{ int a=3,b=4,c if((a+b)==7)c=1 else c=0 return 0 } input exit quit the program.
Date : 2026-01-07 Size : 12kb User : wzl

Cint(C/C++ interpreter, C-int)是一个C++解释器,顾名思义,和GCC、VC等编译器不同,它是解释执行C++代码的。它具有的能力有: 支持 K&R-C, ANSI-C, ANSI-C++ 可处理大规模C/C++源码 动态C++ 内置的Debugger和Class Browser Cint可以在不少操作系统上工作 -Cint (C/C++ interpreter, C-int) is a C++ interpreter, by definition, and the GCC, VC and so different from the compiler, which is to explain the implementation of C++ code. It has the ability to: support for K & R-C, ANSI-C, ANSI-C++ can handle a large-scale C/C++ source code dynamic C++ built-in Debugger and Class Browser Cint can be a lot of work on the operating system
Date : 2026-01-07 Size : 1.9mb User : hopper

DL : 0
编译原理的词法分析的c++代码,比如要分析的单词int i=5 经词法分析后输出结果到文件-Compilation Principle of lexical analysis of the c++ code, for example to analyze the word int i = 5 by lexical analysis output to a file
Date : 2026-01-07 Size : 919kb User : 张颖

一个用c语言写的解释器,有三种数据类型:int、float、string。支持+ -×/和print功能。虽然很小,但有很强的参考意义,容易扩展-A simple interpreter, there are three data types: int, float, string. Support+- ×/and print functions. Although small, but has a strong reference value, easy to extend
Date : 2026-01-07 Size : 18kb User :

CMM语言(c-minus-minus)语言的解释器。相对于一些基本的程序而言,本系统具有以下几个特点: 1.基本功能: 支持int,real等简单类型,支持相应简单数组; 支持while,if,else语句; 基本数值运算:+,-,*,/; 2.语句拓展 支持char,string等类型,同时支持相应类型数组,与常量声明; 完全支持for,break ;switch(case,default)continue等语句; 支持 ,++,--,+=,-=,*=,/=等运算; 3.函数拓展 支持简单函数调用; 在函数实现要求下支持return语句,同时增加void类型支持; 支持函数递归; 支持函数重载; 4.简约界面 支持基本操作,如编辑,保存等; 支持注释,缩进,文件视图,查找等功能; 能够打印分析结果,包括词法分析结果,语法树,错误信息,最后调用DoS窗口; 5.错误处理 对各种错误能够识别; 将所有错误信息收集并打印; 在出错之后继续分析完;-It is a nice cmm compiler...
Date : 2026-01-07 Size : 10.32mb User : Emperor

DL : 1
引用原作者:这个类C编译器是我在2008年写的,完成度并不高,并没有实现指针、struct这些,不过还是实现了基本的C语言数据类型(int/char/long/short等),函数的声明、定义、调用、递归,if/for/while/goto等跳转,详细请看sample和source。 为了节省开发的时间,词法和语法分析分别采用lex和yacc编写,可以用Cygwin里面的flex和bison进行编译。另外我觉得编译成x86的bytecode比较麻烦,所以定义了一套自己的bytecode,以及写了一个虚拟机(叫模拟器更准确)去执行它,这部分是比较好修改的,而且我生成的bytecode要比x86的指令体系精简,也跟平台无关,可能适合移植到一些对运行环境要求较苛刻的地方。-Reference to the original author: This class C compiler is written in 2008, to complete the degree is not high, and did not realize the pointer to the struct, but still achieve the basic C data types (int/char/long/short, etc. ), the function declaration, definition, call, recursive, and if/for/while/a goto, etc. Jump in detail please see the sample and the source. In order to save development time, lexical and syntax analysis were used lex and yacc to write, can be compiled with Cygwin inside the flex and bison. In addition, I think compiled into x86 bytecode is too much trouble, so to define its own set of bytecode, and write a virtual machine (called the simulator is more accurate) to execute it, this part is modified, but I generated bytecode than x86 instructions to streamline the system, also has nothing to do with the platform, may be suitable for transplantation to the harsh operating environment requirements.
Date : 2026-01-07 Size : 68kb User : Elijah

an advance data type to represent a student at PMU. Name this class PMUStudent". The following should be the members of this class: 1- string name //this member will hold the name of the student 2- string major //this member will tell the major of the student 3- double gpa //this will tell the so-far gpa of the student 4- int year //this will have the values 1, 2, 3, 4. The value 1 is for 1st year student and 4 is for final year All of these member variables should be private. Also create the following public member functions for this class: 1- constructors (default and overloaded) 2- getter (accessor) and setter (mutator) functions for each member variable 3- a function to print any object of this class. This function Print should print an object like this: Ali, Computer Science first year student, gpa=3.5 -an advance data type to represent a student at PMU. Name this class PMUStudent". The following should be the members of this class: 1- string name //this member will hold the name of the student 2- string major //this member will tell the major of the student 3- double gpa //this will tell the so-far gpa of the student 4- int year //this will have the values 1, 2, 3, 4. The value 1 is for 1st year student and 4 is for final year All of these member variables should be private. Also create the following public member functions for this class: 1- constructors (default and overloaded) 2- getter (accessor) and setter (mutator) functions for each member variable 3- a function to print any object of this class. This function Print should print an object like this: Ali, Computer Science first year student, gpa=3.5
Date : 2026-01-07 Size : 15kb User : Khalid

making triangular number with c++ using integer #include<stdio.h> int triangular(int a) main() { int x printf("menghitung triangular bilangan\n") printf("masukkan bilangan x= ") scanf(" d",&x) triangular(x) printf("selesai\n") } int triangular(int a) { int b,jum=0 for(b=1 b<=a b++) jum=jum+b printf("bilangan triangular dari d adalah d\n",a,jum) }-making triangular number with c++ using integer #include<stdio.h> int triangular(int a) main() { int x printf("menghitung triangular bilangan\n") printf("masukkan bilangan x= ") scanf(" d",&x) triangular(x) printf("selesai\n") } int triangular(int a) { int b,jum=0 for(b=1 b<=a b++) jum=jum+b printf("bilangan triangular dari d adalah d\n",a,jum) }
Date : 2026-01-07 Size : 938kb User : thongthong

一款比较完善的强大的C语言解释器,附带源码,可以嵌入到用户应用程序中。支持对比较复杂的C代码的解释执行。完美支持各种标准C语言语法,如if-else结构语句, ?:结构求值语句,for循环,while循环,do...while循环等 支持各种数据类型包括: char,short,int,string,float 支持多维数组及指针 支持自定义函数以及系统函数 支持局部变量以及全局变量,允许在变量定义时直接初始化 支持局部变量层次化作用域;允许定义系统常量;支持系统内部定义数据类型,但不支持用户在脚本中自定义数据类型;支持行注释符及段注释符。本解释器不但支持标准C语法,也在标准C语法基础上扩展出一些灵活的语法特色,具体参考演示代码。A powerful C language interpreter-A more complete powerful C language interpreter, with source code, can be embedded into the user application. Support for more complex interpretation of C code execution. Perfect support for a variety of standard C language syntax, such as if-else structure statement?: Structural evaluation statements, for loops, while loops, do ... while loops and other supports a variety of data types include: char, short, int, string , float support multidimensional arrays and pointers support for custom functions and system functions to support local variables, and global variables, which allows variable definition directly support local variables initialized hierarchical scopes allows you to define the system constants supported data types defined within the system, but does not support the user in the script custom data types support line comment character and paragraph comment character. The interpreter supports not only standard C syntax, but also on the basis of the standard C syntax extens
Date : 2026-01-07 Size : 116kb User : CM

该程序使用了I/O流对存有汇编语言文本进行读入以及对操作结果的文本输出;运用了数据结构的栈结构,简化了文本内容的识别;将文本中的一行封装成类对象hang;将系统的一些操作指令通过哈希结构封装在symtab类中;将文本获得的操作指令封装在optab中;自己还另外编写了十进制转十六进制,int类型和对应的字符串进行互转的方法供程序使用。-The program uses the I/O stream of assembly language there and read the text on the operating results of text output the use of a stack structure of the data structure, simplifying the recognized text content the text line in the package into a class object hang some of the operating system via the hash command structure is encapsulated in symtab class the operating instructions enclosed in optab text obtained and he still write additional decimal turn hex​ ​ , int type and the corresponding string Huzhuan the method for the program.
Date : 2026-01-07 Size : 1.08mb User : 钟武俊

本源码用以实现以下功能的中间代码生成: 1.‘+’ ‘-‘ ‘*’ ‘/’ 四则运算的中间代码生成. 2.类型的扩展,比如Int扩展到Float -The source code for the following functions middle generation: 1.' +' ' -' ' *' ' /' Four operations generate intermediate code 2. Type of extensions, such as Int extended to Float.
Date : 2026-01-07 Size : 1.05mb User : xiaowang
« 12 3 4 »
CodeBus is one of the largest source code repositories on the Internet!
Contact us :
1999-2046 CodeBus All Rights Reserved.