/* fsalex - Repackage pattern text as compact, expressive tokens 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. */ #ifndef FSALEX_H #define FSALEX_H 1 /* Always import environment-specific configuration items first. */ #include #include "fsatoken.h" #include "proto-lexparse.h" #include /* Multiple lexer instances can exist in parallel, so define an opaque type to collect together all the context relating to each instance. */ typedef struct fsalex_ctxt_struct fsalex_ctxt_t; /* Generate a new instance of an FSA lexer. */ extern fsalex_ctxt_t * fsalex_new (void); /* Receive the pattern, and reset the lexical analyser state. The interpretation of the chars (octets?) in the pattern (ASCII chars? variable-length UTF-8 sequences? Simplified Chinese? etc.) depends on the locale that was in force when fsalex_syntax () was called. NULs may be present amongst the codes, which is why the length is given explicitly, rather than relying on strlen(3). */ extern void fsalex_pattern (fsalex_ctxt_t *lexer, char const *pattern, size_t const pattern_len); /* Receive syntax directives, and other pattern interpretation instructions such as case folding and end-of-line character. In addition, this function configures various internal structures based on the locale in force. */ extern void fsalex_syntax (fsalex_ctxt_t *lexer, reg_syntax_t bits, int fold, unsigned char eol); /* Define function prototypes for warning and error callbacks. */ typedef void fsalex_warn_callback_fn (const char *); typedef void /* ?? _Noreturn? */ fsalex_error_callback_fn (const char *); /* Receive functions to deal with exceptions detected by the lexer: Warnings and errors. Internally, we add the _Noreturn attribute to the error callback, to help the compiler with code flow analysis. */ extern void fsalex_exception_fns (fsalex_ctxt_t *lexer, fsalex_warn_callback_fn *warningfn, fsalex_error_callback_fn *errorfn); /* Main function to incrementally consume and interpret the pattern text, and return a token describing a single lexical element as a token, perhaps with implied parameters such as character classes for CSET tokens, and {min,max} values for each REPMN token. The user should call this function repeatedly, receiving one token each time, until the lexer detects a fatal error, or returns the END token. */ /* This function must conform to proto_lexparse_lex_fn_t. */ extern fsatoken_token_t fsalex_lex (fsalex_ctxt_t *lexer); /* Define external function to do non-core data exchanges. This function must conform to proto_lexparse_exchange_fn_t. */ extern int fsalex_exchange (fsalex_ctxt_t *lexer, proto_lexparse_opcode_t opcode, void *param); /* Maximum number of characters that can be the case-folded counterparts of a single character, not counting the character itself. This is 1 for towupper, 1 for towlower, and 1 for each entry in LONESOME_LOWER; see fsalex.c. */ enum { FSALEX_CASE_FOLDED_BUFSIZE = 1 + 1 + 19 }; extern int fsalex_case_folded_counterparts (fsalex_ctxt_t *lexer, wchar_t, wchar_t[FSALEX_CASE_FOLDED_BUFSIZE]); #endif /* FSALEX_H */ /* vim:set shiftwidth=2: */