当前位置:天才代写 > JAVA代写,java代考-JAVA作业代写免费Moss检测 > 代写编译原理java cs代写实现+Report

代写编译原理java cs代写实现+Report

2018-10-17 08:00 星期三 所属: JAVA代写,java代考-JAVA作业代写免费Moss检测 浏览:1034

代写编译原理java In this project, you will only be updating the hand-crafted scanne TokenInfo.java and Scanner.java.

Objectives.

1. Support multiline comments.

2. Support additional tokens (reserved words, operators, and separators).

3. Support long and double literals.

代写编译原理java
代写编译原理java

In this project, you will only be updating the hand-crafted scanner, which means that the only program files you will be modifying under $j/j–/src/jminusminus are TokenInfo.java and Scanner.java.

Run the following command inside the $j directory to compile the j– compiler with your changes.

$ ant clean com pile jar

Run the following command to compile (just scan for now) a j– program P.java using the j– compiler.

$ sh $j /j  -/ bin /j   -t P . java

which only scans P.java and prints the tokens in the program along with the line number where each token appears.

 

 Problem 1. (Multiline Comment ) Add support for multiline comment, where all the text from the ASCII characters /* to the ASCII characters */ is ignored.

$   $j /j - -/ bin /j - -   -t   tests / M ultiL ineC om m ent . java
5 : public = public
5 : class = class
5 :   < IDENTIFIER >   =   M ultiL ineC om m ent 5 : { = {
9 :  public  = public
9 : static =  static
9 : void = void
9 :   < IDENTIFIER >   =   main
9 : ( = (
9 :   < IDENTIFIER >   =   S tring
9 :  [  = [
9 :  ]  = ]
9 :   < IDENTIFIER >   =   args
9 :  )  = )
9 :  {   = {
13 :  }  = }
14 :  }  = }
15 : < EOF > = < EOF >

 

 

Problem 2. (Reserved Words) Add support for the following reserved words.

 

break

case

catch

continue

default

do

double

final

finally

for

im plem ents

interface

long

sw itch

throw

throw s

try

$ $j /j - -/ bin /j - - -t tests / R eserved W ords . java
1 : break = break
1 : case = case
1 : catch = catch
2 : continue = continue
2 : default = default
2 : do = do
3 : double = double
3 : final = final
3 : finally = finally
4 : for = for
4 :   im plem ents   =   im plem ents
4 : interface = interface



 

 

Problem 3. (Operators) Add support for the following operators.

 

?

~

!=

/

/=

-=

*=

 

=

>>

> >=

> > >

> > >=

>=

<<

< <=

<

^

^=

|

|=

||

&

&=

$ $j /j - -/ bin /j - - -t tests / O perators . java 1 : ? = ?
1 :  ~   = ~
1 : != = !=
1 : / = /
1 :   /=   =   /=
2 :  -=  = -=
2 :  -- =  --
2 :  *=  = *=
2 : =
2 : =  = =
3 :  >>  = >>
3 : > >=  =  > >=
3 : > > >  =  > > >
3 : > > >= = > > >=
3 :  >=  = >=
4 :  <<  = <<
4 : < <= = < <=
4 :  <   = <
4 :  ^   = ^
4 : ^= = ^=
5 : | = |
5 :   |=   =   |=
5 :  || = ||
5 : & = &
5 : &= = &=
6 : < EOF > = < EOF >

 Problem 4. (Separators) Add support for the separator : (colon).

 

 
$ $j /j - -/ bin /j - - -t tests / S eparators . java 1 : ; = ;
2 :  :  = :
3 :  , = ,
4 : . =   .
5 :  [  = [
5 :  {   = {
5 :  (  = (
5 :  )  = )
5 :  }   = }
5 :  ]  = ]
6 : < EOF > = < EOF >

 Problem 5. (Literals) Add support for (just decimal for now) long and double literals.

 

 

 

< int_literal >   =   0   |   (1 -9)   {0 -9}   //   decim al
 
< long_literal > = < int_literal > ( l | L )
 
< digits > = (0 -9) {0 -9}
 
< exponent > = ( e | E ) [(+ | -)] < digits >
 
< suffix > = d | D
 
< double_literal > = < digits > . [< digits >] [< exponent >] [< suffix >]
| . < digits > [< exponent >] [< suffix >]
| < digits > < exponent > [< suffix >]
| < digits > [< exponent >] < suffix >

$ $j /j - -/ bin /j - - -t tests / L iterals . java
1 :   < IN T _LIT E R A L >   =   0
1 :   < IN T _LIT E R A L >   =   2
1 :   < IN T _LIT E R A L >   =   372
2 : < L O N G _L IT E R A L > = 1996 l
2 : < L O N G _L IT E R A L > = 777 L
2 : < D O U B L E _L IT E R A L > = .3 D
3 : < D O U B L E _L IT E R A L > = 3.14
3 : < D O U B L E _L IT E R A L > = 6.022137 e +23
3 : < D O U B L E _L IT E R A L > = 1e -9 d
4 : < EOF > = < EOF >

Files to Submit

1. j–.tar.gz (j– source tree as a single gzip file)

2. report.txt (project report)

 

 
$  cd $j /j --
$  ant clean
$ cd ..
$ tar - cvf j - -. tar j - -/*
$ gzip j - -. tar
最先出自天才代写 cs代写 作业代写 java代写 代写java服务代写编译原理java
合作:幽灵代写
 

天才代写-代写联系方式