Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java program...need help as soon as possible!!!

Have Programming Question? Ask it here!
 
 
 


samaya khan
java program...need help as soon as possible!!!
0 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners


Modify the Lexer (15 points):
1. Use a command line argument for the input file for processing tokens ? do not use simple.x

2. Recognize the new tokens > void float
Be sure to change token file appropriately and then run TokenSetup as required

3. Include line number information within tokens for subsequent error reporting, etc.

4. Print each token with line number
READLINE: program { int i int j
program left: 0 right: 6 line: 1
{ left: 8 right: 8: line: 1
int left: 10 right: 12 line: 1
i left: 14 right: 14 line: 1
int left: 16 right: 18 line: 1
j left: 20 right: 20 line: 1
.
.

5. Output the source program with line numbers (since SourceReader reads the source lines it should save the program in memory for printout after the tokens are scanned):
e.g.

1. program { int i int j
2. i = 2
3. j = 3
4. i = write(j+4)
5. }

If you encounter an error, e.g. you find a "%" on line 7 of the source file that contains 20 lines, then you should:
1. report the error
2. stop processing tokens at that point
3. echo the lines of the source file with line numbers up to and including the error line - e.g., echo lines 1 through 7 inclusive in the case with the "%" on line 7
4. exit

Comments on this lab..

1. TokenSetup should NOT be changed
2. The tokens file should be changed appropriately
3. Use the main method in Lexer.java for testing - DO NOT use other packages in the compiler (e.g. Compiler.java) since there will always be complaints due to not recognizing the new constructs
4. Each character in the input stream should be accounted for - never ignored..
5. I will post your test case just prior to the due date.
6. REMOVE ALL DEBUG statements not required

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com