47.1k views
3 votes
3) Write code in a language of your choice that checks a source file (input file in plain text format) that separates lexemes by white space and special characters. This lexical analyzer will only have tokens for special characters and alphanumeric strings. Ie: 2345 6tgbsauhd9sa67*I{OPKDSl;jaklhl Would be 2345 6tgbsauhd9sa67 * I { OPKDSl ; jaklhl

User FitzFish
by
4.5k points

1 Answer

5 votes

Answer:

Step-by-step explanation:

CODE:

import java.io.*;

class Test

{

public static void main(String[] args) {

File file = new File("input.txt");

try{

BufferedReader b = new BufferedReader(new FileReader(file));

String line;

while ((line = b.readLine()) != null)

{

for(int i=0;i<line.length();i++)

char c=line.charAt(i);

if((c>='A' && c<='Z')

}

}

catch(Exception e)

{

System.out.println(e);

}

}

}

User Morteza Adi
by
4.5k points