miércoles, 8 de abril de 2009

AnalizadorLex.java


No es posible escribir algunas instrucciones en el blog por que lo toma como codigo Script asi que en algun editor de texto

Reemplaza:





/*
* AnalizadorLex.java
* Autor: craneodelrey@msn.com
* Este programa lee un archivo de texto y calcula las parejas ordenadas <[Token],[Lexema]>
* por medio de un Autómata Finito mmm... Determinista
* Lee línea por línea devolviendo un arreglo con los tokens para su manipulación
*/

import java.io.*;
import java.awt.*;
import java.util.*;
public class AnalizadorLex{
>>>---public static String arrayTokens [][];
>>>---public static int numCar = 0;
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Modulo principal
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>>>---public static void main(String[] args)throws IOException{
>>>--->>>---if(args.length == 0){
>>>--->>>--->>>---System.out.println("No se especifican ficheros");
>>>--->>>---}
/*
>>>--->>>---for(int i = 0; i?args.length; i++){
>>>--->>>--->>>---contenidoFichero(args[i]);
>>>--->>>---}
*/
>>>--->>>---contenidoFichero("Test.plo");
>>>---}


///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Modulo Secundario que lee los Ficheros
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>>>---public static void contenidoFichero(String nombreFichero){
>>>--->>>---FileReader elFichero;
>>>--->>>---BufferedReader lector = null;
>>>--->>>---String linea;
>>>--->>>---try{
>>>--->>>--->>>---elFichero = new FileReader(nombreFichero);
>>>--->>>--->>>---lector = new BufferedReader(elFichero);
>>>--->>>--->>>---while((linea = lector.readLine()) != null){
>>>--->>>--->>>--->>>---numCar = linea.length();
>>>--->>>--->>>--->>>---///Por cada linea se devueve un arreglo de N filas y dos columnas con los tokens enontrados
>>>--->>>--->>>--->>>---arrayTokens = separarTokens(linea);
>>>--->>>--->>>--->>>---for (int I = 0; I?arrayTokens.length; I++){
>>>--->>>--->>>--->>>--->>>---System.out.println(arrayTokens[I][0] + ">>>---" + arrayTokens[I][1]);
>>>--->>>--->>>--->>>---}
>>>--->>>--->>>--->>>---System.out.println("");
>>>--->>>--->>>---}>>>---
>>>--->>>---}catch(Exception e){
>>>--->>>--->>>---System.out.println(e);
>>>--->>>---}
>>>--->>>---//Cierre del fichero
>>>--->>>---try{
>>>--->>>--->>>---if (lector != null){
>>>--->>>--->>>--->>>---lector.close();
>>>--->>>--->>>---}
>>>--->>>---}catch(IOException e){
>>>--->>>---}
>>>---}


///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion separarTokens: Devuelve un arreglo de Tokens
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>>>---static String [][] separarTokens(String row){
>>>--->>>---int N = row.length();>>>---//longitud de la cadena
>>>--->>>---int i = 0;>>>--->>>--->>>--->>>---//numero de caracter
>>>--->>>---String nodo = "0";>>>--->>>---//estado del automata actual
>>>--->>>---String word = "";>>>--->>>---//palabra o token que se esta formando
>>>--->>>---char car = ' ';>>>--->>>--->>>---//caracter que sera analizado por el automata
>>>--->>>---int numTokens = 0;
>>>--->>>---int nT = numTokens;
>>>--->>>---//como en java los "Strings" son objetos, necesite de un arreglo temporal para modificar
>>>--->>>---//el tamaño del "Array de Strings" original
>>>--->>>---String Tokens [][] = new String [numTokens+1][2];
>>>--->>>---String TokensT[][] = new String [numTokens+1][2];
>>>--->>>---while (i<=N){ >>>--->>>--->>>---if (i==N){
>>>--->>>--->>>--->>>---//Se supone que estamos un indice despues del final de la linea por lo que
>>>--->>>--->>>--->>>---//solo se añade el estado final de automata y que la linea nunca estara vacia
>>>--->>>--->>>--->>>---//lo cual es controlado por el modulo en donde se leen los archivos
>>>--->>>--->>>--->>>---nodo = nodo + ".0";
>>>--->>>--->>>--->>>---i++;
>>>--->>>--->>>---}else{
>>>--->>>--->>>--->>>---car = Character.toUpperCase(row.charAt(i));
>>>--->>>--->>>--->>>---nodo = nodoSiguiente(nodo, car);
>>>--->>>--->>>--->>>---
>>>--->>>--->>>---}
/**
La siguente parte es para preparar el Arreglo de Strings y añadir un token cuando se haya encontrado
No es de gran importancia. Si se omitiera y se escribiera directamente en el archivo que se desea crear
aumentaria considerablemente la velocidad de ejecucion del programa...
Por motivos pesonales decidi que la funcion devolviera un Arreglo con los tokens
He tratado lo mas posible de que la forma de programacion sea lo mas parecido a los dos lenguajes que mas
practico C++ y Visual Basic para que otros puedan implantarlo en dichos lenguajes

Diria que este es mi primer programa serio en Java pues veran que desconosco algunos metodos para manejar
correctamente los Strings
*/
>>>--->>>--->>>---if (numTokens != nT){
>>>--->>>--->>>--->>>---///Copio el arreglo original al arreglo temporal para incrementar en numero de filas
>>>--->>>--->>>--->>>---for (int I=0; I?numTokens; I++){
>>>--->>>--->>>--->>>--->>>---TokensT[I][0] = (new String(Tokens[I][0]));
>>>--->>>--->>>--->>>--->>>---TokensT[I][1] = (new String(Tokens[I][1]));
>>>--->>>--->>>--->>>---}
>>>--->>>--->>>--->>>---///Se supone que antes ya se añadio un token por lo que se nesecita de una nueva linea
>>>--->>>--->>>--->>>---Tokens = new String [numTokens+1][2];
>>>--->>>--->>>--->>>---nT = numTokens;
>>>--->>>--->>>--->>>---///Copio el arreglo temporal al nuevo arreglo original
>>>--->>>--->>>--->>>---for (int I=0; I?numTokens; I++){
>>>--->>>--->>>--->>>--->>>---Tokens[I][0] = (new String(TokensT[I][0]));
>>>--->>>--->>>--->>>--->>>---Tokens[I][1] = (new String(TokensT[I][1]));
>>>--->>>--->>>--->>>---}
>>>--->>>--->>>--->>>---TokensT = new String [numTokens+1][2];
>>>--->>>--->>>---}
/**
Se iran añadiendo nuevas filas despues de añadir un token y hasta que se haya llegado al final de la
linea, lo cual es controlado por la primera senencia: if (i==N){
*/

/// E S T A D O S F I N A L E S D E L A U T O M A T A
>>>--->>>--->>>---//Caracter invalido-----------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.0.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("CaracterInvalido");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = ("(C)");
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Identificadores-------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.1.0")){
>>>--->>>--->>>--->>>---if (isIdentifier(word)){
>>>--->>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("PalabraReservada");
>>>--->>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---}else{
>>>--->>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Identificador");
>>>--->>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---}
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Numero Entero---------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.2.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("NumeroEntero");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Numero Real-----------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.2.1.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("NumeroReal");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Numero Real-----------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.2.1.1.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("NumeroReal");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Punto-----------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.3.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Punto");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Coma------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.4.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Coma");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Punto y Coma----------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.5.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("PuntoYComa");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Dos puntos------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.6.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("DosPuntos");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Dos Puntos Igual------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.6.1.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("DosPuntosIgual");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Parentesis Izquierdo--------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.7.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("ParentesisIzq");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Parentesis Derecho----------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.8.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("ParentesisDer");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Suma------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.9.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Suma");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Resta-----------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.10.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Resta");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Multiplicacion--------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.11.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Multiplicacion");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Division--------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.12.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Division");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Div-------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.13.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Div");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Mod-------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.14.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Mod");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Menor-----------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.15.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Menor");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Menor o Igual---------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.15.1.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("MenorIgual");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Mayor-----------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.16.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Mayor");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Mayor o Igual---------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.16.1.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("MayorIgual");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---System.out.println(word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Gato------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.17.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Gato");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Igual-----------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.18.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Igual");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//And-------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.19.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("And");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Or--------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.20.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Or");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Not-------------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.21.0")){
>>>--->>>--->>>--->>>---Tokens[numTokens][0] = ("Not");
>>>--->>>--->>>--->>>---Tokens[numTokens][1] = (word);
>>>--->>>--->>>--->>>---numTokens += 1;
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Nueva Linea-----------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.22.0")){
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Espacio---------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.23.0")){
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---//Tabulacion------------------------------------------------------------
>>>--->>>--->>>---if (nodo.equals("0.24.0")){
>>>--->>>--->>>--->>>---word = "";
>>>--->>>--->>>--->>>---nodo = "0";
>>>--->>>--->>>---}
>>>--->>>--->>>---
>>>--->>>--->>>---if ((nodo.equals("0")) YY (word.equals(""))){
>>>--->>>--->>>---}else{
>>>--->>>--->>>--->>>---word = word + car;
>>>--->>>--->>>--->>>---i++;
>>>--->>>--->>>---}
>>>--->>>---}


/*
>>>--->>>---for (int I = 0; I?numTokens; I++){
>>>--->>>--->>>---System.out.println(Tokens[I][0] + " " + Tokens[I][1]);
>>>--->>>---}
*/

>>>--->>>---return Tokens;
>>>---}
>>>---
>>>---
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion nodoSigiente: Devuelve un String para calcular el estado del Automata
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>>>---public static String nodoSiguiente(String nodo, char car){
>>>--->>>---//guarda el estado del Automata para poder usarlo en caso de requerirlo
>>>--->>>---String nodoT = new String(nodo);
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---//Tipo invalido---------------------------------------------------------
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---if (carTipo(car)==-1){
>>>--->>>--->>>---if (nodo.equals("0")){ nodo="0.0"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---//Tipo caracter---------------------------------------------------------
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---if (carTipo(car)==0){
>>>--->>>--->>>---if (nodo.equals("0")){
>>>--->>>--->>>--->>>---nodo="0.1";
>>>--->>>--->>>---}else if(nodo.equals("0.1")){
>>>--->>>--->>>--->>>---nodo="0.1";
>>>--->>>--->>>---}else{
>>>--->>>--->>>--->>>---nodo = nodoT + ".0";
>>>--->>>--->>>---}
>>>--->>>---}
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---//Tipo numero-----------------------------------------------------------
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---if (carTipo(car)==1){
>>>--->>>--->>>---if (nodo.equals("0")){
>>>--->>>--->>>--->>>---nodo="0.2";
>>>--->>>--->>>---}else if(nodo.equals("0.2")){
>>>--->>>--->>>--->>>---nodo="0.2";
>>>--->>>--->>>---}else if(nodo.equals("0.2.1")){
>>>--->>>--->>>--->>>---nodo="0.2.1.1";
>>>--->>>--->>>---}else if(nodo.equals("0.2.1.1")){
>>>--->>>--->>>--->>>---nodo="0.2.1.1";
>>>--->>>--->>>---}else{
>>>--->>>--->>>--->>>---nodo = nodoT + ".0";
>>>--->>>--->>>---}
>>>--->>>---}
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---//otros Tipos-----------------------------------------------------------
>>>--->>>---//----------------------------------------------------------------------
>>>--->>>---//03
>>>--->>>---if (car=='.'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.3";
>>>--->>>--->>>---}else if (nodo.equals("0.2")){ nodo="0.2.1";
>>>--->>>--->>>---}else{ nodo = nodoT + ".0";
>>>--->>>--->>>---}
>>>--->>>---}
>>>--->>>---//04
>>>--->>>---if (car==','){
>>>--->>>--->>>---if (nodo.equals("0")){ nodo="0.4"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//05
>>>--->>>---if (car==';'){
>>>--->>>--->>>---if (nodo.equals("0")){ nodo="0.5"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//06
>>>--->>>---if (car==':'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.6"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//07
>>>--->>>---if (car=='('){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.7"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//08
>>>--->>>---if (car==')'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.8"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//09
>>>--->>>---if (car=='+'){
>>>--->>>--->>>---if (nodo.equals("0")){ nodo="0.9"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//10
>>>--->>>---if (car=='-'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.10"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//11
>>>--->>>---if (car=='*'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.11"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//12
>>>--->>>---if (car=='/'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.12"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//13
>>>--->>>---if (car=='\\'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.13"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//14
>>>--->>>---if (car=='%'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.14"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//15
>>>--->>>---if (car=='<'){ >>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.15"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//16
>>>--->>>---if (car=='>'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.16"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//17
>>>--->>>---if (car=='#'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.17"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//18
>>>--->>>---if (car=='='){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.18";
>>>--->>>--->>>---}else if (nodo.equals("0.15")){ nodo="0.15.1";
>>>--->>>--->>>---}else if (nodo.equals("0.16")){ nodo="0.16.1";
>>>--->>>--->>>---}else{ nodo = nodoT + ".0";
>>>--->>>--->>>---}
>>>--->>>---}
>>>--->>>---//19
>>>--->>>---if (car=='&'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.19"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//20
>>>--->>>---if (car=='?'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.20"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//21
>>>--->>>---if (car=='!'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.21"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//22
>>>--->>>---if (car=='\n'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.22"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//23
>>>--->>>---if (car==' '){
>>>--->>>--->>>---if(nodo.equals("0") ¿? nodo.equals("0.23") ){ nodo="0.23"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---//24
>>>--->>>---if (car=='\t'){
>>>--->>>--->>>---if(nodo.equals("0")){ nodo="0.24"; }else{ nodo = nodoT + ".0"; }
>>>--->>>---}
>>>--->>>---return nodo;
>>>---}
>>>---
>>>---
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion isIdentifier: Devuelve verdadero si es una palabra reservada
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>>>---public static boolean isIdentifier (String word){
>>>--->>>---if ((word.equals("IF"))¿?
>>>--->>>--->>>---(word.equals("THEN"))¿?
>>>--->>>--->>>---(word.equals("WHILE"))¿?
>>>--->>>--->>>---(word.equals("DO"))¿?
>>>--->>>--->>>---(word.equals("PROCEDURE"))¿?
>>>--->>>--->>>---(word.equals("BEGIN"))¿?
>>>--->>>--->>>---(word.equals("END"))¿?
>>>--->>>--->>>---(word.equals("CONST"))¿?
>>>--->>>--->>>---(word.equals("VAR"))¿?
>>>--->>>--->>>---(word.equals("NUM"))¿?
>>>--->>>--->>>---(word.equals("AIF")))
>>>--->>>---{
>>>--->>>--->>>---return (true);
>>>--->>>---}else{
>>>--->>>--->>>---return (false);
>>>--->>>---}
>>>---}


///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion carTipo: Devuelve 0 si es una letra, 1 si es un numero...
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>>>---public static int carTipo(char c){
>>>--->>>---Character car = new Character (c);
>>>--->>>---car.toUpperCase(c);
>>>--->>>---if (
>>>--->>>--->>>---(car=='A') ¿? (car=='B') ¿? (car=='C') ¿? (car=='D') ¿? (car=='E') ¿?
>>>--->>>--->>>---(car=='F') ¿? (car=='G') ¿? (car=='H') ¿? (car=='I') ¿? (car=='J') ¿?
>>>--->>>--->>>---(car=='K') ¿? (car=='L') ¿? (car=='M') ¿? (car=='N') ¿?
>>>--->>>--->>>---(car=='O') ¿? (car=='P') ¿? (car=='Q') ¿? (car=='R') ¿? (car=='S') ¿?
>>>--->>>--->>>---(car=='T') ¿? (car=='U') ¿? (car=='V') ¿? (car=='W') ¿? (car=='X') ¿?
>>>--->>>--->>>---(car=='Y') ¿? (car=='Z')
>>>--->>>---){
>>>--->>>--->>>---return 0;
>>>--->>>---}else if(
>>>--->>>--->>>---(car=='0') ¿? (car=='1') ¿? (car=='2') ¿? (car=='3') ¿? (car=='4') ¿?
>>>--->>>--->>>---(car=='5') ¿? (car=='6') ¿? (car=='7') ¿? (car=='8') ¿? (car=='9')
>>>--->>>---){
>>>--->>>--->>>---return 1;
>>>--->>>---}else if(
>>>--->>>--->>>---(car=='.') ¿? (car==',') ¿? (car==';') ¿? (car==':') ¿? (car=='(') ¿?
>>>--->>>--->>>---(car==')') ¿? (car=='+') ¿? (car=='-') ¿? (car=='*') ¿? (car=='/') ¿?
>>>--->>>--->>>---(car=='%') ¿? (car=='<') ¿? (car=='>') ¿? (car=='#') ¿? (car=='\\') ¿?
>>>--->>>--->>>---(car=='=') ¿? (car=='&') ¿? (car=='?') ¿? (car=='!') ¿? (car=='\n') ¿?
>>>--->>>--->>>---(car=='\t') ¿? (car==' ')
>>>--->>>---){
>>>--->>>--->>>---return 2;
>>>--->>>---}else {
>>>--->>>--->>>---return -1;
>>>--->>>---}
>>>---}
}



Aplicando mis nuevos conocimientos, les puedo presentar el código tal y como debería de verse. Aun no lo he compilado, pero estoy seguro de que funcionará.

/* 
* AnalizadorLex.java
* Autor: craneodelrey@msn.com
* Este programa lee un archivo de texto y calcula las parejas ordenadas <[Token],[Lexema]>
* por medio de un Autómata Finito Determinista
* Lee línea por línea devolviendo un arreglo con los tokens para su manipulación
*/

import java.io.*;
import java.awt.*;
import java.util.*;
public class AnalizadorLex{
        public static String arrayTokens [][];
        public static int numCar = 0;
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Modulo principal
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        public static void main(String[] args)throws IOException{
                if(args.length == 0){
                        System.out.println("No se especifican ficheros");
                }
/*
                for(int i = 0; i<args.length; i++){
                        contenidoFichero(args[i]);
                }
*/
                contenidoFichero("Test.plo");
        }


///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Modulo Secundario que lee los Ficheros
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        public static void contenidoFichero(String nombreFichero){
                FileReader elFichero;
                BufferedReader lector = null;
                String linea;
                try{
                        elFichero = new FileReader(nombreFichero);
                        lector = new BufferedReader(elFichero);
                        while((linea = lector.readLine()) != null){
                                numCar = linea.length();
                                ///Por cada linea se devueve un arreglo de N filas y dos columnas con los tokens enontrados
                                arrayTokens = separarTokens(linea);
                                for (int I = 0; I<arrayTokens.length; I++){
                                        System.out.println(arrayTokens[I][0] + "        " + arrayTokens[I][1]);
                                }
                                System.out.println("");
                        }
                }catch(Exception e){
                        System.out.println(e);
                }        
                //Cierre del fichero
                try{
                        if (lector != null){
                                lector.close();
                        }
                }catch(IOException e){
                }
        }


///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion separarTokens: Devuelve un arreglo de Tokens
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        static String [][] separarTokens(String row){
                int N = row.length(); //longitud de la cadena
                int i = 0;                         //numero de caracter
                String nodo = "0";         //estado del automata actual
                String word = "";         //palabra o token que se esta formando
                char car = ' ';                 //caracter que sera analizado por el automata
                int numTokens = 0;
                int nT = numTokens;
                //como en java los "Strings" son objetos, necesite de un arreglo temporal para modificar
                //el tamaño del "Array de Strings" original
                String Tokens [][] = new String [numTokens+1][2];
                String TokensT[][] = new String [numTokens+1][2];
                while (i<=N){
                        if (i==N){
                                //Se supone que estamos un indice despues del final de la linea por lo que
                                //solo se añade el estado final de automata y que la linea nunca estara vacia
                                //lo cual es controlado por el modulo en donde se leen los archivos
                                nodo = nodo + ".0";
                                i++;
                        }else{
                                car = Character.toUpperCase(row.charAt(i));
                                nodo = nodoSiguiente(nodo, car);
                                
                        }
/**
La siguente parte es para preparar el Arreglo de Strings y añadir un token cuando se haya encontrado
No es de gran importancia. Si se omitiera y se escribiera directamente en el archivo que se desea crear
aumentaria considerablemente la velocidad de ejecucion del programa...
Por motivos pesonales decidi que la funcion devolviera un Arreglo con los tokens
He tratado lo mas posible de que la forma de programacion sea lo mas parecido a los dos lenguajes que mas
practico C++ y Visual Basic para que otros puedan implantarlo en dichos lenguajes

Diria que este es mi primer programa serio en Java pues veran que desconosco algunos metodos para manejar
correctamente los Strings
*/
                        if (numTokens !=nT){
                                ///Copio el arreglo original al arreglo temporal para incrementar en numero de filas
                                for (int I=0; I<numTokens; I++){
                                        TokensT[I][0] = (new String(Tokens[I][0]));
                                        TokensT[I][1] = (new String(Tokens[I][1]));
                                }
                                ///Se supone que antes ya se añadio un token por lo que se nesecita de una nueva linea
                                Tokens = new String [numTokens+1][2];
                                nT = numTokens;
                                ///Copio el arreglo temporal al nuevo arreglo original
                                for (int I=0; I<numTokens; I++){
                                        Tokens[I][0] = (new String(TokensT[I][0]));
                                        Tokens[I][1] = (new String(TokensT[I][1]));
                                }
                                TokensT = new String [numTokens+1][2];
                        }
/**
Se iran añadiendo nuevas filas despues de añadir un token y hasta que se haya llegado al final de la
linea, lo cual es controlado por la primera senencia: if (i==N){
*/

/// E S T A D O S F I N A L E S D E L A U T O M A T A
                        //Caracter invalido-----------------------------------------------------
                        if (nodo.equals("0.0.0")){
                                Tokens[numTokens][0] = ("CaracterInvalido");
                                Tokens[numTokens][1] = ("(C)");
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Identificadores-------------------------------------------------------
                        if (nodo.equals("0.1.0")){
                                if (isIdentifier(word)){
                                        Tokens[numTokens][0] = ("PalabraReservada");
                                        Tokens[numTokens][1] = (word);
                                }else{
                                        Tokens[numTokens][0] = ("Identificador");
                                        Tokens[numTokens][1] = (word);
                                }
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Numero Entero---------------------------------------------------------
                        if (nodo.equals("0.2.0")){
                                Tokens[numTokens][0] = ("NumeroEntero");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Numero Real-----------------------------------------------------------
                        if (nodo.equals("0.2.1.0")){
                                Tokens[numTokens][0] = ("NumeroReal");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Numero Real-----------------------------------------------------------
                        if (nodo.equals("0.2.1.1.0")){
                                Tokens[numTokens][0] = ("NumeroReal");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Punto-----------------------------------------------------------------
                        if (nodo.equals("0.3.0")){
                                Tokens[numTokens][0] = ("Punto");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Coma------------------------------------------------------------------
                        if (nodo.equals("0.4.0")){
                                Tokens[numTokens][0] = ("Coma");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Punto y Coma----------------------------------------------------------
                        if (nodo.equals("0.5.0")){
                                Tokens[numTokens][0] = ("PuntoYComa");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Dos puntos------------------------------------------------------------
                        if (nodo.equals("0.6.0")){
                                Tokens[numTokens][0] = ("DosPuntos");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Dos Puntos Igual------------------------------------------------------
                        if (nodo.equals("0.6.1.0")){
                                Tokens[numTokens][0] = ("DosPuntosIgual");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Parentesis Izquierdo--------------------------------------------------
                        if (nodo.equals("0.7.0")){
                                Tokens[numTokens][0] = ("ParentesisIzq");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Parentesis Derecho----------------------------------------------------
                        if (nodo.equals("0.8.0")){
                                Tokens[numTokens][0] = ("ParentesisDer");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Suma------------------------------------------------------------------
                        if (nodo.equals("0.9.0")){
                                Tokens[numTokens][0] = ("Suma");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Resta-----------------------------------------------------------------
                        if (nodo.equals("0.10.0")){
                                Tokens[numTokens][0] = ("Resta");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Multiplicacion--------------------------------------------------------
                        if (nodo.equals("0.11.0")){
                                Tokens[numTokens][0] = ("Multiplicacion");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Division--------------------------------------------------------------
                        if (nodo.equals("0.12.0")){
                                Tokens[numTokens][0] = ("Division");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Div-------------------------------------------------------------------
                        if (nodo.equals("0.13.0")){
                                Tokens[numTokens][0] = ("Div");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Mod-------------------------------------------------------------------
                        if (nodo.equals("0.14.0")){
                                Tokens[numTokens][0] = ("Mod");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Menor-----------------------------------------------------------------
                        if (nodo.equals("0.15.0")){
                                Tokens[numTokens][0] = ("Menor");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Menor o Igual---------------------------------------------------------
                        if (nodo.equals("0.15.1.0")){
                                Tokens[numTokens][0] = ("MenorIgual");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Mayor-----------------------------------------------------------------
                        if (nodo.equals("0.16.0")){
                                Tokens[numTokens][0] = ("Mayor");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Mayor o Igual---------------------------------------------------------
                        if (nodo.equals("0.16.1.0")){
                                Tokens[numTokens][0] = ("MayorIgual");
                                Tokens[numTokens][1] = (word);
                                System.out.println(word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Gato------------------------------------------------------------------
                        if (nodo.equals("0.17.0")){
                                Tokens[numTokens][0] = ("Gato");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Igual-----------------------------------------------------------------
                        if (nodo.equals("0.18.0")){
                                Tokens[numTokens][0] = ("Igual");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //And-------------------------------------------------------------------
                        if (nodo.equals("0.19.0")){
                                Tokens[numTokens][0] = ("And");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Or--------------------------------------------------------------------
                        if (nodo.equals("0.20.0")){
                                Tokens[numTokens][0] = ("Or");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Not-------------------------------------------------------------------
                        if (nodo.equals("0.21.0")){
                                Tokens[numTokens][0] = ("Not");
                                Tokens[numTokens][1] = (word);
                                numTokens += 1;
                                word = "";
                                nodo = "0";
                        }
                        //Nueva Linea-----------------------------------------------------------
                        if (nodo.equals("0.22.0")){
                                word = "";
                                nodo = "0";
                        }
                        //Espacio---------------------------------------------------------------
                        if (nodo.equals("0.23.0")){
                                word = "";
                                nodo = "0";
                        }
                        //Tabulacion------------------------------------------------------------
                        if (nodo.equals("0.24.0")){
                                word = "";
                                nodo = "0";
                        }
                        
                        if ((nodo.equals("0")) && (word.equals(""))){
                        }else{
                                word = word + car;
                                i++;
                        }
                }


/*
                for (int I = 0; I<numTokens; I++){
                        System.out.println(Tokens[I][0] + " " + Tokens[I][1]);
                }
*/

                return Tokens;
        }
        
        
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion nodoSigiente: Devuelve un String para calcular el estado del Automata
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        public static String nodoSiguiente(String nodo, char car){
                //guarda el estado del Automata para poder usarlo en caso de requerirlo
                String nodoT = new String(nodo);
                //----------------------------------------------------------------------
                //Tipo invalido---------------------------------------------------------
                //----------------------------------------------------------------------
                if (carTipo(car)==-1){
                        if (nodo.equals("0")){ nodo="0.0"; }else{ nodo = nodoT + ".0"; }
                }
                //----------------------------------------------------------------------
                //Tipo caracter---------------------------------------------------------
                //----------------------------------------------------------------------
                if (carTipo(car)==0){
                        if (nodo.equals("0")){
                                nodo="0.1";
                        }else if(nodo.equals("0.1")){
                                nodo="0.1";
                        }else{
                                nodo = nodoT + ".0";
                        }
                }
                //----------------------------------------------------------------------
                //Tipo numero-----------------------------------------------------------
                //----------------------------------------------------------------------
                if (carTipo(car)==1){
                        if (nodo.equals("0")){
                                nodo="0.2";
                        }else if(nodo.equals("0.2")){
                                nodo="0.2";
                        }else if(nodo.equals("0.2.1")){
                                nodo="0.2.1.1";
                        }else if(nodo.equals("0.2.1.1")){
                                nodo="0.2.1.1";
                        }else{
                                nodo = nodoT + ".0";
                        }
                }
                //----------------------------------------------------------------------
                //otros Tipos-----------------------------------------------------------
                //----------------------------------------------------------------------
                //03
                if (car=='.'){
                        if(nodo.equals("0")){ nodo="0.3";
                        }else if (nodo.equals("0.2")){ nodo="0.2.1";
                        }else{ nodo = nodoT + ".0";
                        }
                }
                //04
                if (car==','){
                        if (nodo.equals("0")){ nodo="0.4"; }else{ nodo = nodoT + ".0"; }
                }
                //05
                if (car==';'){
                        if (nodo.equals("0")){ nodo="0.5"; }else{ nodo = nodoT + ".0"; }
                }
                //06
                if (car==':'){
                        if(nodo.equals("0")){ nodo="0.6"; }else{ nodo = nodoT + ".0"; }
                }
                //07
                if (car=='('){
                        if(nodo.equals("0")){ nodo="0.7"; }else{ nodo = nodoT + ".0"; }
                }
                //08
                if (car==')'){
                        if(nodo.equals("0")){ nodo="0.8"; }else{ nodo = nodoT + ".0"; }
                }
                //09
                if (car=='+'){
                        if (nodo.equals("0")){ nodo="0.9"; }else{ nodo = nodoT + ".0"; }
                }
                //10
                if (car=='-'){
                        if(nodo.equals("0")){ nodo="0.10"; }else{ nodo = nodoT + ".0"; }
                }
                //11
                if (car=='*'){
                        if(nodo.equals("0")){ nodo="0.11"; }else{ nodo = nodoT + ".0"; }
                }
                //12
                if (car=='/'){
                        if(nodo.equals("0")){ nodo="0.12"; }else{ nodo = nodoT + ".0"; }
                }
                //13
                if (car=='\\'){
                        if(nodo.equals("0")){ nodo="0.13"; }else{ nodo = nodoT + ".0"; }
                }
                //14
                if (car=='%'){
                        if(nodo.equals("0")){ nodo="0.14"; }else{ nodo = nodoT + ".0"; }
                }
                //15
                if (car=='<'){
                        if(nodo.equals("0")){ nodo="0.15"; }else{ nodo = nodoT + ".0"; }
                }
                //16
                if (car=='>'){
                        if(nodo.equals("0")){ nodo="0.16"; }else{ nodo = nodoT + ".0"; }
                }
                //17
                if (car=='#'){
                        if(nodo.equals("0")){ nodo="0.17"; }else{ nodo = nodoT + ".0"; }
                }
                //18
                if (car=='='){
                        if(nodo.equals("0")){ nodo="0.18";
                        }else if (nodo.equals("0.15")){ nodo="0.15.1";
                        }else if (nodo.equals("0.16")){ nodo="0.16.1";
                        }else{ nodo = nodoT + ".0";
                        }
                }
                //19
                if (car=='&'){
                        if(nodo.equals("0")){ nodo="0.19"; }else{ nodo = nodoT + ".0"; }
                }
                //20
                if (car=='|'){
                        if(nodo.equals("0")){ nodo="0.20"; }else{ nodo = nodoT + ".0"; }
                }
                //21
                if (car=='!'){
                        if(nodo.equals("0")){ nodo="0.21"; }else{ nodo = nodoT + ".0"; }
                }
                //22
                if (car=='\n'){
                        if(nodo.equals("0")){ nodo="0.22"; }else{ nodo = nodoT + ".0"; }
                }
                //23
                if (car==' '){
                        if(nodo.equals("0") || nodo.equals("0.23") ){ nodo="0.23"; }else{ nodo = nodoT + ".0"; }
                }
                //24
                if (car=='\t'){
                        if(nodo.equals("0")){ nodo="0.24"; }else{ nodo = nodoT + ".0"; }
                }
                return nodo;
        }
        
        
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion isIdentifier: Devuelve verdadero si es una palabra reservada
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        public static boolean isIdentifier (String word){
                if ((word.equals("IF"))||
                        (word.equals("THEN"))||
                        (word.equals("WHILE"))||
                        (word.equals("DO"))||
                        (word.equals("PROCEDURE"))||
                        (word.equals("BEGIN"))||
                        (word.equals("END"))||
                        (word.equals("CONST"))||
                        (word.equals("VAR"))||
                        (word.equals("NUM"))||
                        (word.equals("AIF")))
                {
                        return (true);
                }else{
                        return (false);
                }
        }


///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
///Funcion carTipo: Devuelve 0 si es una letra, 1 si es un numero...
///XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        public static int carTipo(char c){
                Character car = new Character (c);
                car.toUpperCase(c);
                if (
                        (car=='A') || (car=='B') || (car=='C') || (car=='D') || (car=='E') ||
                        (car=='F') || (car=='G') || (car=='H') || (car=='I') || (car=='J') ||
                        (car=='K') || (car=='L') || (car=='M') || (car=='N') ||
                        (car=='O') || (car=='P') || (car=='Q') || (car=='R') || (car=='S') ||
                        (car=='T') || (car=='U') || (car=='V') || (car=='W') || (car=='X') ||
                        (car=='Y') || (car=='Z')
                ){
                        return 0;
                }else if(
                        (car=='0') || (car=='1') || (car=='2') || (car=='3') || (car=='4') ||
                        (car=='5') || (car=='6') || (car=='7') || (car=='8') || (car=='9')
                ){
                        return 1;
                }else if(
                        (car=='.') || (car==',') || (car==';') || (car==':') || (car=='(') ||
                        (car==')') || (car=='+') || (car=='-') || (car=='*') || (car=='/') ||
                        (car=='%') || (car=='<') || (car=='>') || (car=='#') || (car=='\\') ||
                        (car=='=') || (car=='&') || (car=='|') || (car=='!') || (car=='\n') ||
                        (car=='\t') || (car==' ')
                ){
                        return 2;
                }else {
                        return -1;
                }
        }
}


El programa necesita del archivo “Test.plo”, mismo que de veras crear y situarlo en la misma carpeta donde se genera el archivo “AnalizadorLex.class”

Donwload
From SkyDrive

21 comentarios:

Master David dijo...

Te la rifaste soy principiante de java y revisare tu codigo por que me han pedido algo similar

RAZIEL2099 dijo...

Muy bien espero que te sirva de mucho… y puedas aportar algo más.

Anónimo dijo...

QUE TAL???, muy buen uso del lenguaje java, igual soy principiante intento crear el Test.plo, pero no me lo reconoce, podrias decirme como lo hago??? o darme algun ejemplo???

RAZIEL2099 dijo...

Aquí tienes todo el código + la clase compilada + el archivo Test.plo

http://www.megaupload.com/?d=L7BUWUR0

Solo estará disponible unas semanas a partir de hoy.

Revisalo.

froyl dijo...

Gracias master el codigo fue genial me ha servido bastante.
gracias desde veracruz mexico.

Gustav dijo...

Colombia! amigo gracias por tomarte el trabajo de publicar esto

Sacred dijo...

Genial... no sabes cuanto me has ayudado, muxas gracias.. un saludo desde Perú =)

Sacred dijo...

Muxas pero muxas gracias... no sabes cuanto me has ayudado... !!!! un saludo desde Perú!!!

Anónimo dijo...

Me sale esto:

run-single:
No se especifican ficheros
java.io.FileNotFoundException: Test.plo (El sistema no puede hallar el archivo especificado)

Para eso el archivo "Test.plo" lo he situado en la carpeta donde se genera el archivo "AnalizadorLez.class"


en mi carpeta de proyecto estan:

- practica
- Source Packages
- pratica
- AnalizadorLex.class
- AnalizadorLex.java
- Test.plo

Anónimo dijo...

AQUI TE DEJO UNA IMAGEN para que tengas la idea claro de lo que te digo:

Me sale esto:

run-single:
No se especifican ficheros
java.io.FileNotFoundException: Test.plo (El sistema no puede hallar el archivo especificado)


http://imageshack.us/photo/my-images/543/imagencd.jpg/

http://img543.imageshack.us/img543/111/imagencd.jpg

Anónimo dijo...

OH....muxas gracias pero tengo un problema, abri el archivo .class con el block de notas :(.... y ya no quiere abrir, ya cambie en las opciones de carpeta y le quite la opcion de que se abriera con el block de notas, asi k me volvio a aparecer el icono normal, pero al momento de querer abrirlo dede java me sale pura simbologias, en serio k necesito comprender el codigo...quiero aprender!!!!!!... por favor ayudame!!...

Anónimo dijo...

Pues si ya no te funciona vuelve a bajarlo... esta clase de java la debes ejecutar desde la pantalla negra o alguna forma parecida.

LEINAD dijo...

Disculpen las molestias pero me piden un analizador sintactico para java si alguien lo tiene me podria mandar el codigo a mi correo abdiel_evalizq@hotmail.com si no es mucha la molestia se los agradeceria porfavor!! gracias

Anónimo dijo...

como creaste el archivo .plo! no me aparece nada

Anónimo dijo...

espero que me puedas ayudar con estO!
GRAX

MAVERICKC45 dijo...

Es increible!!

Haces un archivo de texto y le metes códigos o un programa (algo para que lea), luego lo guardas como Test.plo

Ya actualice la descarga

chibi5 dijo...

Como hago el archivo Test.plo y donde lo coloca para que el programa corra,por si acaso uso IDE Netbeans, espero que funcione allí XD

Anónimo dijo...

Muchas gracias de verdad me ayudo, hice tal y como explicas y funciona perfecto!!!!

Anónimo dijo...

Gracias amigos.... si usan netBeans creen el archivo Test.plo en la carpeta Principal donde se guarda el proyecto... si funciona!!!!

Anónimo dijo...

Que debe llevar el archivo Test.plo?
Agradezco su ayuda

Anónimo dijo...

Por favor lee los comentarios! Ya puse un enlace de descarga al final del blog.

El archivo "Test.plo" debe llevar codigo fuente o algoritmos con las palabras reservadas y signos que se mencionan.