/* Copyright (c) 1990 The Regents of the University of California. */ /* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */ /* Vern Paxson. */
/* The United States Government has rights in this work pursuant */ /* to contract no. DE-AC03-76SF00098 between the United States */ /* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */
/* 1. Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* 2. Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in the */ /* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */ /* may be used to endorse or promote products derived from this software */ /* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */ /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ /* PURPOSE. */
#ifndef FLEXDEF_H #define FLEXDEF_H 1
#ifdef HAVE_CONFIG_H #include <config.h> #endif
/* AIX requires this to be the first thing in the file. */ #if !defined(__GNUC__) && !defined(__lint__) # if HAVE_ALLOCA_H # include <alloca.h> # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif #endif
/* We use gettext. So, when we write strings which should be translated, we mark them with _() */ #ifdef ENABLE_NLS #ifdef HAVE_LOCALE_H #include <locale.h> #endif/* HAVE_LOCALE_H */ #include"gettext.h" #define _(String) gettext (String) #else #define _(STRING) STRING #endif/* ENABLE_NLS */
/* Always be prepared to generate an 8-bit scanner. */ #define CSIZE 256 #defineCharunsignedchar
/* Size of input alphabet - should be size of ASCII set. */ #ifndef DEFAULT_CSIZE #define DEFAULT_CSIZE 128 #endif
#ifndef PROTO #ifdefined(__STDC__) #define PROTO(proto) proto #else #define PROTO(proto) () #endif #endif
/* Returns true if an nfa state has an epsilon out-transition slot *thatcanbeused.Thisdefinitioniscurrentlynotused.
*/ #define FREE_EPSILON(state) \
(transchar[state] == SYM_EPSILON && \
trans2[state] == NO_TRANSITION && \
finalst[state] != state)
/* Returns true if an nfa state has an epsilon out-transition character *andbothslotsarefree
*/ #define SUPER_FREE_EPSILON(state) \
(transchar[state] == SYM_EPSILON && \
trans1[state] == NO_TRANSITION) \
/* Maximum number of NFA states that can comprise a DFA state. It's real *bigbecauseifthere'salotofrules,theinitialstatewillhavea *hugeepsilonclosure.
*/ #define INITIAL_MAX_DFA_SIZE 750 #define MAX_DFA_SIZE_INCREMENT 750
/* A note on the following masks. They are used to mark accepting numbers *asbeingspecial.Assuch,theyimplicitlylimitthenumberofaccepting *numbers(i.e.,rules)becauseiftherearetoomanyrulestherulenumbers *willoverloadthemaskbits.Fortunately,thislimitis\large/(0x2000== *8192)sounlikelytoactuallycauseanyproblems.Acheckismadein *new_rule()toensurethatthislimitisnotreached.
*/
/* Mask to mark a trailing context accepting number. */ #define YY_TRAILING_MASK 0x2000
/* Mask to mark the accepting number of the "head" of a trailing context *rule.
*/ #define YY_TRAILING_HEAD_MASK 0x4000
/* Maximum number of rules, as outlined in the above note. */ #define MAX_RULE (YY_TRAILING_MASK - 1)
/* NIL must be 0. If not, its special meaning when making equivalence classes *(itmarkstherepresentativeofagivene.c.)willbeunidentifiable.
*/ #define NIL 0
#define JAM -1/* to mark a missing DFA transition */ #define NO_TRANSITION NIL #define UNIQUE -1/* marks a symbol as an e.c. representative */ #define INFINITE_REPEAT -1/* for x{5,} constructions */
#define INITIAL_MAX_CCLS 100/* max number of unique character classes */ #define MAX_CCLS_INCREMENT 100
/* Size of table holding members of character classes. */ #define INITIAL_MAX_CCL_TBL_SIZE 500 #define MAX_CCL_TBL_SIZE_INCREMENT 250
#define INITIAL_MAX_RULES 100/* default maximum number of rules */ #define MAX_RULES_INCREMENT 100
#define INITIAL_MNS 2000/* default maximum number of nfa states */ #define MNS_INCREMENT 1000/* amount to bump above by if it's not enough */
#define INITIAL_MAX_DFAS 1000/* default maximum number of dfa states */ #define MAX_DFAS_INCREMENT 1000
#define JAMSTATE -32766/* marks a reference to the state that always jams */
/* Maximum number of NFA states. */ #define MAXIMUM_MNS 31999 #define MAXIMUM_MNS_LONG 1999999999
/* Enough so that if it's subtracted from an NFA state number, the result *isguaranteedtobenegative.
*/ #define MARKER_DIFFERENCE (maximum_mns+2)
/* Maximum number of nxt/chk pairs for non-templates. */ #define INITIAL_MAX_XPAIRS 2000 #define MAX_XPAIRS_INCREMENT 2000
/* Maximum number of nxt/chk pairs needed for templates. */ #define INITIAL_MAX_TEMPLATE_XPAIRS 2500 #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
#define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */
#define INITIAL_MAX_SCS 40/* maximum number of start conditions */ #define MAX_SCS_INCREMENT 40/* amount to bump by if it's not enough */
#define ONE_STACK_SIZE 500/* stack of states with only one out-transition */ #define SAME_TRANS -1/* transition is the same as "default" entry for state */
/* The following percentages are used to tune table compression:
/* The percentage the number of homogeneous out-transitions of a state *mustbeofthenumberoftotalout-transitionsofthestateinorder *thatthestate'stransitiontableisfirstcomparedwithapotential *templateofthemostcommonout-transitioninsteadofwiththefirst *protointheprotoqueue.
*/ #define CHECK_COM_PERCENTAGE 50
/* The percentage the number of differences between a state's transition *tableandtheprotoitwasfirstcomparedwithmustbeofthetotal *numberofout-transitionsofthestateinordertokeepthefirst *protoasagoodmatchandnotsearchanyfurther.
*/ #define FIRST_MATCH_DIFF_PERCENTAGE 10
/* The percentage the number of differences between a state's transition *tableandthemostsimilarprotomustbeofthestate'stotalnumber *ofout-transitionstousetheprotoasanacceptableclosematch.
*/ #define ACCEPTABLE_DIFF_PERCENTAGE 50
/* The percentage the number of homogeneous out-transitions of a state *mustbeofthenumberoftotalout-transitionsofthestateinorder *toconsidermakingatemplatefromthestate.
*/ #define TEMPLATE_SAME_PERCENTAGE 60
/* The percentage the number of differences between a state's transition *tableandthemostsimilarprotomustbeofthestate'stotalnumber *ofout-transitionstocreateanewprotofromthestate.
*/ #define NEW_PROTO_DIFF_PERCENTAGE 20
/* The percentage the total number of out-transitions of a state must be *ofthenumberofequivalenceclassesinordertoconsidertryingto *fitthetransitiontableinto"holes"insidethenxt/chktable.
*/ #define INTERIOR_FIT_PERCENTAGE 15
/* Size of region set aside to cache the complete transition table of *protosontheprotoqueuetoenablequickcomparisons.
*/ #define PROT_SAVE_SIZE 2000
#define MSP 50/* maximum number of saved protos (protos on the proto queue) */
/* Maximum number of out-transitions a state can have that we'll rummage *aroundthroughtheinterioroftheinternalfasttablelookingfora *spotforit.
*/ #define MAX_XTIONS_FULL_INTERIOR_FIT 4
/* Maximum number of rules which will be reported as being associated *withaDFAstate.
*/ #define MAX_ASSOC_RULES 100
/* Number that, if used to subscript an array, has a good chance of producing *anerror;shouldbesmallenoughtofitintoashort.
*/ #define BAD_SUBSCRIPT -32767
/* Absolute value of largest number that can be stored in a short, with a *bitofslopthrowninforgeneralparanoia.
*/ #define MAX_SHORT 32700
/* Variables for stack of states having only one out-transition: *onestate-statenumber *onesym-transitionsymbol *onenext-targetstate *onedef-defaultbaseentry *onesp-stackpointer
*/
/* Different types of states; values are useful as masks, as well, for *routineslikecheck_trailing_context().
*/ #define STATE_NORMAL 0x1 #define STATE_TRAILING_CONTEXT 0x2
/* Global holding current type of state we're making. */
externint current_state_type;
/* Different types of rules. */ #define RULE_NORMAL 0 #define RULE_VARIABLE 1
/* True if the input rules include a rule with both variable-length head *andtrailingcontext,falseotherwise.
*/ externint variable_trailing_context_rules;
/* Reserve enough room in the equivalence class arrays so that we *canusetheCSIZE'thelementtoholdequivalenceclassinformation *fortheNULcharacter.Laterwe'llmovethisinformationinto *the0thelement.
*/ externint numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
/* Meta-equivalence classes are indexed starting at 1, so it's possible *thattheywillrequirepositionsfrom1..CSIZE,i.e.,CSIZE+1 *slotstotal(sincethearraysare0-based).nextecm[]andecgroup[] *don'trequiretheextrapositionsincethey'reindexedfrom1..CSIZE-1.
*/ externint tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
/* Used to communicate between scanner and parser. The type should really *beYYSTYPE,butwecan'teasilygetourhandsonit.
*/ externint yylval;
/* External functions that are cross-referenced among the flex source files. */
/* from file ccl.c */
externvoid ccladd PROTO ((int, int)); /* add a single character to a ccl */ externint cclinit PROTO ((void)); /* make an empty ccl */ externvoid cclnegate PROTO ((int)); /* negate a ccl */ externint ccl_set_diff (int a, int b); /* set difference of two ccls. */ externint ccl_set_union (int a, int b); /* set union of two ccls. */
/* List the members of a set of characters in CCL form. */ externvoid list_character_set PROTO ((FILE *, int[]));
/* from file dfa.c */
/* Check a DFA state for backing up. */ externvoid check_for_backing_up PROTO ((int, int[]));
/* Check to see if NFA state set constitutes "dangerous" trailing context. */ externvoid check_trailing_context PROTO ((int *, int, int *, int));
/* Construct the epsilon closure of a set of ndfa states. */ externint *epsclosure PROTO ((int *, int *, int[], int *, int *));
/* Increase the maximum number of dfas. */ externvoid increase_max_dfas PROTO ((void));
externvoid ntod PROTO ((void)); /* convert a ndfa to a dfa */
/* Converts a set of ndfa states into a dfa state. */ externint snstods PROTO ((int[], int, int[], int, int, int *));
/* from file ecs.c */
/* Convert character classes to set of equivalence classes. */ externvoid ccl2ecl PROTO ((void));
/* Associate equivalence class numbers with class members. */ externint cre8ecs PROTO ((int[], int[], int));
/* Update equivalence classes based on character class transitions. */ externvoid mkeccl PROTO ((Char[], int, int[], int[], int, int));
/* Create equivalence class for single character. */ externvoid mkechar PROTO ((int, int[], int[]));
/* from file gen.c */
externvoid do_indent PROTO ((void)); /* indent to the current level */
/* Generate the code to keep backing-up information. */ externvoid gen_backing_up PROTO ((void));
/* Generate the code to perform the backing up. */ externvoid gen_bu_action PROTO ((void));
/* Generate full speed compressed transition table. */ externvoid genctbl PROTO ((void));
/* Generate the code to find the action number. */ externvoid gen_find_action PROTO ((void));
externvoid genftbl PROTO ((void)); /* generate full transition table */
/* Generate the code to find the next compressed-table state. */ externvoid gen_next_compressed_state PROTO ((char *));
/* Generate the code to find the next match. */ externvoid gen_next_match PROTO ((void));
/* Generate the code to find the next state. */ externvoid gen_next_state PROTO ((int));
/* Generate the code to make a NUL transition. */ externvoid gen_NUL_trans PROTO ((void));
/* Generate the code to find the start state. */ externvoid gen_start_state PROTO ((void));
/* Generate data statements for the transition tables. */ externvoid gentabs PROTO ((void));
/* Write out a formatted string at the current indentation level. */ externvoid indent_put2s PROTO ((constchar *, constchar *));
/* Write out a string + newline at the current indentation level. */ externvoid indent_puts PROTO ((constchar *));
externvoid make_tables PROTO ((void)); /* generate transition tables */
/* from file main.c */
externvoid check_options PROTO ((void)); externvoid flexend PROTO ((int)); externvoid usage PROTO ((void));
/* from file misc.c */
/* Add a #define to the action file. */ externvoid action_define PROTO ((constchar *defname, int value));
/* Add the given text to the stored actions. */ externvoid add_action PROTO ((constchar *new_text));
/* True if a string is all lower case. */ externint all_lower PROTO ((char *));
/* True if a string is all upper case. */ externint all_upper PROTO ((char *));
/* Compare two integers for use by qsort. */ externint intcmp PROTO ((constvoid *, constvoid *));
/* Check a character to make sure it's in the expected range. */ externvoid check_char PROTO ((int c));
/* Replace upper-case letter to lower-case. */ externChar clower PROTO ((int));
/* Returns a dynamically allocated copy of a string. */ externchar *copy_string PROTO ((constchar *));
/* Returns a dynamically allocated copy of a (potentially) unsigned string. */ externChar *copy_unsigned_string PROTO ((Char *));
/* Compare two characters for use by qsort with '\0' sorting last. */ externint cclcmp PROTO ((constvoid *, constvoid *));
/* Finish up a block of data declarations. */ externvoid dataend PROTO ((void));
/* Flush generated data statements. */ externvoid dataflush PROTO ((void));
/* Report an error message and terminate. */ externvoid flexerror PROTO ((constchar *));
/* Report a fatal error message and terminate. */ externvoid flexfatal PROTO ((constchar *));
/* Like lerr, but also exit after displaying message. */ externvoid lerr_fatal PROTO ((constchar *, ...)) #ifdefined(__GNUC__) && __GNUC__ >= 3
__attribute__((__format__(__printf__, 1, 2))) #endif
;
/* Spit out a "#line" statement. */ externvoid line_directive_out PROTO ((FILE *, int));
/* Mark the current position in the action array as the end of the section 1 *userdefs.
*/ externvoid mark_defs1 PROTO ((void));
/* Mark the current position in the action array as the end of the prolog. */ externvoid mark_prolog PROTO ((void));
/* Generate a data statment for a two-dimensional array. */ externvoid mk2data PROTO ((int));
externvoid mkdata PROTO ((int)); /* generate a data statement */
/* Return the integer represented by a string of digits. */ externint myctoi PROTO ((constchar *));
/* Return character corresponding to escape sequence. */ externChar myesc PROTO ((Char[]));
/* Convert an octal digit string to an integer value. */ externint otoi PROTO ((Char[]));
/* Output a (possibly-formatted) string to the generated scanner. */ externvoid out PROTO ((constchar *)); externvoid out_dec PROTO ((constchar *, int)); externvoid out_dec2 PROTO ((constchar *, int, int)); externvoid out_hex PROTO ((constchar *, unsignedint)); externvoid out_str PROTO ((constchar *, constchar *)); externvoid out_str3
PROTO ((constchar *, constchar *, constchar *, constchar *)); externvoid out_str_dec PROTO ((constchar *, constchar *, int)); externvoid outc PROTO ((int)); externvoid outn PROTO ((constchar *)); externvoid out_m4_define (constchar* def, constchar* val);
/* Return a printable version of the given character, which might be *8-bit.
*/ externchar *readable_form PROTO ((int));
/* Write out one section of the skeleton file. */ externvoid skelout PROTO ((void));
/* Output a yy_trans_info structure. */ externvoid transition_struct_out PROTO ((int, int));
/* Only needed when using certain broken versions of bison to build parse.c. */ externvoid *yy_flex_xmalloc PROTO ((int));
/* Set a region of memory to 0. */ externvoid zero_out PROTO ((char *, size_t));
/* from file nfa.c */
/* Add an accepting state to a machine. */ externvoid add_accept PROTO ((int, int));
/* Make a given number of copies of a singleton machine. */ externint copysingl PROTO ((int, int));
/* Debugging routine to write out an nfa. */ externvoid dumpnfa PROTO ((int));
/* Finish up the processing for a rule. */ externvoid finish_rule PROTO ((int, int, int, int, int));
/* Connect two machines together. */ externint link_machines PROTO ((int, int));
/* Mark each "beginning" state in a machine as being a "normal" (i.e., *nottrailingcontextassociated)state.
*/ externvoid mark_beginning_as_normal PROTO ((int));
/* Make a machine that branches to two machines. */ externint mkbranch PROTO ((int, int));
externint mkclos PROTO ((int)); /* convert a machine into a closure */ externint mkopt PROTO ((int)); /* make a machine optional */
/* Make a machine that matches either one of two machines. */ externint mkor PROTO ((int, int));
/* Convert a machine into a positive closure. */ externint mkposcl PROTO ((int));
externint mkrep PROTO ((int, int, int)); /* make a replicated machine */
/* Create a state with a transition on a given symbol. */ externint mkstate PROTO ((int));
externvoid new_rule PROTO ((void)); /* initialize for a new rule */
/* from file parse.y */
/* Build the "<<EOF>>" action for the active start conditions. */ externvoid build_eof_action PROTO ((void));
/* Write out a message formatted with one string, pinpointing its location. */ externvoid format_pinpoint_message PROTO ((constchar *, constchar *));
/* Write out a message, pinpointing its location. */ externvoid pinpoint_message PROTO ((constchar *));
/* Write out a warning, pinpointing it at the given line. */ externvoid line_warning PROTO ((constchar *, int));
/* Write out a message, pinpointing it at the given line. */ externvoid line_pinpoint PROTO ((constchar *, int));
/* Report a formatted syntax error. */ externvoid format_synerr PROTO ((constchar *, constchar *)); externvoid synerr PROTO ((constchar *)); /* report a syntax error */ externvoid format_warn PROTO ((constchar *, constchar *)); externvoid warn PROTO ((constchar *)); /* report a warning */ externvoid yyerror PROTO ((constchar *)); /* report a parse error */ externint yyparse PROTO ((void)); /* the YACC parser */
/* from file scan.l */
/* The Flex-generated scanner for flex. */ externint flexscan PROTO ((void));
/* Open the given file (if NULL, stdin) for scanning. */ externvoid set_input_file PROTO ((char *));
/* Wrapup a file in the lexical analyzer. */ externint yywrap PROTO ((void));
/* from file sym.c */
/* Save the text of a character class. */ externvoid cclinstal PROTO ((Char[], int));
/* Lookup the number associated with character class. */ externint ccllookup PROTO ((Char[]));
externvoid ndinstal PROTO ((constchar *, Char[])); /* install a name definition */ externChar *ndlookup PROTO ((constchar *)); /* lookup a name definition */
/* Increase maximum number of SC's. */ externvoid scextend PROTO ((void)); externvoid scinstal PROTO ((constchar *, int)); /* make a start condition */
/* Lookup the number associated with a start condition. */ externint sclookup PROTO ((constchar *));
/* from file tblcmp.c */
/* Build table entries for dfa state. */ externvoid bldtbl PROTO ((int[], int, int, int, int));
externvoid cmptmps PROTO ((void)); /* compress template table entries */ externvoid expand_nxt_chk PROTO ((void)); /* increase nxt/chk arrays */
/* Finds a space in the table for a state to be placed. */ externint find_table_space PROTO ((int *, int)); externvoid inittbl PROTO ((void)); /* initialize transition tables */
/* Make the default, "jam" table entries. */ externvoid mkdeftbl PROTO ((void));
/* Create table entries for a state (or state fragment) which has *onlyoneout-transition.
*/ externvoid mk1tbl PROTO ((int, int, int, int));
/* Place a state into full speed transition table. */ externvoid place_state PROTO ((int *, int, int));
/* Save states with only one out-transition to be processed later. */ externvoid stack1 PROTO ((int, int, int, int));
/* from file yylex.c */
externint yylex PROTO ((void));
/* A growable array. See buf.c. */ struct Buf { void *elts; /* elements. */ int nelts; /* number of elements. */
size_t elt_size; /* in bytes. */ int nmax; /* max capacity of elements. */
};
externstruct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */ externstruct Buf defs_buf; /* a char* buffer to save #define'd some symbols generated by flex. */ externstruct Buf yydmap_buf; /* a string buffer to hold yydmap elements */ externstruct Buf m4defs_buf; /* Holds m4 definitions. */ externstruct Buf top_buf; /* contains %top code. String buffer. */
/* For blocking out code from the header file. */ #define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[") #define OUT_END_CODE() outn("]])")
/* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */ extern jmp_buf flex_main_jmp_buf;
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.28Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.