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 ...
随机推荐
- HoloLens开发手记 - 测试 Testing
测试HoloLens应用的做法和测试Windows应用很类似.所有常规的内容都应该被考虑在内(功能.互操作性.性能.安全性.可靠性等等),然而有些特性是HoloLens特有的,在PC或者手机上无法测试 ...
- JavaScript中的类型转换(二)
说明: 本篇主要讨论JavaScript中各运算符对运算数进行的类型转换的影响,本文中所提到的对象类型仅指JavaScript预定义的类型和程序员自己实现的对象,不包括宿主环境定义的特殊对象(比如浏览 ...
- Tensorflow学习笔记4:分布式Tensorflow
简介 Tensorflow API提供了Cluster.Server以及Supervisor来支持模型的分布式训练. 关于Tensorflow的分布式训练介绍可以参考Distributed Tenso ...
- codevs 4543 treap 模板
type rec=record lc,rc,v,rnd,size,w,fa:longint; end; var n,root,tot,ans,opt,x,i,po:longint; tr:array[ ...
- [转]C#操作注册表
原文链接:http://www.cnblogs.com/txw1958/archive/2012/08/01/csharp-regidit.html 下面我们就来用.NET下托管语言C#注册表操作,主 ...
- Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo
更新了xcode后使用goland运行项目时提示 Agreeing to the Xcode/iOS license requires admin privileges, please re-run ...
- Alpha版本冲刺现场演示和阶段验收的总结
一共15个组.有13个组参加了今天的现场演示,分别是YZH.Radio Group.FZU5BOYS.静静看.Clean Code.Mod4.F4.For the Dream.Journey of C ...
- 软件工程(FZU2015)增补作业
说明 张老师为FZU软件工程2015班级添加了一次增补作业,总分10分,deadline是2016/01/01-2016/01/03 前11次正式作业和练习的迭代评分见:http://www.cnbl ...
- inheritableStatics 与statics类
/** * statics 可以包含类的静态和静态方法,但是不能被子类继承 * inheritableStatics 与statics类似但是可以被子类继承 */ Ext.onReady(functi ...
- T3 任职定级面试准备
山东大学计算机专业本科毕业,工作8年,以前在华为工作,来YY正好1年. 个人心态开放积极,对未知事物好奇心很强,前沿科学.古老宗教皆有涉猎.英语口语能力较强,能和老外流程的交流.技术涉猎广泛,喜好研究 ...