15f2eab64SJohn Marino /* 25f2eab64SJohn Marino tre-parse.c - Regexp parser definitions 35f2eab64SJohn Marino 45f2eab64SJohn Marino This software is released under a BSD-style license. 55f2eab64SJohn Marino See the file LICENSE for details and copyright. 65f2eab64SJohn Marino 75f2eab64SJohn Marino */ 85f2eab64SJohn Marino 95f2eab64SJohn Marino #ifndef TRE_PARSE_H 105f2eab64SJohn Marino #define TRE_PARSE_H 1 115f2eab64SJohn Marino 12*d5f8dde1SJohn Marino #include "xlocale_private.h" 13*d5f8dde1SJohn Marino 145f2eab64SJohn Marino /* Parse context. */ 155f2eab64SJohn Marino typedef struct { 165f2eab64SJohn Marino /* Memory allocator. The AST is allocated using this. */ 175f2eab64SJohn Marino tre_mem_t mem; 185f2eab64SJohn Marino /* Stack used for keeping track of regexp syntax. */ 195f2eab64SJohn Marino tre_stack_t *stack; 205f2eab64SJohn Marino /* The parse result. */ 215f2eab64SJohn Marino tre_ast_node_t *result; 225f2eab64SJohn Marino /* The regexp to parse and its length. */ 235f2eab64SJohn Marino const tre_char_t *re; 245f2eab64SJohn Marino /* The first character of the entire regexp. */ 255f2eab64SJohn Marino const tre_char_t *re_start; 265f2eab64SJohn Marino /* The first character after the end of the regexp. */ 275f2eab64SJohn Marino const tre_char_t *re_end; 28*d5f8dde1SJohn Marino /* The current locale */ 29*d5f8dde1SJohn Marino locale_t loc; 305f2eab64SJohn Marino int len; 315f2eab64SJohn Marino /* Current submatch ID. */ 325f2eab64SJohn Marino int submatch_id; 33*d5f8dde1SJohn Marino /* Current invisible submatch ID. */ 34*d5f8dde1SJohn Marino int submatch_id_invisible; 355f2eab64SJohn Marino /* Current position (number of literal). */ 365f2eab64SJohn Marino int position; 375f2eab64SJohn Marino /* The highest back reference or -1 if none seen so far. */ 385f2eab64SJohn Marino int max_backref; 39*d5f8dde1SJohn Marino /* Number of tags that need reordering. */ 40*d5f8dde1SJohn Marino int num_reorder_tags; 415f2eab64SJohn Marino /* This flag is set if the regexp uses approximate matching. */ 425f2eab64SJohn Marino int have_approx; 435f2eab64SJohn Marino /* Compilation flags. */ 445f2eab64SJohn Marino int cflags; 455f2eab64SJohn Marino /* If this flag is set the top-level submatch is not captured. */ 465f2eab64SJohn Marino int nofirstsub; 475f2eab64SJohn Marino /* The currently set approximate matching parameters. */ 485f2eab64SJohn Marino int params[TRE_PARAM_LAST]; 495f2eab64SJohn Marino } tre_parse_ctx_t; 505f2eab64SJohn Marino 515f2eab64SJohn Marino /* Parses a wide character regexp pattern into a syntax tree. This parser 525f2eab64SJohn Marino handles both syntaxes (BRE and ERE), including the TRE extensions. */ 535f2eab64SJohn Marino reg_errcode_t 545f2eab64SJohn Marino tre_parse(tre_parse_ctx_t *ctx); 555f2eab64SJohn Marino 565f2eab64SJohn Marino #endif /* TRE_PARSE_H */ 575f2eab64SJohn Marino 585f2eab64SJohn Marino /* EOF */ 59