[V0.2.1]A simple compiler - lexical analysis

 
input file:in.txt    output file:out.txt
time limit: 500ms
language:ASM、C、C++、C#、Java、VB

Difficulty:★★★★
Describe:
    The backtracking algorithm is the most fundamental part but not the most graceful part of this project's underlying as we will also use compiling technique on it.Let's have a look at the simple set and subset problem.Assume that we have a universal set U and n subsets I0,I1...In.Now several logical expressions have given to you,please try to make lexical analysis on them.
Input:
    The first line:Define variables in the format shown in Sample Input;
    The following lines:Logic expressions in the format shown in Sample Input.
Output:
    For each expression,print out all its words.If there is some syntax errors in the input file,print a single line showing the first syntax error and its line number in the format shown in Sample Output. Notice that you don't have to find out all the syntax errors in input file.
Sample Input1:
dim 变量一,变量二,条件A,条件B,flag,flag_
printwords 变量一&(变量二|flag)
printwords !(条件A|flag&条件B)&flag_|!变量一
Sample Output1:
变量一
&
(
变量二
|
flag
)

!
(
条件A
|
flag
&
条件B
)
&
flag_
|
!
变量一
Sample Input2:
define 变量一,变量二,条件A,条件B,flag,flag_
printwords 变量一&(变量二|flag)
printwords !(条件A|flag&条件B)&flag_|!变量一
Sample Output2:
Error(Line 1):Undecleared identitier "define"!
Sample Input3:
dim 变量一,变量二,条件A,条件B,flag
printwords 变量一&(变量二|flag)
printwords !(条件A|flag&条件B)&flag_|!变量一
Sample Output3:
Error(Line 3):Undecleared identitier "flag_"!
Sample Input4:
dim 变量一,变量二,条件A,条件B,flag
printwords 变量一&&(变量二|flag)
printwords !(条件A|flag&条件B)&flag_|!变量一
Sample Output4:
Error(Line 2): Unrecognized expression: "&&"!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值