Lexer: Migrated ispunct to Lexer::isPunctuation

This commit is contained in:
Paul Beckingham 2015-04-16 23:52:43 -04:00
parent 3cbb2bb20f
commit 39fb45447b
6 changed files with 11 additions and 40 deletions

View file

@ -31,7 +31,6 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <Nibbler.h>
#include <Date.h>
#include <Variant.h>

View file

@ -299,8 +299,14 @@ bool Lexer::isBoundary (int left, int right)
////////////////////////////////////////////////////////////////////////////////
bool Lexer::isPunctuation (int c)
{
return c != '@' &&
ispunct (c);
return isprint (c) &&
c != ' ' &&
c != '@' &&
c != '#' &&
c != '$' &&
c != '_' &&
! isDigit (c) &&
! isAlpha (c);
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -27,7 +27,6 @@
#include <cmake.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <inttypes.h>
#include <Lexer.h>
@ -1037,7 +1036,7 @@ bool Nibbler::getWord (std::string& result)
if (i < _length)
{
while (!Lexer::isDigit (_input[i]) &&
!isPunctuation (_input[i]) &&
!Lexer::isPunctuation (_input[i]) &&
!Lexer::isWhitespace (_input[i]))
{
++i;
@ -1228,21 +1227,6 @@ bool Nibbler::depleted ()
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Override of ispunct, that considers #, $, _ and @ not to be punctuation.
//
// ispunct: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
// Punctuation: ! " % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ ` { | } ~
// delta: # $ @
//
bool Nibbler::isPunctuation (char c)
{
if (c == '@' || c == '#' || c == '$' || c == '_')
return false;
return ispunct (c);
}
////////////////////////////////////////////////////////////////////////////////
std::string Nibbler::dump ()
{

View file

@ -110,7 +110,6 @@ public:
bool depleted ();
static bool isPunctuation (char);
std::string dump ();
private:

View file

@ -32,7 +32,6 @@
#include <vector>
#include <string>
#include <strings.h>
#include <ctype.h>
#include <Context.h>
#include <Lexer.h>
#include <math.h>
@ -479,21 +478,6 @@ bool nontrivial (const std::string& input)
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Override of ispunct, that considers #, $ and @ not to be punctuation.
//
// ispunct: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
// Punctuation: ! " % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ ` { | } ~
// delta: # $ @
//
bool isPunctuation (char c)
{
if (c == '@' || c == '#' || c == '$')
return false;
return ispunct (c);
}
////////////////////////////////////////////////////////////////////////////////
bool compare (
const std::string& left,

View file

@ -50,7 +50,6 @@ const std::string str_replace (std::string&, const std::string&, const std::stri
const std::string str_replace (const std::string&, const std::string&, const std::string&);
const char* optionalBlankLine ();
bool nontrivial (const std::string&);
bool isPunctuation (char);
bool compare (const std::string&, const std::string&, bool sensitive = true);
bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0);
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);