Question: I have provided the program but I need to show screenshots of the output from the executable program. Can you provide my request? Class 1
I have provided the program but I need to show screenshots of the output from the executable program. Can you provide my request? Class : JavaFileAnalyzerjava
JavaFileAnalyzer.java
Name: Elbert Clements
Project: Delimiter Matching
Date:
Description: This class encapsulates the input file and provides methods to read characters excluding comments and literals.
import java.io;
public class JavaFileAnalyzer
private BufferedReader reader;
private int lineNumber;
private int charNumber;
private String currentLine;
private int currentIndex;
public JavaFileAnalyzerString fileName throws FileNotFoundException
reader new BufferedReadernew FileReaderfileName;
lineNumber ;
charNumber ;
currentLine null;
currentIndex ;
public char getNextChar throws IOException
while true
if currentLine null currentIndex currentLine.length
currentLine reader.readLine;
if currentLine null
return ; End of file
lineNumber;
currentIndex ;
char c currentLine.charAtcurrentIndex;
charNumber;
Skip comments and literals
if c && currentIndex currentLine.length && currentLine.charAtcurrentIndex
currentLine null; Skip singleline comment
continue;
else if c && currentIndex currentLine.length && currentLine.charAtcurrentIndex
Skip multiline comment
currentIndex;
while true
if currentLine null currentIndex currentLine.length
currentLine reader.readLine;
if currentLine null
return ; End of file
lineNumber;
currentIndex ;
if currentLinecharAtcurrentIndex && currentIndex currentLine.length && currentLine.charAtcurrentIndex
currentIndex ;
break;
currentIndex;
continue;
else if c c
Skip string and character literals
char quote c;
while true
if currentLine null currentIndex currentLine.length
currentLine reader.readLine;
if currentLine null
return ; End of file
lineNumber;
currentIndex ;
c currentLine.charAtcurrentIndex;
if c quote
break;
continue;
return c;
public String getCurrentPosition
return "Line: lineNumber Char: charNumber;
Class : DelimiterMatcherjava
DelimiterMatcher.java
Name: Elbert Clements
Project: Delimiter Matching
Date:
Description: This class contains the main method to read the file name, create an object of JavaFileAnalyzer, and check for matching delimiters.
import java.io;
import java.util.;
public class DelimiterMatcher
public static void mainString args
Scanner scanner new ScannerSystemin;
JavaFileAnalyzer analyzer null;
while analyzer null
System.out.printEnter the Java source file name: ;
String fileName scanner.nextLine;
try
analyzer new JavaFileAnalyzerfileName;
catch FileNotFoundException e
System.out.printlnFile not found. Please try again.";
Stack stack new Stack;
try
char c;
while c analyzer.getNextChar
if c c c
stack.pushc;
else if c c c
if stackisEmpty
System.out.printlnUnmatched c at analyzer.getCurrentPosition;
return;
char last stack.pop;
if isMatchingPairlast c
System.out.printlnMismatched last and c at analyzer.getCur
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
