Documentos de Académico
Documentos de Profesional
Documentos de Cultura
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*Matcher es la encargada de que la cadena introducida concuerde con el
patron
* Pattern => Es la encargada de definir el patron
*/
/**
*
* @author edwin
*/
public class Compiladores {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
/*
* Lo primero que se hace es definir el patron
*/
String instruccion;
while (matcher.find()){
instruccion = matcher.group(1);
if(instruccion != null){
System.out.println("Palabra reservada :" + instruccion );
}
instruccion = matcher.group(2);
if(instruccion != null){
System.out.println("Numero :" + instruccion);
}
// String identificador = matcher.group(2);
instruccion= matcher.group(3);
if(instruccion != null){
System.out.println("identificador :" + instruccion );
}
//String operador = matcher.group(3);
instruccion = matcher.group(4);
if(instruccion != null){
System.out.println("Operador :" + instruccion );
} }
}