/* fsaparse -- Build a structure naming relationships (sequences, alternatives, options and precedence) of 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. */ /* This function receives a stream of tokens from fsalex, and processes them to impose precedence rules and to describe complex pattern elements that are beyond the capability of the simple lexer. In addition to the cases explicit in the syntax (e.g."(ab|c)", variable-length multibyte encodings (UTF-8; codesets including modifiers and/or shift items) also require these enhanced facilities. */ #ifndef FSAPARSE_H #define FSAPARSE_H 1 /* Always import environment-specific configuration items first. */ #include #include "fsatoken.h" #include "proto-lexparse.h" /* Multiple parser instances can exist in parallel, so define an opaque type to collect together all the context relating to each instance. */ typedef struct fsaparse_ctxt_struct fsaparse_ctxt_t; /* Allow configurable parser/lexer combinations by using a plugin interface for lexer invocation. */ typedef fsatoken_token_t fsaparse_lexer_fn_t (void *lexer_context); /* Generate a new instance of an FSA parser. */ extern fsaparse_ctxt_t * fsaparse_new (void); /* Receiver a lexer function, plus lexer instance context pointer, for use by the parser. Although not needed initially, this plug-in architecture may be useful in the future, and it breaks up some of the intricate connections that made the original dfa.c code so daunting. */ extern void fsaparse_lexer (fsaparse_ctxt_t *parser, void *lexer_context, proto_lexparse_lex_fn_t *lex_fn, proto_lexparse_exchange_fn_t *lex_exchange_fn); /* Define function prototypes for warning and error callbacks. */ typedef void fsaparse_warn_callback_fn (const char *); typedef void /* ?? _Noreturn? */ fsaparse_error_callback_fn (const char *); /* Receive functions to deal with exceptions detected by the parser: Warnings and errors. Internally, we add the _Noreturn attribute to the error callback, to help the compiler with code flow analysis. */ extern void fsaparse_exception_fns (fsaparse_ctxt_t *parser, fsaparse_warn_callback_fn *warningfn, fsaparse_error_callback_fn *errorfn); /* Main entry point for the parser. Parser is a pointer to a parser context struct created by fsaparse_new. Before calling this function, the parser instance must be supplied with a lexer (fsaparse_lexer), and also with callback functions to receive warning and error reports (fsaparse_esception_fns). */ extern void fsaparse_parse (fsaparse_ctxt_t *parser); /* After parsing, report a list of tokens describing the pattern. Complex structures such as alternation, backreferences, and locale-induced complexity such as variable-length utf8 sequences are described here by appending operators that apply to the preceding item(s) (postfix notation). */ extern void fsaparse_get_token_list (fsaparse_ctxt_t *parser, size_t *nr_tokens, fsatoken_token_t **token_list); #endif /* FSAPARSE_H */ /* vim:set shiftwidth=2: */