Commit d36d3f31 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	Introduce utilities for lexical analysis.
	
	* src/misc/lexutils.hh, src/misc/lexutils.cc:
	Pack utilities for lexical analysis in these files.
	* src/misc/Makefile.am: Update accordingly.
	* src/shell/shell.hh, src/shell/shell.cc:
	Use lexutils.
parent a23e921a
2005-01-15 Benot Perrot <benoit@lrde.epita.fr>
Introduce utilities for lexical analysis.
* src/misc/lexutils.hh, src/misc/lexutils.cc:
Pack utilities for lexical analysis in these files.
* src/misc/Makefile.am: Update accordingly.
* src/shell/shell.hh, src/shell/shell.cc:
Use lexutils.
2005-01-15 Benot Perrot <benoit@lrde.epita.fr>
Improve command identifiers recognition.
......
......@@ -9,6 +9,7 @@ libmisc_a_SOURCES = \
counted_ptr.hh \
select_const.hh \
unique_string.hh unique_string.cc \
lexutils.hh lexutils.cc \
readline.hh
check_PROGRAMS = test-unique_string
......
//
// lexutils.hh: utilities for lexical analysis
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// This 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.
//
// It 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
//
#include <sstream>
#include "misc/lexutils.hh"
namespace misc
{
std::istringstream &
skip_blank(std::istringstream &iss)
{
while (isblank(iss.peek()))
iss.get();
return iss;
}
} // namespace misc
//
// lexutils.hh: utilities for lexical analysis
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// This 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.
//
// It 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
//
#ifndef MISC_LEXUTILS_HH
# define MISC_LEXUTILS_HH
# include <cctype>
# include "config.h"
#ifndef HAVE_ISBLANK
inline bool
isblank(int c)
{
return c == ' ' || c == '\t';
}
#endif // !HAVE_ISBLANK
class istringstream;
namespace misc
{
/// Skip blank characters
std::istringstream &
skip_blank(std::istringstream &iss);
} // namespace misc
#endif // !MISC_LEXUTILS_HH
......@@ -19,6 +19,8 @@
#include <iomanip>
#include "modules.hh"
#include "misc/readline.hh"
#include "parse/libparse.hh"
......@@ -26,14 +28,6 @@
#include "shell/shell.hh"
#include "shell/cmd.hh"
#ifndef HAVE_ISBLANK
bool
isblank(int c)
{
return (c == ' ' || c == '\t');
}
#endif // !HAVE_ISBLANK
namespace shell
{
......
......@@ -23,30 +23,19 @@
#ifndef SHELL_SHELL_HH
# define SHELL_SHELL_HH
# include "config.h"
# include <ctype.h>
# include <list>
# include <map>
# include <string>
# include <sstream>
# include <iostream>
# include <algorithm>
# include "common.hh"
# include "modules.hh" // FIXME: check if usefull
# include "misc/has.hh"
# include "misc/lexutils.hh"
# include "task/task_register.hh"
# include "vm/virtual_machine.hh"
# include "shell/cmd.hh"
# ifndef HAVE_ISBLANK
bool isblank(int c);
# endif // !HAVE_ISBLANK
namespace shell
{
......@@ -146,17 +135,10 @@ namespace shell
return true;
}
/// Skip blank characters
void skip_blank(std::istringstream &iss)
{
while (isblank(iss.peek()))
iss.get();
}
/// Get the next word in the command line.
std::string get_next_word(std::istringstream &iss)
{
skip_blank(iss);
misc::skip_blank(iss);
std::string res;
while (!isblank(iss.peek()))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment