Comments (11)
徐老师关于此问题的回复:在实验题目的测试数据示例中,运算符(+,>),关键词(while)都没有属性(属性为无)。这样定义是可以的,但更鼓励进行实验时由后续语法分析的需要来重新定义单词种别及属性。
from compiler.
返回值INT
表示种别:需要定义各个种别的整型值
int scan(char* input)
全部变量
表示单词属性:需要定义全局变量存储单词属性
例子
种别 | 属性 |
---|---|
INT10 | 0 |
INT10 | 92 |
+ | _ |
IDN | data |
> | _ |
INT16 | 63 |
INT8 | 0 |
WHILE | _ |
from compiler.
@Jakob1357 语法分析中对词法分析器的种别和属性的需求大概是?
from compiler.
@hanliutong 目前来看,我觉得需要的属性有三类数字,返回的是三种int型的值;标识符,返回一个类。感觉关键字和+,-这样的关键字和运算符暂时可以无属性。如果行不通可以再讨论。
from compiler.
@Jakob1357 标识符返回的是它本身吗?比如说上面韩柳彤发的例子中输入数据"data"的属性就为data。
from compiler.
@bjutfgxqzn 你是说返回的是个字符串吗?
from compiler.
@Jakob1357 是的
from compiler.
我在想有没有必要以宏定义的形式把接口返回的种别单独定义在一个头文件里 @bjutfgxqzn @hanliutong
from compiler.
类似于#define INT10 10
?我感觉好像确实会优雅一点 @WDDcat
from compiler.
对对对,这样代码可读性也强一些 @hanliutong
from compiler.
int NUM = 0;
INT8 INT10 INT16属性的全局变量
string IDN_NAME;
标识符属性的全局变量
from compiler.
Related Issues (11)
- 词法分析器的算符部分 HOT 4
- 通过NUM变量传参时,参数会在下个字符识别完成后返回 HOT 1
- 词法分析器剩余任务 HOT 1
- 三地址代码生成 逻辑部分 HOT 1
- 词法分析器的KeyWord分析部分 HOT 4
- 请将确定的接口形式更新到./lex/Readme.md里 HOT 2
- 没有input += index; 导致死循环 HOT 1
- 语法分析器“逻辑控制”部分 HOT 1
- 词法分析器TodoList已更新,请认领任务
- 增量八进制、十六进制转换为十进制代码,并调通NUM接口 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler.