Question: Syntactic Analyzer (assembly) in java. Complete program to cover the following points . Identify lines that end in : (tag), check that there are no

Syntactic Analyzer (assembly) in java.

Complete program to cover the following points.

Identify lines that end in ":" (tag), check that there are no spaces in the name and save the name in an arraylist as long as it has not been saved before. Validate that you do not have two with the same name.

Invalid tags:

Tag :: double ":" With space: no spaces allowed 1234: can not be only number, must start with letter or underscore _

Program:

package softwaresistemas;

import java.io.*;

public class FileASM {

public static void main (String args[]){

String linea;

try {

File archivoFuente = new File ("C:/Ensamblador/02TLIGHT.ASM");

FileReader fr = new FileReader (archivoFuente);

BufferedReader br = new BufferedReader(fr);

FileWriter archivoMaquina = new FileWriter("c:/Ensamblador/02TLIGHTNuevo.ASM");

PrintWriter pw = new PrintWriter(archivoMaquina);

while((linea=br.readLine())!=null){

linea = linea.trim();

if(linea.length()>0){

if(!linea.startsWith(";")){

System.out.println(linea);

pw.println(linea);

}

}

}

fr.close();

archivoMaquina.close();

}

catch(Exception e3){

e3.printStackTrace();

}finally{

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!