Ybadoo - Soluções em Software Livre
Tutoriais
Compiladores

(Deitel, 2003) Desenvolva um programa na sua linguagem de programação preferida, que realize a análise léxica dos programas desenvolvidos na linguagem de programação SIMPLE.

 

Especificação das classes de tokens:

Symbol.java Token.java Lexeme.java LexicalAnalysis.java Compiler.java

Arquivo Symbol.java

/*************************************************************************
* Copyright (C) 2009/2018 - Cristiano Lehrer (cristiano@ybadoo.com.br) *
* Ybadoo - Solucoes em Software Livre (ybadoo.com.br) *
* *
* Permission is granted to copy, distribute and/or modify this document *
* under the terms of the GNU Free Documentation License, Version 1.3 or *
* any later version published by the Free Software Foundation; with no *
* Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A *
* A copy of the license is included in the section entitled "GNU Free *
* Documentation License". *
* *
* Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic) *
* OpenJDK Version "1.8.0_121" *
* OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode) *
*************************************************************************/
package com.ybadoo.tutoriais.cmp.tutorial11.exercicio01;

/**
* Interface responsavel pelas constantes utilizadas na fase de analise
*/
public interface Symbol
{
/**
* Delimitador de nova linha
*/
public int LF = 10;

/**
* Delimitador de fim de texto
*/
public int ETX = 3;

/**
* Operador de atribuicao (=)
*/
public int ASSIGNMENT = 11;

/**
* Operador aritmetico de adicao (+)
*/
public int ADD = 21;

/**
* Operador aritmetico de subtracao (-)
*/
public int SUBTRACT = 22;

/**
* Operador aritmetico de divisao inteira (/)
*/
public int DIVIDE = 23;

/**
* Operador aritmetico de multiplicacao (*)
*/
public int MULTIPLY = 24;

/**
* Operador relacional igual a (==)
*/
public int EQ = 31;

/**
* Operador relacional diferente de (!=)
*/
public int NE = 32;

/**
* Operador relacional maior que (>)
*/
public int GT = 33;

/**
* Operador relacional menor que (<)
*/
public int LT = 34;

/**
* Operador relacional maior ou igual a (>=)
*/
public int GE = 35;

/**
* Operador relacional menor ou igual a (<=)
*/
public int LE = 36;

/**
* Identificador
*/
public int VARIABLE = 41;

/**
* Constante numerica inteira
*/
public int INTEGER = 51;

/**
* Palavra reservada rem
*/
public int REM = 61;

/**
* Palavra reservada input
*/
public int INPUT = 62;

/**
* Palavra reservada let
*/
public int LET = 63;

/**
* Palavra reservada print
*/
public int PRINT = 64;

/**
* Palavra reservada goto
*/
public int GOTO = 65;

/**
* Palavra reservada if
*/
public int IF = 66;

/**
* Palavra reservada end
*/
public int END = 67;

/**
* Token nao reconhecido
*/
public int ERROR = 99;
}

Arquivo Token.java

/*************************************************************************
* Copyright (C) 2009/2018 - Cristiano Lehrer (cristiano@ybadoo.com.br) *
* Ybadoo - Solucoes em Software Livre (ybadoo.com.br) *
* *
* Permission is granted to copy, distribute and/or modify this document *
* under the terms of the GNU Free Documentation License, Version 1.3 or *
* any later version published by the Free Software Foundation; with no *
* Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A *
* A copy of the license is included in the section entitled "GNU Free *
* Documentation License". *
* *
* Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic) *
* OpenJDK Version "1.8.0_121" *
* OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode) *
*************************************************************************/
package com.ybadoo.tutoriais.cmp.tutorial11.exercicio01;

/**
* Classe responsavel pela representacao de um token
*/
public class Token
{
/**
* Tipo/classe do token
*/
private int type;

/**
* Endereco na tabela de simbolos
*/
private int address;

/**
* Numero da linha no codigo-fonte
*/
private int line;

/**
* Numero da coluna no codigo-fonte
*/
private int column;

/**
* Construtor para inicializar o token - sem tabela de simbolo
*
* @param type tipo/classe do token
* @param line numero da linha no codigo-fonte
* @param column numero da coluna no codigo-fonte
*/
public Token(int type, int line, int column)
{
this(type, -1, line, column);
}

/**
* Construtor para inicializar o token - com tabela de simbolo
*
* @param type tipo/classe do token
* @param address endereco na tabela de simbolos
* @param line numero da linha no codigo-fonte
* @param column numero da coluna no codigo-fonte
*/
public Token(int type, int address, int line, int column)
{
this.type = type;
this.address = address;
this.line = line;
this.column = column;
}

/**
* Retornar o tipo/classe do token
*
* @return tipo/classe do token
*/
public int getType()
{
return type;
}

/**
* Retornar o endereco na tabela de simbolos
*
* @return endereco na tabela de simbolos
*/
public int getAddress()
{
return address;
}

/**
* Retornar o numero da linha no codigo-fonte
*
* @return numero da linha no codigo-fonte
*/
public int getLine()
{
return line;
}

/**
* Retornar o numero da coluna no codigo-fonte
*
* @return numero da coluna no codigo-fonte
*/
public int getColumn()
{
return column;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
if(getAddress() != -1)
{
return "[" + getType() + ", " + getAddress()+ ", ("
+ getLine() + ", " + getColumn() + ")]" ;
}
else
{
return "[" + getType() + ", , ("
+ getLine() + ", " + getColumn() + ")]" ;
}
}
}

Arquivo Lexeme.java

/*************************************************************************
* Copyright (C) 2009/2018 - Cristiano Lehrer (cristiano@ybadoo.com.br) *
* Ybadoo - Solucoes em Software Livre (ybadoo.com.br) *
* *
* Permission is granted to copy, distribute and/or modify this document *
* under the terms of the GNU Free Documentation License, Version 1.3 or *
* any later version published by the Free Software Foundation; with no *
* Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A *
* A copy of the license is included in the section entitled "GNU Free *
* Documentation License". *
* *
* Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic) *
* OpenJDK Version "1.8.0_121" *
* OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode) *
*************************************************************************/
package com.ybadoo.tutoriais.cmp.tutorial11.exercicio01;

/**
* Classe responsavel pela representacao de um lexema
*/
public class Lexeme
{
/**
* Termo lido do codigo-fonte
*/
private StringBuilder term;

/**
* Tipo/classe do lexema
*/
private int type;

/**
* Numero da linha no codigo-fonte
*/
private int line;

/**
* Numero da coluna no codigo-fonte
*/
private int column;

/**
* Construtor para inicializar o lexema
*
* @param character caractere lido do codigo-fonte
* @param type tipo/classe do lexema
* @param line numero da linha no codigo-fonte
* @param column numero da coluna no codigo-fonte
*/
public Lexeme(char character, int type, int line, int column)
{
term = new StringBuilder().append(character);

this.type = type;
this.line = line;
this.column = column;
}

/**
* Adicionar um caractere ao termo lido do codigo-fonte
*
* @param character caractere lido do codigo-fonte
* @param type tipo/classe do lexema
*/
public void append(char character, int type)
{
term.append(character);

this.type = type;
}

/**
* Retornar o termo lido do codigo-fonte
*
* @return termo lido do codigo-fonte
*/
public String getTerm()
{
return term.toString();
}

/**
* Retornar o tipo/classe do lexema
*
* @return tipo/classe do lexema
*/
public int getType()
{
return type;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return "'" + getTerm() + "' (" + line + ", " + column + ")";
}

/**
* Retornar o token correspondente ao lexema - sem tabela de simbolo
*
* @return token correspondente ao lexema - sem tabela de simbolo
*/
public Token toToken()
{
return new Token(type, line, column);
}

/**
* Retornar o token correspondente ao lexema - com tabela de simbolo
*
* @param address endereco na tabela de simbolos
* @return token correspondente ao lexema - com tabela de simbolo
*/
public Token toToken(int address)
{
return new Token(type, address, line, column);
}
}

Arquivo LexicalAnalysis.java

/*************************************************************************
* Copyright (C) 2009/2018 - Cristiano Lehrer (cristiano@ybadoo.com.br) *
* Ybadoo - Solucoes em Software Livre (ybadoo.com.br) *
* *
* Permission is granted to copy, distribute and/or modify this document *
* under the terms of the GNU Free Documentation License, Version 1.3 or *
* any later version published by the Free Software Foundation; with no *
* Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A *
* A copy of the license is included in the section entitled "GNU Free *
* Documentation License". *
* *
* Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic) *
* OpenJDK Version "1.8.0_121" *
* OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode) *
*************************************************************************/
package com.ybadoo.tutoriais.cmp.tutorial11.exercicio01;

import java.io.IOException;
import java.io.Reader;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
* Classe responsavel pela analise lexica da linguagem de programacao
* SIMPLE 15.01
*/
public class LexicalAnalysis
{
/**
* Arquivo com o codigo-fonte
*/
private Reader source;

/**
* Lexema em reconhecimento
*/
private Lexeme lexeme;

/**
* Tokens identificados na analise lexica
*/
private List<Token> tokens;

/**
* Numero da linha no codigo-fonte
*/
private int line;

/**
* Numero da coluna no codigo-fonte
*/
private int column;

/**
* Problemas na analise lexica
*/
private boolean error;

/**
* Tabela de simbolos da analise lexica
*/
private Map<String, Integer> symbolTable;

/**
* Construtor padrao
*/
public LexicalAnalysis()
{
line = 1;

column = 0;

error = false;
}

/**
* Adicionar os identificadores e as constantes numericas a tabela de
* simbolos
*
* @param lexema identificador e/ou constante numerica
* @return posicao do lexema e/ou constante numerica na tabela de
* simbolos
*/
private int addSymbolTable(String lexeme)
{
if(!symbolTable.containsKey(lexeme))
{
symbolTable.put(lexeme, symbolTable.size());
}

return symbolTable.get(lexeme);
}

/**
* Adicionar o lexema a lista de tokens
*/
private void addToken()
{
if(lexeme.getType() != Symbol.ERROR)
{
if((lexeme.getType() == Symbol.INTEGER) ||
(lexeme.getType() == Symbol.VARIABLE))
{
tokens.add(lexeme.toToken(addSymbolTable(lexeme.getTerm())));
}
else
{
tokens.add(lexeme.toToken());
}
}
else
{
System.out.println("Token não reconhecido: " + lexeme);

error = true;
}
}

/**
* Retornar a tabela de simbolos da analise lexica
*
* @return tabela de simbolos da analise lexica
*/
public Map<String, Integer> getSymbolTable()
{
return symbolTable;
}

/**
* Retornar os tokens identificados na analise lexica
*
* @return tokens identificados na analise lexica
*/
public List<Token> getTokens()
{
return tokens;
}

/**
* Retornar o caracter do token para analise
*
* @return caracter do token para analise
*/
private char next()
{
int caracter = 0;

if(source != null)
{
try
{
caracter = source.read();

if(caracter == '\r')
{
caracter = source.read();
}

if(caracter > 0)
{
column = column + 1;

return (char) caracter;
}
else
{
source.close();

source = null;
}
}
catch (IOException exception)
{
exception.printStackTrace();
}
}

return 0;
}

/**
* Realizar a analise lexica do codigo-fonte
*
* @param source arquivo com o codigo-fonte de entrada
* @return sucesso ou nao na analisa lexica
*/
public boolean parser(Reader source)
{
this.source = source;

tokens = new LinkedList<Token>();

symbolTable = new LinkedHashMap<String, Integer>();

while(this.source != null)
{
q0();
}

return error;
}

/**
* Estado inicial do automato finito deterministico
*/
private void q0()
{
char caracter = next();

switch(caracter)
{
case 0 :
q04();
break;
case '\n' :
q03();
break;
case ' ' :
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
case '+' :
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
default :
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q99();
}
}

/**
* Estado responsavel pelo reconhecimento da constante numerica inteira
*/
private void q01()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
lexeme.append(caracter, Symbol.INTEGER);
q01();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q01();
}
}

/**
* Estado responsavel pelo reconhecido do identificador
*/
private void q02()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q02();
}
}

/**
* Estado responsavel pelo reconhecimento do delimitador de nova linha
*/
private void q03()
{
lexeme = new Lexeme('\n', Symbol.LF, line, column);

addToken();

line = line + 1;

column = 0;
}

/**
* Estado responsavel pelo reconhecimento do delimitador de fim de texto
*/
private void q04()
{
lexeme = new Lexeme('\0', Symbol.ETX, line, column);

addToken();
}

/**
* Estado responsavel pelo reconhecido do operador aritmetico de
* adicao (+)
*/
private void q05()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q05();
}
}

/**
* Estado responsavel pelo reconhecido do operador aritmetico de
* subtracao (-)
*/
private void q06()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q06();
}
}

/**
* Estado responsavel pelo reconhecido do operador aritmetico de
* multiplicacao (*)
*/
private void q07()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q07();
}
}

/**
* Estado responsavel pelo reconhecido do operador aritmetico de
* divisao inteira (/)
*/
private void q08()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q08();
}
}

/**
* Estado responsavel pelo reconhecido do operador de atribuicao (=)
*/
private void q09()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
case '=' :
lexeme.append(caracter, Symbol.EQ);
q12();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q09();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* menor que (<)
*/
private void q10()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
case '=' :
lexeme.append(caracter, Symbol.LE);
q13();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q10();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* maior que (>)
*/
private void q11()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
case '=' :
lexeme.append(caracter, Symbol.GE);
q14();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q11();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* igual a (==)
*/
private void q12()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q12();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* maior ou igual a (>=)
*/
private void q13()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q13();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* menor ou igual a (<=)
*/
private void q14()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q14();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* diferente de (!=)
*/
private void q15()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q15();
}
}

/**
* Estado responsavel pelo reconhecido do operador relacional
* diferente de (!=)
*/
private void q16()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '=' :
lexeme.append(caracter, Symbol.NE);
q15();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q16();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada rem
*/
private void q17()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
case 'e' :
lexeme.append(caracter, Symbol.ERROR);
q18();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q17();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada rem
*/
private void q18()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'm' :
lexeme.append(caracter, Symbol.REM);
q34();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q18();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada if
*/
private void q19()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
case 'f' :
lexeme.append(caracter, Symbol.IF);
q39();
break;
case 'n' :
lexeme.append(caracter, Symbol.ERROR);
q20();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q19();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada input
*/
private void q20()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'p' :
lexeme.append(caracter, Symbol.ERROR);
q21();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q20();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada input
*/
private void q21()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'u' :
lexeme.append(caracter, Symbol.ERROR);
q22();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q21();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada input
*/
private void q22()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 't' :
lexeme.append(caracter, Symbol.INPUT);
q35();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q22();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada let
*/
private void q23()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
case 'e' :
lexeme.append(caracter, Symbol.ERROR);
q24();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q23();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada let
*/
private void q24()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 't' :
lexeme.append(caracter, Symbol.LET);
q36();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q24();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada print
*/
private void q25()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
case 'r' :
lexeme.append(caracter, Symbol.ERROR);
q26();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q25();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada print
*/
private void q26()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'i' :
lexeme.append(caracter, Symbol.ERROR);
q27();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q26();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada print
*/
private void q27()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'n' :
lexeme.append(caracter, Symbol.ERROR);
q28();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q27();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada print
*/
private void q28()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 't' :
lexeme.append(caracter, Symbol.PRINT);
q37();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q28();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada goto
*/
private void q29()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
case 'o' :
lexeme.append(caracter, Symbol.ERROR);
q30();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q29();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada goto
*/
private void q30()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 't' :
lexeme.append(caracter, Symbol.ERROR);
q31();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q30();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada goto
*/
private void q31()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'o' :
lexeme.append(caracter, Symbol.GOTO);
q38();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q31();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada end
*/
private void q32()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
case 'n' :
lexeme.append(caracter, Symbol.ERROR);
q33();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q32();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada end
*/
private void q33()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
case 'd' :
lexeme.append(caracter, Symbol.END);
q40();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q33();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada rem
*/
private void q34()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
default :
q34();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada input
*/
private void q35()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q35();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada let
*/
private void q36()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q36();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada print
*/
private void q37()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q37();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada goto
*/
private void q38()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q38();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada if
*/
private void q39()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q39();
}
}

/**
* Estado responsavel pelo reconhecido da palavra reservada end
*/
private void q40()
{
char caracter = next();

switch(caracter)
{
case 0 :
addToken();
q04();
break;
case '\n' :
addToken();
q03();
break;
case ' ' :
addToken();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q40();
}
}

/**
* Estado responsavel pelo reconhecimento do erro
*/
private void q99()
{
char caracter = next();

switch(caracter)
{
case 0 :
q04();
break;
case '\n' :
q03();
break;
case ' ' :
break;
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
addToken();
lexeme = new Lexeme(caracter, Symbol.INTEGER, line, column);
q01();
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'f' :
case 'h' :
case 'j' :
case 'k' :
case 'm' :
case 'n' :
case 'o' :
case 'q' :
case 's' :
case 't' :
case 'u' :
case 'v' :
case 'w' :
case 'x' :
case 'y' :
case 'z' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q02();
break;
case 'r' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q17();
break;
case 'i' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q19();
break;
case 'l' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q23();
break;
case 'p' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q25();
break;
case 'g' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q29();
break;
case 'e' :
addToken();
lexeme = new Lexeme(caracter, Symbol.VARIABLE, line, column);
q32();
break;
case '+' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ADD, line, column);
q05();
break;
case '-' :
addToken();
lexeme = new Lexeme(caracter, Symbol.SUBTRACT, line, column);
q06();
break;
case '*' :
addToken();
lexeme = new Lexeme(caracter, Symbol.MULTIPLY, line, column);
q07();
break;
case '/' :
addToken();
lexeme = new Lexeme(caracter, Symbol.DIVIDE, line, column);
q08();
break;
case '=' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ASSIGNMENT, line, column);
q09();
break;
case '<' :
addToken();
lexeme = new Lexeme(caracter, Symbol.LT, line, column);
q10();
break;
case '>' :
addToken();
lexeme = new Lexeme(caracter, Symbol.GT, line, column);
q11();
break;
case '!' :
addToken();
lexeme = new Lexeme(caracter, Symbol.ERROR, line, column);
q16();
break;
default :
lexeme.append(caracter, Symbol.ERROR);
q99();
}
}
}

Arquivo Compiler.java

/*************************************************************************
* Copyright (C) 2009/2018 - Cristiano Lehrer (cristiano@ybadoo.com.br) *
* Ybadoo - Solucoes em Software Livre (ybadoo.com.br) *
* *
* Permission is granted to copy, distribute and/or modify this document *
* under the terms of the GNU Free Documentation License, Version 1.3 or *
* any later version published by the Free Software Foundation; with no *
* Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A *
* A copy of the license is included in the section entitled "GNU Free *
* Documentation License". *
* *
* Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic) *
* OpenJDK Version "1.8.0_121" *
* OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode) *
*************************************************************************/
package com.ybadoo.tutoriais.cmp.tutorial11.exercicio01;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

/**
* Classe responsavel pelo compilador da linguagem de programacao
* SIMPLE 15.01
*/
public class Compiler
{
/**
* Metodo principal da linguagem de programacao Java
*
* @param args argumentos da linha de comando (nao utilizado)
*/
public static void main(String[] args)
{
if(args.length != 1)
{
System.err.println("Por favor, informe o arquivo a ser compilado!");

return;
}

BufferedReader source = null;

try
{
source = new BufferedReader(new FileReader(new File(args[0])));
}
catch(Exception exception)
{
exception.printStackTrace();
}

System.out.println("Início da análise léxica");

LexicalAnalysis lexical = new LexicalAnalysis();

if(!lexical.parser(source))
{
for(String key: lexical.getSymbolTable().keySet())
{
System.out.println(lexical.getSymbolTable().get(key) + " : " + key);
}

for(Token token: lexical.getTokens())
{
System.out.println(token);
}
}

System.out.println("Fim da análise léxica");
}
}

Deitel, H. M. (2003). Java, como programar. 4ª edição. Porto Alegre: Bookman. 1.386 páginas.