lexicon.cpp.svn-base

来自「一个巴西大学编写的2D仿真组足球机器人程序」· SVN-BASE 代码 · 共 89 行

SVN-BASE
89
字号
/*************************************************************************** *   Copyright (C) 2007 by Orivaldo V. Santana Jr -  orivajr@dcc.ufba.br   * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************//*! \file Lexicon.cpp<pre><b>File:</b>          Lexicon.cpp<b>Project:</b>       Robocup Soccer Simulation Team: MecaTeam<b>Authors:</b>       Orivaldo Santana Jr <orivajr@dcc.ufba.br><b>Created:</b>       10/09/2006<b>Last Revision:</b> $ID$<b>Contents:</b>      Este arquivo cont閙 a defini玢o da classe                Lexicon. Esta classe faz a an醠ise l閤ica do analisador                de regras do sistema baseado em conhecimento do agente.               Ela foi projetada como trabalho da discicplina MAT153 -                Compiladores - ministrada pelo professor Luciano Barreto.<hr size=2><h2><b>Changes</b></h2><b>Date</b>             <b>Author</b>          <b>Comment</b>19/09/2006       Orivaldo Vieira      Documenta玢o</pre>*/#include "Lexicon.h"/*! Construtor, recebe como par鈓etro o nome do arquivo a ser analisado l閤icamente. Ele inicializa os atributos da classe, colocando os indexadores de linha e coluna na posi玢o zero, define verbose para falso e adiciona todos os valores de tokens no map, tokensValues, que associa uma string a cada um desses valores.    \param fileName nome do arquivo as ser analisado.*/Lexicon::Lexicon(char *fileName){   m_charLine = 0;   m_charColumn = 0;   m_tokenType = TOKEN_UNKNOWN;   m_verbose = false;   m_sourceFile.open(fileName);   if (!(m_sourceFile.good()))   {      cout << " ERRO: Nome do aquivo de regras inv醠ido." << endl;      exit(1);   }   tokensValues["if"] = TOKEN_IF;   tokensValues["then"] = TOKEN_THEN;   tokensValues["logic"] = TOKEN_LOGIC;   tokensValues["filter"] = TOKEN_FILTER;   tokensValues["frame"] = TOKEN_FRAME;   tokensValues["message"] = TOKEN_MESSAGE;   tokensValues["to"]= TOKEN_MESSAGE_TO;   tokensValues["from"] = TOKEN_MESSAGE_FROM;   tokensValues["deadline"] = TOKEN_MESSAGE_DEADLINE;   tokensValues["grade"] = TOKEN_MESSAGE_GRADE;   tokensValues["alpha"] = TOKEN_MESSAGE_ALPHA;   tokensValues["round"] = TOKEN_MESSAGE_ROUND;   tokensValues["body"] = TOKEN_MESSAGE_BODY;   tokensValues["("] = TOKEN_OPEN_BRACKETS;            // simbolos   tokensValues[")"] = TOKEN_CLOSE_BRACKETS;   tokensValues["="] = TOKEN_OPERATOR_EQUAL;   tokensValues["!="] = TOKEN_OPERATOR_NOT_EQUAL;   tokensValues["<"] = TOKEN_OPERATOR_LESS;   tokensValues["<="] = TOKEN_OPERATOR_LESS_EQUAL;   tokensValues[">"] = TOKEN_OPERATOR_GREATER;   tokensValues[">="] = TOKEN_OPERATOR_GREATER_EQUAL;}/*! Destrutor, fechar o arquivo aberto no construtor. */Lexicon::~Lexicon(){   m_sourceFile.close();}/*! Este m閠odo chama o extair token at

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?