PL/0编译器(java version) – Symbol.java
1: package compiler;
2:
3: /**
4: * 采用全局变量sym来存储符号码,并用全局变量id和num来传递语义值
5: *
6: * @author jiangnan
7: *
8: */
9: public class Symbol {
10:
11: //各类符号码
12: public static final int nul = 0; //NULL
13: public static final int ident = 1; //标识符
14: public static final int plus = 2; //加号+
15: public static final int minus = 3; //减号-
16: public static final int mul = 4; //乘号*
17: public static final int div = 5; //除号/
18: public static final int oddsym = 6; //odd
19: public static final int number = 7; //数字
20: public static final int eql = 8; //等于号=(equal)
21: public static final int neq = 9; //不等于<>(not equal)
22: public static final int lss = 10; //小于<(less)
23: public static final int geq = 11; //大于等于>=(greater or equal)
24: public static final int gtr = 12; //大于>(greater)
25: public static final int leq = 13; //小于等于<=(less or equal)
26: public static final int lparen = 14; //左括号(
27: public static final int rparen = 15; //右括号 )
28: public static final int comma = 16; //逗号,
29: public static final int semicolon = 17; //分号;
30: public static final int peroid = 18; //句号.
31: public static final int becomes = 19; //赋值符号 :=
32: public static final int beginsym = 20; //开始符号begin
33: public static final int endsym = 21; //结束符号end
34: public static final int ifsym = 22; //if
35: public static final int thensym = 23; //then
36: public static final int whilesym = 24; //while
37: public static final int writesym = 25; //write
38: public static final int readsym = 26; //read
39: public static final int dosym = 27; //do
40: public static final int callsym = 28; //call
41: public static final int constsym = 29; //const
42: public static final int varsym = 30; //var
43: public static final int procsym = 31; //procedure
44: public static final int elsesym = 32;
45: public static final int repeatsym=33;
46: public static final int untilsym=34;
47:
48: //符号码的个数
49: public static final int symnum = 35;
50:
51: //设置保留字名字,按照字母顺序,便于折半查找
52: public static final String[] word = new String[]{
53: "begin","call" , "const" , "do" ,
54: "else" ,"end" ,"if" , "odd",
55: "procedure", "read","repeat","then",
56: "until" , "var", "while" , "write" };
57: //保留字对应的符号值
58: public static final int[] wsym = new int[]{
59: beginsym, callsym, constsym, dosym,
60: elsesym, endsym, ifsym,oddsym,
61: procsym,readsym,repeatsym, thensym,
62: untilsym ,varsym,whilesym, writesym};
63:
64: //符号码
65: public int symtype;
66: //标志符号名字;
67: public String id;
68: //数值的大小
69: public int num;
70:
71: /**
72: * 构造具有特定符号码的符号
73: *
74: * @param stype
75: */
76: public Symbol(int stype) {
77: symtype = stype;
78: id = "";
79: num = 0;
80: }
81: }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
PL/0编译器(java version) – Symbol.java的更多相关文章
- PL/0编译器(java version) - MainFrame.java
1: /* 2: * To change this license header, choose License Headers in Project Properties. 3: * To chan ...
- PL/0编译器实践---后记
花了几天时间,把清华版的<编译原理>一书中的PL/0编译器实践了一遍.颇有收获,记录如下: 理解代码的技巧,如何理解一份代码,比如这个程序,其逻辑相对于一般程序就比较复杂了,如何翻译,虚拟 ...
- PL/0编译器(java version)–Praser.java
1: package compiler; 2: 3: import java.io.IOException; 4: import java.util.BitSet; 5: 6: /** 7: ...
- PL/0编译器(java version) – Scanner.java
1: package compiler; 2: 3: import java.io.BufferedReader; 4: import java.io.FileNotFoundException; ...
- PL/0编译器(java version) – SymbolTable.java
1: package compiler; 2: //竟然没有对符号表检查大小,会溢出的. 3: 4: import java.io.IOException; 5: 6: public clas ...
- PL/0编译器(java version)–PL0.java
1: package compiler; 2: 3: import java.io.BufferedWriter; 4: import java.io.FileWriter; 5: 6: /* ...
- PL/0编译器(java version) - Interpreter.java
1: package compiler; 2: 3: import java.io.BufferedReader; 4: import java.io.BufferedWriter; 5: imp ...
- PL/0编译器(java version) - Err.java
1: package compiler; 2: 3: import java.io.BufferedWriter; 4: 5: public class Err { 6: 7: publi ...
- PL/0编译器(java version)–Pcode.java
1: package compiler; 2: 3: /** 4: * //虚拟机指令 5: * 6: * @author jiangnan 7: * 8: */ 9: public class ...
随机推荐
- 微软分布式云计算框架Orleans(1):Hello World
自从写了RabbitHub框架系列后的一段时间内一直在思索更加轻量简便,分布式高并发的框架(RabbitHub学习成本较高),无意间在网上级联看到了很多新框架:从helios到Akka.NET在到Or ...
- bootstrap点滴
1.nav-stacked 这个属性可以决定 tab的变为竖的,不添加的话为横向的. 2.tab 横向的 ul中必须含有nav nav-tabs ul li a 中必须有data-toggle=&q ...
- SQL2008R2 不支持用该后端版本设计数据库关系图或表
向下不兼容. 要么安装SQL2012,要么把SQL2012数据库通过脚本转成2008
- HTTP请求头参数
Accept-Language: zh-cn,zh;q=0.5 意思:浏览器支持的语言分别是中文和简体中文,优先支持简体中文. 详解: Accept-Language表示浏览器所支持的语言类型: ...
- 树链剖分(+线段树)(codevs4633)
type node=^link; link=record des:longint; next:node; end; type seg=record z,y,lc,rc,toadd,sum:longin ...
- Matlab学习笔记 figure函数
Matlab学习笔记 figure函数 matlab中的 figure 命令,能够创建一个用来显示图形输出的一个窗口对象.每一个这样的窗口都有一些属性,例如窗口的尺寸.位置,等等.下面一一介绍它们. ...
- No Launcher activity found!
已经研究Android有几天了,刚开始写的代码说安装成功,但是在AVD没有显示.左看代码,右看代码,总是没找到错误, <application android:allowBackup=" ...
- date 显示或设置系统时间和日期
显示或设置系统时间和日期 date [options] [+format] date [options] [new date] date用来显示系统的时间和日期,超级用户可以使用date来更改系统时钟 ...
- mycat 9066管理端口 常用命令
1.连接mycat 9066管理端口 命令:mysql -uroot -proot -P9066 -h127.0.0.1 -u:用户名 -p:密码 -P:端口 -h:ip地址例:linux路径切换到m ...
- [转]Servlet 中文乱码问题及解决方案剖析
原文地址:http://blog.csdn.net/xiazdong/article/details/7217022/ 一.常识了解 1.GBK包含GB2312,即如果通过GB2312编码后可以通过G ...