/* fsatoken - Support routines specific to token definitions Copyright (C) 1988, 1998, 2000, 2002, 2004-2005, 2007-2014 Free Software Foundation, Inc. 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 3, 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA */ /* Written June, 1988 by Mike Haertel Modified July, 1988 by Arthur David Olson to assist BMG speedups */ /* 2014: Repackaged by "untangle" script, written by behoffski. */ /* The majority of the fsatoken[ch] module is in fsatoken.h, as it is shared by other modules. This file provides token-specific support functions, such as functions to print tokens (for debugging). Although there is a relationship between some generic constructs such as character classes and the CSET token defined here, the generic items are defined in a separate support library, not in this module. This is because these tokens are very FSA/grep-specific, whereas the generic consructs are potentially widely useable, and may even be amenable to hardware-specific optimisations (such as superscalar opcodes such as: - and/or/set/clear/test-and-set/test-and-clear; and/or - bit counting operations). */ /* Always import environment-specific configuration items first. */ #include #include "fsatoken.h" #include #ifdef DEBUG void fsatoken_prtok (fsatoken_token_t t) { char const *s; if (t < 0) fprintf (stderr, "FSATOKEN_TK_END"); else if (t < FSATOKEN_NOTCHAR) { int ch = t; fprintf (stderr, "%c", ch); } else { switch (t) { case FSATOKEN_TK_EMPTY: s = "FSATOKEN_TK_EMPTY"; break; case FSATOKEN_TK_BACKREF: s = "FSATOKEN_TK_BACKREF"; break; case FSATOKEN_TK_BEGLINE: s = "FSATOKEN_TK_BEGLINE"; break; case FSATOKEN_TK_ENDLINE: s = "FSATOKEN_TK_ENDLINE"; break; case FSATOKEN_TK_BEGWORD: s = "FSATOKEN_TK_BEGWORD"; break; case FSATOKEN_TK_ENDWORD: s = "FSATOKEN_TK_ENDWORD"; break; case FSATOKEN_TK_LIMWORD: s = "FSATOKEN_TK_LIMWORD"; break; case FSATOKEN_TK_NOTLIMWORD: s = "FSATOKEN_TK_NOTLIMWORD"; break; case FSATOKEN_TK_QMARK: s = "FSATOKEN_TK_QMARK"; break; case FSATOKEN_TK_STAR: s = "FSATOKEN_TK_STAR"; break; case FSATOKEN_TK_PLUS: s = "FSATOKEN_TK_PLUS"; break; case FSATOKEN_TK_CAT: s = "FSATOKEN_TK_CAT"; break; case FSATOKEN_TK_OR: s = "FSATOKEN_TK_OR"; break; case FSATOKEN_TK_LPAREN: s = "FSATOKEN_TK_LPAREN"; break; case FSATOKEN_TK_RPAREN: s = "FSATOKEN_TK_RPAREN"; break; case FSATOKEN_TK_ANYCHAR: s = "FSATOKEN_TK_ANYCHAR"; break; case FSATOKEN_TK_MBCSET: s = "FSATOKEN_TK_MBCSET"; break; default: s = "FSATOKEN_TK_CSET"; break; } fprintf (stderr, "%s", s); } } #endif /* DEBUG */ /* vim:set shiftwidth=2: */