asked 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

asked
User FitzFish
by
8.6k 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);

}

}

}

answered
User Morteza Adi
by
7.9k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.

Categories