diff --git a/Makefile b/Makefile index bc14e259..35495a60 100644 --- a/Makefile +++ b/Makefile @@ -138,8 +138,6 @@ include libc/dns/dns.mk # │ include libc/crypto/crypto.mk # │ include net/http/http.mk #─┘ include third_party/lemon/lemon.mk -include third_party/linenoise/linenoise.mk -include third_party/editline/editline.mk include third_party/duktape/duktape.mk include third_party/regex/regex.mk include third_party/avir/avir.mk @@ -148,10 +146,7 @@ include third_party/third_party.mk include libc/testlib/testlib.mk include tool/viz/lib/vizlib.mk include examples/examples.mk -include third_party/lex/lex.mk -include third_party/m4/m4.mk include third_party/lz4cli/lz4cli.mk -include third_party/bzip2/bzip2.mk include tool/build/lib/buildlib.mk include third_party/chibicc/chibicc.mk include third_party/chibicc/test/test.mk diff --git a/third_party/bzip2/.clang-format b/third_party/bzip2/.clang-format deleted file mode 100644 index ff4feef4..00000000 --- a/third_party/bzip2/.clang-format +++ /dev/null @@ -1,125 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: WebKit -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: All -BreakBeforeBraces: WebKit -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 4 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: Inner -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 4 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 4 -UseTab: Always -... diff --git a/third_party/bzip2/bzip2.mk b/third_party/bzip2/bzip2.mk deleted file mode 100644 index f5a51785..00000000 --- a/third_party/bzip2/bzip2.mk +++ /dev/null @@ -1,33 +0,0 @@ -#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ -#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ -# Description: -# bzip2 is a compression format. - -PKGS += THIRD_PARTY_BZIP2 - -THIRD_PARTY_BZIP2_BINS = \ - o/$(MODE)/third_party/bzip2/µbunzip2.com \ - o/$(MODE)/third_party/bzip2/µbunzip2.com.dbg - -THIRD_PARTY_BZIP2_OBJS = \ - o/$(MODE)/third_party/bzip2/µbunzip2.o - -THIRD_PARTY_BZIP2_DEPS := $(call uniq, \ - $(LIBC_STR) \ - $(LIBC_STDIO)) - -$(THIRD_PARTY_BZIP2_OBJS): \ - DEFAULT_CPPFLAGS += \ - -DHAVE_CONFIG_H - -o/$(MODE)/third_party/bzip2/µbunzip2.com.dbg: \ - $(THIRD_PARTY_BZIP2_DEPS) \ - $(THIRD_PARTY_BZIP2_OBJS) \ - $(CRT) \ - $(APE) - @$(APELINK) - -$(THIRD_PARTY_BZIP2_OBJS): third_party/bzip2/bzip2.mk - -.PHONY: o/$(MODE)/third_party/bzip2 -o/$(MODE)/third_party/bzip2: $(THIRD_PARTY_BZIP2_BINS) diff --git a/third_party/bzip2/µbunzip2.c b/third_party/bzip2/µbunzip2.c deleted file mode 100644 index fea1f5fd..00000000 --- a/third_party/bzip2/µbunzip2.c +++ /dev/null @@ -1,569 +0,0 @@ -/* micro-bunzip, a small, simple bzip2 decompression implementation. - Copyright 2003 by Rob Landley (rob@landley.net). - - Based on bzip2 decompression code by Julian R Seward (jseward@acm.org), - which also acknowledges contributions by Mike Burrows, David Wheeler, - Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten, - Robert Sedgewick, and Jon L. Bentley. - - I hereby release this code under the GNU Library General Public License - (LGPL) version 2, available at http://www.gnu.org/copyleft/lgpl.html -*/ - -#include "libc/calls/calls.h" -#include "libc/mem/mem.h" -#include "libc/runtime/runtime.h" -#include "libc/stdio/stdio.h" -#include "libc/str/str.h" -#include "libc/sysv/consts/fileno.h" - -/* Constants for huffman coding */ -#define MAX_GROUPS 6 -#define GROUP_SIZE 50 /* 64 would have been more efficient */ -#define MAX_HUFCODE_BITS 20 /* Longest huffman code allowed */ -#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */ -#define SYMBOL_RUNA 0 -#define SYMBOL_RUNB 1 - -/* Status return values */ -#define RETVAL_OK 0 -#define RETVAL_LAST_BLOCK (-1) -#define RETVAL_NOT_BZIP_DATA (-2) -#define RETVAL_UNEXPECTED_INPUT_EOF (-3) -#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4) -#define RETVAL_DATA_ERROR (-5) -#define RETVAL_OUT_OF_MEMORY (-6) -#define RETVAL_OBSOLETE_INPUT (-7) - -/* Other housekeeping constants */ -#define IOBUF_SIZE 4096 - -char *bunzip_errors[] = { NULL, "Bad file checksum", "Not bzip data", - "Unexpected input EOF", "Unexpected output EOF", "Data error", - "Out of memory", "Obsolete (pre 0.9.5) bzip format not supported." }; - -/* This is what we know about each huffman coding group */ -struct group_data { - int limit[MAX_HUFCODE_BITS], base[MAX_HUFCODE_BITS], permute[MAX_SYMBOLS]; - char minLen, maxLen; -}; - -/* Structure holding all the housekeeping data, including IO buffers and - memory that persists between calls to bunzip */ -typedef struct { - /* For I/O error handling */ - jmp_buf jmpbuf; - /* Input stream, input buffer, input bit buffer */ - int64_t in_fd, inbufCount, inbufPos; - unsigned char *inbuf; - unsigned int inbufBitCount, inbufBits; - /* Output buffer */ - char outbuf[IOBUF_SIZE]; - int outbufPos; - /* The CRC values stored in the block header and calculated from the data */ - unsigned int crc32Table[256], headerCRC, dataCRC, totalCRC; - /* Intermediate buffer and its size (in bytes) */ - unsigned int *dbuf, dbufSize; - /* State for interrupting output loop */ - int writePos, writeRun, writeCount, writeCurrent; - - /* These things are a bit too big to go on the stack */ - unsigned char selectors[32768]; /* nSelectors=15 bits */ - struct group_data groups[MAX_GROUPS]; /* huffman coding tables */ -} bunzip_data; - -/* Return the next nnn bits of input. All reads from the compressed - input are done through this function. All reads are big endian */ -static unsigned int get_bits(bunzip_data *bd, char bits_wanted) -{ - unsigned int bits = 0; - - /* If we need to get more data from the byte buffer, do so. (Loop - getting one byte at a time to enforce endianness and avoid - unaligned access.) */ - while (bd->inbufBitCount < bits_wanted) { - /* If we need to read more data from file into byte buffer, do so */ - if (bd->inbufPos == bd->inbufCount) { - if (!(bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE))) - longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_INPUT_EOF); - bd->inbufPos = 0; - } - /* Avoid 32-bit overflow (dump bit buffer to top of output) */ - if (bd->inbufBitCount >= 24) { - bits = bd->inbufBits & ((1u << bd->inbufBitCount) - 1); - bits_wanted -= bd->inbufBitCount; - bits <<= bits_wanted; - bd->inbufBitCount = 0; - } - /* Grab next 8 bits of input from buffer. */ - bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++]; - bd->inbufBitCount += 8; - } - /* Calculate result */ - bd->inbufBitCount -= bits_wanted; - bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1u << bits_wanted) - 1); - - return bits; -} - -/* Decompress a block of text to into intermediate buffer */ - -static int read_bunzip_data(bunzip_data *bd) -{ - struct group_data *hufGroup; - int dbufCount, nextSym, dbufSize, origPtr, groupCount, *base, *limit, - selector, i, j, k, t, runPos, symCount, symTotal, nSelectors, - byteCount[256]; - unsigned char uc, symToByte[256], mtfSymbol[256], *selectors; - unsigned int *dbuf; - - /* Read in header signature (borrowing mtfSymbol for temp space). */ - for (i = 0; i < 6; i++) - mtfSymbol[i] = get_bits(bd, 8); - mtfSymbol[6] = 0; - /* Read CRC (which is stored big endian). */ - bd->headerCRC = get_bits(bd, 32); - /* Is this the last block (with CRC for file)? */ - if (!strcmp((char *)mtfSymbol, "\x17\x72\x45\x38\x50\x90")) - return RETVAL_LAST_BLOCK; - /* If it's not a valid data block, barf. */ - if (strcmp((char *)mtfSymbol, "\x31\x41\x59\x26\x53\x59")) - return RETVAL_NOT_BZIP_DATA; - - dbuf = bd->dbuf; - dbufSize = bd->dbufSize; - selectors = bd->selectors; - /* We can add support for blockRandomised if anybody complains. - There was some code for this in busybox 1.0.0-pre3, but nobody - ever noticed that it didn't actually work. */ - if (get_bits(bd, 1)) - return RETVAL_OBSOLETE_INPUT; - if ((origPtr = get_bits(bd, 24)) > dbufSize) - return RETVAL_DATA_ERROR; - /* mapping table: if some byte values are never used (encoding - things like ascii text), the compression code removes the gaps to - have fewer symbols to deal with, and writes a sparse bitfield - indicating which values were present. We make a translation table - to convert the symbols back to the corresponding bytes. */ - t = get_bits(bd, 16); - memset(symToByte, 0, 256); - symTotal = 0; - for (i = 0; i < 16; i++) { - if (t & (1u << (15 - i))) { - k = get_bits(bd, 16); - for (j = 0; j < 16; j++) - if (k & (1u << (15 - j))) - symToByte[symTotal++] = (16 * i) + j; - } - } - /* How many different huffman coding groups does this block use? */ - groupCount = get_bits(bd, 3); - if (groupCount < 2 || groupCount > MAX_GROUPS) - return RETVAL_DATA_ERROR; - /* nSelectors: Every GROUP_SIZE many symbols we select a new huffman - coding group. Read in the group selector list, which is stored as - MTF encoded bit runs. */ - if (!(nSelectors = get_bits(bd, 15))) - return RETVAL_DATA_ERROR; - for (i = 0; i < groupCount; i++) - mtfSymbol[i] = i; - for (i = 0; i < nSelectors; i++) { - /* Get next value */ - for (j = 0; get_bits(bd, 1); j++) - if (j >= groupCount) - return RETVAL_DATA_ERROR; - /* Decode MTF to get the next selector */ - uc = mtfSymbol[j]; - memmove(mtfSymbol + 1, mtfSymbol, j); - mtfSymbol[0] = selectors[i] = uc; - } - /* Read the huffman coding tables for each group, which code for symTotal - literal symbols, plus two run symbols (RUNA, RUNB) */ - symCount = symTotal + 2; - for (j = 0; j < groupCount; j++) { - unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS + 1]; - int minLen, maxLen, pp; - /* Read lengths */ - t = get_bits(bd, 5); - for (i = 0; i < symCount; i++) { - for (;;) { - if (t < 1 || t > MAX_HUFCODE_BITS) - return RETVAL_DATA_ERROR; - if (!get_bits(bd, 1)) - break; - if (!get_bits(bd, 1)) - t++; - else - t--; - } - length[i] = t; - } - /* Find largest and smallest lengths in this group */ - minLen = maxLen = length[0]; - for (i = 1; i < symCount; i++) { - if (length[i] > maxLen) - maxLen = length[i]; - else if (length[i] < minLen) - minLen = length[i]; - } - /* Calculate permute[], base[], and limit[] tables from length[]. - * - * permute[] is the lookup table for converting huffman coded symbols - * into decoded symbols. base[] is the amount to subtract from the - * value of a huffman symbol of a given length when using permute[]. - * - * limit[] indicates the largest numerical value a symbol with a given - * number of bits can have. It lets us know when to stop reading. - * - * To use these, keep reading bits until value<=limit[bitcount] or - * you've read over 20 bits (error). Then the decoded symbol - * equals permute[hufcode_value-base[hufcode_bitcount]]. - */ - hufGroup = bd->groups + j; - hufGroup->minLen = minLen; - hufGroup->maxLen = maxLen; - /* Note that minLen can't be smaller than 1, so we adjust the - base and limit array pointers so we're not always wasting the - first entry. We do this again when using them (during symbol - decoding).*/ - base = hufGroup->base - 1; - limit = hufGroup->limit - 1; - /* Calculate permute[] */ - pp = 0; - for (i = minLen; i <= maxLen; i++) - for (t = 0; t < symCount; t++) - if (length[t] == i) - hufGroup->permute[pp++] = t; - /* Count cumulative symbols coded for at each bit length */ - for (i = minLen; i <= maxLen; i++) - temp[i] = limit[i] = 0; - for (i = 0; i < symCount; i++) - temp[length[i]]++; - /* Calculate limit[] (the largest symbol-coding value at each - bit length, which is (previous limit<<1)+symbols at this - level), and base[] (number of symbols to ignore at each bit - length, which is limit-cumulative count of symbols coded for - already). */ - pp = t = 0; - for (i = minLen; i < maxLen; i++) { - pp += temp[i]; - limit[i] = pp - 1; - pp <<= 1; - base[i + 1] = pp - (t += temp[i]); - } - limit[maxLen] = pp + temp[maxLen] - 1; - base[minLen] = 0; - } - /* We've finished reading and digesting the block header. Now read this - block's huffman coded symbols from the file and undo the huffman - coding and run length encoding, saving the result into - dbuf[dbufCount++]=uc */ - - /* Initialize symbol occurrence counters and symbol mtf table */ - memset(byteCount, 0, 256 * sizeof(int)); - for (i = 0; i < 256; i++) - mtfSymbol[i] = (unsigned char)i; - /* Loop through compressed symbols */ - runPos = dbufCount = symCount = selector = 0; - for (;;) { - /* Determine which huffman coding group to use. */ - if (!(symCount--)) { - symCount = GROUP_SIZE - 1; - if (selector >= nSelectors) - return RETVAL_DATA_ERROR; - hufGroup = bd->groups + selectors[selector++]; - base = hufGroup->base - 1; - limit = hufGroup->limit - 1; - } - /* Read next huffman-coded symbol */ - i = hufGroup->minLen; - j = get_bits(bd, i); - for (;;) { - if (i > hufGroup->maxLen) - return RETVAL_DATA_ERROR; - if (j <= limit[i]) - break; - i++; - - j = (j << 1) | get_bits(bd, 1); - } - /* Huffman decode nextSym (with bounds checking) */ - j -= base[i]; - if (j < 0 || j >= MAX_SYMBOLS) - return RETVAL_DATA_ERROR; - nextSym = hufGroup->permute[j]; - /* If this is a repeated run, loop collecting data */ - if (nextSym == SYMBOL_RUNA || nextSym == SYMBOL_RUNB) { - /* If this is the start of a new run, zero out counter */ - if (!runPos) { - runPos = 1; - t = 0; - } - /* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 - at each bit position, add 1 or 2 instead. For example, - 1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2. - You can make any bit pattern that way using 1 less symbol - than the basic or 0/1 method (except all bits 0, which - would use no symbols, but a run of length 0 doesn't mean - anything in this context). Thus space is saved. */ - if (nextSym == SYMBOL_RUNA) - t += runPos; - else - t += 2 * runPos; - runPos <<= 1; - continue; - } - /* When we hit the first non-run symbol after a run, we now know - how many times to repeat the last literal, so append that - many copies to our buffer of decoded symbols (dbuf) now. (The - last literal used is the one at the head of the mtfSymbol - array.) */ - if (runPos) { - runPos = 0; - if (dbufCount + t >= dbufSize) - return RETVAL_DATA_ERROR; - - uc = symToByte[mtfSymbol[0]]; - byteCount[uc] += t; - while (t--) - dbuf[dbufCount++] = uc; - } - /* Is this the terminating symbol? */ - if (nextSym > symTotal) - break; - /* At this point, the symbol we just decoded indicates a new - literal character. Subtract one to get the position in the - MTF array at which this literal is currently to be found. - (Note that the result can't be -1 or 0, because 0 and 1 are - RUNA and RUNB. Another instance of the first symbol in the - mtf array, position 0, would have been handled as part of a - run.) */ - if (dbufCount >= dbufSize) - return RETVAL_DATA_ERROR; - i = nextSym - 1; - uc = mtfSymbol[i]; - memmove(mtfSymbol + 1, mtfSymbol, i); - mtfSymbol[0] = uc; - uc = symToByte[uc]; - /* We have our literal byte. Save it into dbuf. */ - byteCount[uc]++; - dbuf[dbufCount++] = (unsigned int)uc; - } - /* At this point, we've finished reading huffman-coded symbols and - compressed runs from the input stream. There are dbufCount many - of them in dbuf[]. Now undo the Burrows-Wheeler transform on - dbuf. See http://dogma.net/markn/articles/bwt/bwt.htm */ - - /* Now we know what dbufCount is, do a better sanity check on origPtr. */ - if (origPtr < 0 || origPtr >= dbufCount) - return RETVAL_DATA_ERROR; - /* Turn byteCount into cumulative occurrence counts of 0 to n-1. */ - j = 0; - for (i = 0; i < 256; i++) { - k = j + byteCount[i]; - byteCount[i] = j; - j = k; - } - /* Figure out what order dbuf would be in if we sorted it. */ - for (i = 0; i < dbufCount; i++) { - uc = (unsigned char)(dbuf[i] & 0xff); - dbuf[byteCount[uc]] |= (i << 8); - byteCount[uc]++; - } - /* blockRandomised support would go here. */ - - /* Using i as position, j as previous character, t as current character, - and uc as run count */ - bd->dataCRC = 0xffffffffL; - /* Decode first byte by hand to initialize "previous" byte. Note - that it doesn't get output, and if the first three characters are - identical it doesn't qualify as a run (hence uc=255, which will - either wrap to 1 or get reset). */ - if (dbufCount) { - bd->writePos = dbuf[origPtr]; - bd->writeCurrent = (unsigned char)(bd->writePos & 0xff); - bd->writePos >>= 8; - bd->writeRun = -1; - } - bd->writeCount = dbufCount; - - return RETVAL_OK; -} - -/* Flush output buffer to disk */ -static void flush_bunzip_outbuf(bunzip_data *bd, int64_t out_fd) -{ - if (bd->outbufPos) { - if (write(out_fd, bd->outbuf, bd->outbufPos) != bd->outbufPos) - longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_OUTPUT_EOF); - bd->outbufPos = 0; - } -} - -/* Undo burrows-wheeler transform on intermediate buffer to produce output. - If !len, write up to len bytes of data to buf. Otherwise write to out_fd. - Returns len ? bytes written : RETVAL_OK. Notice all errors negative #'s. */ -static int write_bunzip_data( - bunzip_data *bd, int64_t out_fd, char *outbuf, int len) -{ - unsigned int *dbuf = bd->dbuf; - int count, pos, current, run, copies, outbyte, previous, gotcount = 0; - - for (;;) { - /* If last read was short due to end of file, return last block now */ - if (bd->writeCount < 0) - return bd->writeCount; - /* If we need to refill dbuf, do it. */ - if (!bd->writeCount) { - int i = read_bunzip_data(bd); - if (i) { - if (i == RETVAL_LAST_BLOCK) { - bd->writeCount = i; - return gotcount; - } else - return i; - } - } - /* Loop generating output */ - count = bd->writeCount; - pos = bd->writePos; - current = bd->writeCurrent; - run = bd->writeRun; - while (count) { - /* If somebody (like busybox tar) wants a certain number of - bytes of data from memory instead of written to a file, - humor them */ - if (len && bd->outbufPos >= len) - goto dataus_interruptus; - count--; - /* Follow sequence vector to undo Burrows-Wheeler transform */ - previous = current; - pos = dbuf[pos]; - current = pos & 0xff; - pos >>= 8; - /* Whenever we see 3 consecutive copies of the same byte, - the 4th is a repeat count */ - if (run++ == 3) { - copies = current; - outbyte = previous; - current = -1; - } else { - copies = 1; - outbyte = current; - } - /* Output bytes to buffer, flushing to file if necessary */ - while (copies--) { - if (bd->outbufPos == IOBUF_SIZE) - flush_bunzip_outbuf(bd, out_fd); - bd->outbuf[bd->outbufPos++] = outbyte; - bd->dataCRC = (bd->dataCRC << 8) - ^ bd->crc32Table[(bd->dataCRC >> 24) ^ outbyte]; - } - if (current != previous) - run = 0; - } - /* Decompression of this block completed successfully */ - bd->dataCRC = ~(bd->dataCRC); - bd->totalCRC - = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->dataCRC; - /* If this block had a CRC error, force file level CRC error. */ - if (bd->dataCRC != bd->headerCRC) { - bd->totalCRC = bd->headerCRC + 1; - return RETVAL_LAST_BLOCK; - } - dataus_interruptus: - bd->writeCount = count; - if (len) { - gotcount += bd->outbufPos; - memcpy(outbuf, bd->outbuf, len); - /* If we got enough data, checkpoint loop state and return */ - if ((len -= bd->outbufPos) < 1) { - bd->outbufPos -= len; - if (bd->outbufPos) - memmove(bd->outbuf, bd->outbuf + len, bd->outbufPos); - bd->writePos = pos; - bd->writeCurrent = current; - bd->writeRun = run; - return gotcount; - } - } - } -} - -/* Allocate the structure, read file header. If !len, src_fd contains - filehandle to read from. Else inbuf contains data. */ -static int start_bunzip(bunzip_data **bdp, int64_t src_fd, char *inbuf, int len) -{ - bunzip_data *bd; - unsigned int i, j, c; - - /* Figure out how much data to allocate */ - i = sizeof(bunzip_data); - if (!len) - i += IOBUF_SIZE; - /* Allocate bunzip_data. Most fields initialize to zero. */ - if (!(bd = *bdp = malloc(i))) - return RETVAL_OUT_OF_MEMORY; - memset(bd, 0, sizeof(bunzip_data)); - if (len) { - bd->inbuf = (unsigned char *)inbuf; - bd->inbufCount = len; - bd->in_fd = -1; - } else { - bd->inbuf = (unsigned char *)(bd + 1); - bd->in_fd = src_fd; - } - /* Init the CRC32 table (big endian) */ - for (i = 0; i < 256; i++) { - c = i << 24; - for (j = 8; j; j--) - c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1); - bd->crc32Table[i] = c; - } - /* Setup for I/O error handling via longjmp */ - i = setjmp(bd->jmpbuf); - if (i) - return i; - /* Ensure that file starts with "BZh" */ - for (i = 0; i < 3; i++) - if (get_bits(bd, 8) != "BZh"[i]) - return RETVAL_NOT_BZIP_DATA; - /* Next byte ascii '1'-'9', indicates block size in units of 100k of - uncompressed data. Allocate intermediate buffer for block. */ - i = get_bits(bd, 8); - if (i < '1' || i > '9') - return RETVAL_NOT_BZIP_DATA; - bd->dbufSize = 100000 * (i - '0'); - if (!(bd->dbuf = malloc(bd->dbufSize * sizeof(int)))) - return RETVAL_OUT_OF_MEMORY; - return RETVAL_OK; -} - -/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data, - not end of file.) */ -static char *uncompressStream(int64_t src_fd, int64_t dst_fd) -{ - bunzip_data *bd; - int i; - if (!(i = start_bunzip(&bd, src_fd, 0, 0))) { - i = write_bunzip_data(bd, dst_fd, 0, 0); - if (i == RETVAL_LAST_BLOCK && bd->headerCRC == bd->totalCRC) - i = RETVAL_OK; - } - flush_bunzip_outbuf(bd, dst_fd); - if (bd->dbuf) - free(bd->dbuf); - free(bd); - return bunzip_errors[-i]; -} - -int main(int argc, char *argv[]) -{ - char *err; - if (!(err = uncompressStream(STDIN_FILENO, STDOUT_FILENO))) { - return 0; - } else { - fprintf(stderr, "\n%s\n", err); - return 1; - } -} diff --git a/third_party/double-conversion/LICENSE b/third_party/double-conversion/LICENSE deleted file mode 100644 index 933718a9..00000000 --- a/third_party/double-conversion/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ -Copyright 2006-2011, the V8 project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/double-conversion/README.cosmo b/third_party/double-conversion/README.cosmo deleted file mode 100644 index e797015f..00000000 --- a/third_party/double-conversion/README.cosmo +++ /dev/null @@ -1 +0,0 @@ -google/double-conversion@1dce44c4313a6f356fcfa4b3e8887f037ac0bf23 diff --git a/third_party/double-conversion/bignum-dtoa.cc b/third_party/double-conversion/bignum-dtoa.cc deleted file mode 100644 index 48d71545..00000000 --- a/third_party/double-conversion/bignum-dtoa.cc +++ /dev/null @@ -1,621 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "libc/macros.h" -#include "libc/math.h" -#include "third_party/double-conversion/bignum-dtoa.h" -#include "third_party/double-conversion/bignum.h" -#include "third_party/double-conversion/ieee.h" - -asm(".ident\t\"\\n\\n\ -double-conversion (BSD-3)\\n\ -Copyright 2010 the V8 project authors\""); -asm(".include \"libc/disclaimer.inc\""); - -namespace double_conversion { - -static int NormalizedExponent(uint64_t significand, int exponent) { - DOUBLE_CONVERSION_ASSERT(significand != 0); - while ((significand & Double::kHiddenBit) == 0) { - significand = significand << 1; - exponent = exponent - 1; - } - return exponent; -} - -// Forward declarations: -// Returns an estimation of k such that 10^(k-1) <= v < 10^k. -static int EstimatePower(int exponent); -// Computes v / 10^estimated_power exactly, as a ratio of two bignums, numerator -// and denominator. -static void InitialScaledStartValues(uint64_t significand, int exponent, - bool lower_boundary_is_closer, - int estimated_power, - bool need_boundary_deltas, - Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus); -// Multiplies numerator/denominator so that its values lies in the range 1-10. -// Returns decimal_point s.t. -// v = numerator'/denominator' * 10^(decimal_point-1) -// where numerator' and denominator' are the values of numerator and -// denominator after the call to this function. -static void FixupMultiply10(int estimated_power, bool is_even, - int* decimal_point, Bignum* numerator, - Bignum* denominator, Bignum* delta_minus, - Bignum* delta_plus); -// Generates digits from the left to the right and stops when the generated -// digits yield the shortest decimal representation of v. -static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus, - bool is_even, Vector buffer, - int* length); -// Generates 'requested_digits' after the decimal point. -static void BignumToFixed(int requested_digits, int* decimal_point, - Bignum* numerator, Bignum* denominator, - Vector buffer, int* length); -// Generates 'count' digits of numerator/denominator. -// Once 'count' digits have been produced rounds the result depending on the -// remainder (remainders of exactly .5 round upwards). Might update the -// decimal_point when rounding up (for example for 0.9999). -static void GenerateCountedDigits(int count, int* decimal_point, - Bignum* numerator, Bignum* denominator, - Vector buffer, int* length); - -void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, - Vector buffer, int* length, int* decimal_point) { - DOUBLE_CONVERSION_ASSERT(v > 0); - DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); - uint64_t significand; - int exponent; - bool lower_boundary_is_closer; - if (mode == BIGNUM_DTOA_SHORTEST_SINGLE) { - float f = static_cast(v); - DOUBLE_CONVERSION_ASSERT(f == v); - significand = Single(f).Significand(); - exponent = Single(f).Exponent(); - lower_boundary_is_closer = Single(f).LowerBoundaryIsCloser(); - } else { - significand = Double(v).Significand(); - exponent = Double(v).Exponent(); - lower_boundary_is_closer = Double(v).LowerBoundaryIsCloser(); - } - bool need_boundary_deltas = - (mode == BIGNUM_DTOA_SHORTEST || mode == BIGNUM_DTOA_SHORTEST_SINGLE); - - bool is_even = (significand & 1) == 0; - int normalized_exponent = NormalizedExponent(significand, exponent); - // estimated_power might be too low by 1. - int estimated_power = EstimatePower(normalized_exponent); - - // Shortcut for Fixed. - // The requested digits correspond to the digits after the point. If the - // number is much too small, then there is no need in trying to get any - // digits. - if (mode == BIGNUM_DTOA_FIXED && -estimated_power - 1 > requested_digits) { - buffer[0] = '\0'; - *length = 0; - // Set decimal-point to -requested_digits. This is what Gay does. - // Note that it should not have any effect anyways since the string is - // empty. - *decimal_point = -requested_digits; - return; - } - - Bignum numerator; - Bignum denominator; - Bignum delta_minus; - Bignum delta_plus; - // Make sure the bignum can grow large enough. The smallest double equals - // 4e-324. In this case the denominator needs fewer than 324*4 binary digits. - // The maximum double is 1.7976931348623157e308 which needs fewer than - // 308*4 binary digits. - DOUBLE_CONVERSION_ASSERT(Bignum::kMaxSignificantBits >= 324 * 4); - InitialScaledStartValues(significand, exponent, lower_boundary_is_closer, - estimated_power, need_boundary_deltas, &numerator, - &denominator, &delta_minus, &delta_plus); - // We now have v = (numerator / denominator) * 10^estimated_power. - FixupMultiply10(estimated_power, is_even, decimal_point, &numerator, - &denominator, &delta_minus, &delta_plus); - // We now have v = (numerator / denominator) * 10^(decimal_point-1), and - // 1 <= (numerator + delta_plus) / denominator < 10 - switch (mode) { - case BIGNUM_DTOA_SHORTEST: - case BIGNUM_DTOA_SHORTEST_SINGLE: - GenerateShortestDigits(&numerator, &denominator, &delta_minus, - &delta_plus, is_even, buffer, length); - break; - case BIGNUM_DTOA_FIXED: - BignumToFixed(requested_digits, decimal_point, &numerator, &denominator, - buffer, length); - break; - case BIGNUM_DTOA_PRECISION: - GenerateCountedDigits(requested_digits, decimal_point, &numerator, - &denominator, buffer, length); - break; - default: - DOUBLE_CONVERSION_UNREACHABLE(); - } - buffer[*length] = '\0'; -} - -// The procedure starts generating digits from the left to the right and stops -// when the generated digits yield the shortest decimal representation of v. A -// decimal representation of v is a number lying closer to v than to any other -// double, so it converts to v when read. -// -// This is true if d, the decimal representation, is between m- and m+, the -// upper and lower boundaries. d must be strictly between them if !is_even. -// m- := (numerator - delta_minus) / denominator -// m+ := (numerator + delta_plus) / denominator -// -// Precondition: 0 <= (numerator+delta_plus) / denominator < 10. -// If 1 <= (numerator+delta_plus) / denominator < 10 then no leading 0 digit -// will be produced. This should be the standard precondition. -static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus, - bool is_even, Vector buffer, - int* length) { - // Small optimization: if delta_minus and delta_plus are the same just reuse - // one of the two bignums. - if (Bignum::Equal(*delta_minus, *delta_plus)) { - delta_plus = delta_minus; - } - *length = 0; - for (;;) { - uint16_t digit; - digit = numerator->DivideModuloIntBignum(*denominator); - DOUBLE_CONVERSION_ASSERT( - digit <= 9); // digit is a uint16_t and therefore always positive. - // digit = numerator / denominator (integer division). - // numerator = numerator % denominator. - buffer[(*length)++] = static_cast(digit + '0'); - - // Can we stop already? - // If the remainder of the division is less than the distance to the lower - // boundary we can stop. In this case we simply round down (discarding the - // remainder). - // Similarly we test if we can round up (using the upper boundary). - bool in_delta_room_minus; - bool in_delta_room_plus; - if (is_even) { - in_delta_room_minus = Bignum::LessEqual(*numerator, *delta_minus); - } else { - in_delta_room_minus = Bignum::Less(*numerator, *delta_minus); - } - if (is_even) { - in_delta_room_plus = - Bignum::PlusCompare(*numerator, *delta_plus, *denominator) >= 0; - } else { - in_delta_room_plus = - Bignum::PlusCompare(*numerator, *delta_plus, *denominator) > 0; - } - if (!in_delta_room_minus && !in_delta_room_plus) { - // Prepare for next iteration. - numerator->Times10(); - delta_minus->Times10(); - // We optimized delta_plus to be equal to delta_minus (if they share the - // same value). So don't multiply delta_plus if they point to the same - // object. - if (delta_minus != delta_plus) { - delta_plus->Times10(); - } - } else if (in_delta_room_minus && in_delta_room_plus) { - // Let's see if 2*numerator < denominator. - // If yes, then the next digit would be < 5 and we can round down. - int compare = Bignum::PlusCompare(*numerator, *numerator, *denominator); - if (compare < 0) { - // Remaining digits are less than .5. -> Round down (== do nothing). - } else if (compare > 0) { - // Remaining digits are more than .5 of denominator. -> Round up. - // Note that the last digit could not be a '9' as otherwise the whole - // loop would have stopped earlier. - // We still have an assert here in case the preconditions were not - // satisfied. - DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); - buffer[(*length) - 1]++; - } else { - // Halfway case. - // TODO(floitsch): need a way to solve half-way cases. - // For now let's round towards even (since this is what Gay seems to - // do). - - if ((buffer[(*length) - 1] - '0') % 2 == 0) { - // Round down => Do nothing. - } else { - DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); - buffer[(*length) - 1]++; - } - } - return; - } else if (in_delta_room_minus) { - // Round down (== do nothing). - return; - } else { // in_delta_room_plus - // Round up. - // Note again that the last digit could not be '9' since this would have - // stopped the loop earlier. - // We still have an DOUBLE_CONVERSION_ASSERT here, in case the - // preconditions were not satisfied. - DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); - buffer[(*length) - 1]++; - return; - } - } -} - -// Let v = numerator / denominator < 10. -// Then we generate 'count' digits of d = x.xxxxx... (without the decimal point) -// from left to right. Once 'count' digits have been produced we decide wether -// to round up or down. Remainders of exactly .5 round upwards. Numbers such -// as 9.999999 propagate a carry all the way, and change the -// exponent (decimal_point), when rounding upwards. -static void GenerateCountedDigits(int count, int* decimal_point, - Bignum* numerator, Bignum* denominator, - Vector buffer, int* length) { - DOUBLE_CONVERSION_ASSERT(count >= 0); - for (int i = 0; i < count - 1; ++i) { - uint16_t digit; - digit = numerator->DivideModuloIntBignum(*denominator); - DOUBLE_CONVERSION_ASSERT( - digit <= 9); // digit is a uint16_t and therefore always positive. - // digit = numerator / denominator (integer division). - // numerator = numerator % denominator. - buffer[i] = static_cast(digit + '0'); - // Prepare for next iteration. - numerator->Times10(); - } - // Generate the last digit. - uint16_t digit; - digit = numerator->DivideModuloIntBignum(*denominator); - if (Bignum::PlusCompare(*numerator, *numerator, *denominator) >= 0) { - digit++; - } - DOUBLE_CONVERSION_ASSERT(digit <= 10); - buffer[count - 1] = static_cast(digit + '0'); - // Correct bad digits (in case we had a sequence of '9's). Propagate the - // carry until we hat a non-'9' or til we reach the first digit. - for (int i = count - 1; i > 0; --i) { - if (buffer[i] != '0' + 10) break; - buffer[i] = '0'; - buffer[i - 1]++; - } - if (buffer[0] == '0' + 10) { - // Propagate a carry past the top place. - buffer[0] = '1'; - (*decimal_point)++; - } - *length = count; -} - -// Generates 'requested_digits' after the decimal point. It might omit -// trailing '0's. If the input number is too small then no digits at all are -// generated (ex.: 2 fixed digits for 0.00001). -// -// Input verifies: 1 <= (numerator + delta) / denominator < 10. -static void BignumToFixed(int requested_digits, int* decimal_point, - Bignum* numerator, Bignum* denominator, - Vector buffer, int* length) { - // Note that we have to look at more than just the requested_digits, since - // a number could be rounded up. Example: v=0.5 with requested_digits=0. - // Even though the power of v equals 0 we can't just stop here. - if (-(*decimal_point) > requested_digits) { - // The number is definitively too small. - // Ex: 0.001 with requested_digits == 1. - // Set decimal-point to -requested_digits. This is what Gay does. - // Note that it should not have any effect anyways since the string is - // empty. - *decimal_point = -requested_digits; - *length = 0; - return; - } else if (-(*decimal_point) == requested_digits) { - // We only need to verify if the number rounds down or up. - // Ex: 0.04 and 0.06 with requested_digits == 1. - DOUBLE_CONVERSION_ASSERT(*decimal_point == -requested_digits); - // Initially the fraction lies in range (1, 10]. Multiply the denominator - // by 10 so that we can compare more easily. - denominator->Times10(); - if (Bignum::PlusCompare(*numerator, *numerator, *denominator) >= 0) { - // If the fraction is >= 0.5 then we have to include the rounded - // digit. - buffer[0] = '1'; - *length = 1; - (*decimal_point)++; - } else { - // Note that we caught most of similar cases earlier. - *length = 0; - } - return; - } else { - // The requested digits correspond to the digits after the point. - // The variable 'needed_digits' includes the digits before the point. - int needed_digits = (*decimal_point) + requested_digits; - GenerateCountedDigits(needed_digits, decimal_point, numerator, denominator, - buffer, length); - } -} - -// Returns an estimation of k such that 10^(k-1) <= v < 10^k where -// v = f * 2^exponent and 2^52 <= f < 2^53. -// v is hence a normalized double with the given exponent. The output is an -// approximation for the exponent of the decimal approimation .digits * 10^k. -// -// The result might undershoot by 1 in which case 10^k <= v < 10^k+1. -// Note: this property holds for v's upper boundary m+ too. -// 10^k <= m+ < 10^k+1. -// (see explanation below). -// -// Examples: -// EstimatePower(0) => 16 -// EstimatePower(-52) => 0 -// -// Note: e >= 0 => EstimatedPower(e) > 0. No similar claim can be made for e<0. -static int EstimatePower(int exponent) { - // This function estimates log10 of v where v = f*2^e (with e == exponent). - // Note that 10^floor(log10(v)) <= v, but v <= 10^ceil(log10(v)). - // Note that f is bounded by its container size. Let p = 53 (the double's - // significand size). Then 2^(p-1) <= f < 2^p. - // - // Given that log10(v) == log2(v)/log2(10) and e+(len(f)-1) is quite close - // to log2(v) the function is simplified to (e+(len(f)-1)/log2(10)). - // The computed number undershoots by less than 0.631 (when we compute log3 - // and not log10). - // - // Optimization: since we only need an approximated result this computation - // can be performed on 64 bit integers. On x86/x64 architecture the speedup is - // not really measurable, though. - // - // Since we want to avoid overshooting we decrement by 1e10 so that - // floating-point imprecisions don't affect us. - // - // Explanation for v's boundary m+: the computation takes advantage of - // the fact that 2^(p-1) <= f < 2^p. Boundaries still satisfy this requirement - // (even for denormals where the delta can be much more important). - - const double k1Log10 = 0.30102999566398114; // 1/lg(10) - - // For doubles len(f) == 53 (don't forget the hidden bit). - const int kSignificandSize = Double::kSignificandSize; - double estimate = ceil((exponent + kSignificandSize - 1) * k1Log10 - 1e-10); - return static_cast(estimate); -} - -// See comments for InitialScaledStartValues. -static void InitialScaledStartValuesPositiveExponent( - uint64_t significand, int exponent, int estimated_power, - bool need_boundary_deltas, Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus) { - // A positive exponent implies a positive power. - DOUBLE_CONVERSION_ASSERT(estimated_power >= 0); - // Since the estimated_power is positive we simply multiply the denominator - // by 10^estimated_power. - - // numerator = v. - numerator->AssignUInt64(significand); - numerator->ShiftLeft(exponent); - // denominator = 10^estimated_power. - denominator->AssignPowerUInt16(10, estimated_power); - - if (need_boundary_deltas) { - // Introduce a common denominator so that the deltas to the boundaries are - // integers. - denominator->ShiftLeft(1); - numerator->ShiftLeft(1); - // Let v = f * 2^e, then m+ - v = 1/2 * 2^e; With the common - // denominator (of 2) delta_plus equals 2^e. - delta_plus->AssignUInt16(1); - delta_plus->ShiftLeft(exponent); - // Same for delta_minus. The adjustments if f == 2^p-1 are done later. - delta_minus->AssignUInt16(1); - delta_minus->ShiftLeft(exponent); - } -} - -// See comments for InitialScaledStartValues -static void InitialScaledStartValuesNegativeExponentPositivePower( - uint64_t significand, int exponent, int estimated_power, - bool need_boundary_deltas, Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus) { - // v = f * 2^e with e < 0, and with estimated_power >= 0. - // This means that e is close to 0 (have a look at how estimated_power is - // computed). - - // numerator = significand - // since v = significand * 2^exponent this is equivalent to - // numerator = v * / 2^-exponent - numerator->AssignUInt64(significand); - // denominator = 10^estimated_power * 2^-exponent (with exponent < 0) - denominator->AssignPowerUInt16(10, estimated_power); - denominator->ShiftLeft(-exponent); - - if (need_boundary_deltas) { - // Introduce a common denominator so that the deltas to the boundaries are - // integers. - denominator->ShiftLeft(1); - numerator->ShiftLeft(1); - // Let v = f * 2^e, then m+ - v = 1/2 * 2^e; With the common - // denominator (of 2) delta_plus equals 2^e. - // Given that the denominator already includes v's exponent the distance - // to the boundaries is simply 1. - delta_plus->AssignUInt16(1); - // Same for delta_minus. The adjustments if f == 2^p-1 are done later. - delta_minus->AssignUInt16(1); - } -} - -// See comments for InitialScaledStartValues -static void InitialScaledStartValuesNegativeExponentNegativePower( - uint64_t significand, int exponent, int estimated_power, - bool need_boundary_deltas, Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus) { - // Instead of multiplying the denominator with 10^estimated_power we - // multiply all values (numerator and deltas) by 10^-estimated_power. - - // Use numerator as temporary container for power_ten. - Bignum* power_ten = numerator; - power_ten->AssignPowerUInt16(10, -estimated_power); - - if (need_boundary_deltas) { - // Since power_ten == numerator we must make a copy of 10^estimated_power - // before we complete the computation of the numerator. - // delta_plus = delta_minus = 10^estimated_power - delta_plus->AssignBignum(*power_ten); - delta_minus->AssignBignum(*power_ten); - } - - // numerator = significand * 2 * 10^-estimated_power - // since v = significand * 2^exponent this is equivalent to - // numerator = v * 10^-estimated_power * 2 * 2^-exponent. - // Remember: numerator has been abused as power_ten. So no need to assign it - // to itself. - DOUBLE_CONVERSION_ASSERT(numerator == power_ten); - numerator->MultiplyByUInt64(significand); - - // denominator = 2 * 2^-exponent with exponent < 0. - denominator->AssignUInt16(1); - denominator->ShiftLeft(-exponent); - - if (need_boundary_deltas) { - // Introduce a common denominator so that the deltas to the boundaries are - // integers. - numerator->ShiftLeft(1); - denominator->ShiftLeft(1); - // With this shift the boundaries have their correct value, since - // delta_plus = 10^-estimated_power, and - // delta_minus = 10^-estimated_power. - // These assignments have been done earlier. - // The adjustments if f == 2^p-1 (lower boundary is closer) are done later. - } -} - -// Let v = significand * 2^exponent. -// Computes v / 10^estimated_power exactly, as a ratio of two bignums, numerator -// and denominator. The functions GenerateShortestDigits and -// GenerateCountedDigits will then convert this ratio to its decimal -// representation d, with the required accuracy. -// Then d * 10^estimated_power is the representation of v. -// (Note: the fraction and the estimated_power might get adjusted before -// generating the decimal representation.) -// -// The initial start values consist of: -// - a scaled numerator: s.t. numerator/denominator == v / 10^estimated_power. -// - a scaled (common) denominator. -// optionally (used by GenerateShortestDigits to decide if it has the shortest -// decimal converting back to v): -// - v - m-: the distance to the lower boundary. -// - m+ - v: the distance to the upper boundary. -// -// v, m+, m-, and therefore v - m- and m+ - v all share the same denominator. -// -// Let ep == estimated_power, then the returned values will satisfy: -// v / 10^ep = numerator / denominator. -// v's boundarys m- and m+: -// m- / 10^ep == v / 10^ep - delta_minus / denominator -// m+ / 10^ep == v / 10^ep + delta_plus / denominator -// Or in other words: -// m- == v - delta_minus * 10^ep / denominator; -// m+ == v + delta_plus * 10^ep / denominator; -// -// Since 10^(k-1) <= v < 10^k (with k == estimated_power) -// or 10^k <= v < 10^(k+1) -// we then have 0.1 <= numerator/denominator < 1 -// or 1 <= numerator/denominator < 10 -// -// It is then easy to kickstart the digit-generation routine. -// -// The boundary-deltas are only filled if the mode equals BIGNUM_DTOA_SHORTEST -// or BIGNUM_DTOA_SHORTEST_SINGLE. - -static void InitialScaledStartValues(uint64_t significand, int exponent, - bool lower_boundary_is_closer, - int estimated_power, - bool need_boundary_deltas, - Bignum* numerator, Bignum* denominator, - Bignum* delta_minus, Bignum* delta_plus) { - if (exponent >= 0) { - InitialScaledStartValuesPositiveExponent( - significand, exponent, estimated_power, need_boundary_deltas, numerator, - denominator, delta_minus, delta_plus); - } else if (estimated_power >= 0) { - InitialScaledStartValuesNegativeExponentPositivePower( - significand, exponent, estimated_power, need_boundary_deltas, numerator, - denominator, delta_minus, delta_plus); - } else { - InitialScaledStartValuesNegativeExponentNegativePower( - significand, exponent, estimated_power, need_boundary_deltas, numerator, - denominator, delta_minus, delta_plus); - } - - if (need_boundary_deltas && lower_boundary_is_closer) { - // The lower boundary is closer at half the distance of "normal" numbers. - // Increase the common denominator and adapt all but the delta_minus. - denominator->ShiftLeft(1); // *2 - numerator->ShiftLeft(1); // *2 - delta_plus->ShiftLeft(1); // *2 - } -} - -// This routine multiplies numerator/denominator so that its values lies in the -// range 1-10. That is after a call to this function we have: -// 1 <= (numerator + delta_plus) /denominator < 10. -// Let numerator the input before modification and numerator' the argument -// after modification, then the output-parameter decimal_point is such that -// numerator / denominator * 10^estimated_power == -// numerator' / denominator' * 10^(decimal_point - 1) -// In some cases estimated_power was too low, and this is already the case. We -// then simply adjust the power so that 10^(k-1) <= v < 10^k (with k == -// estimated_power) but do not touch the numerator or denominator. -// Otherwise the routine multiplies the numerator and the deltas by 10. -static void FixupMultiply10(int estimated_power, bool is_even, - int* decimal_point, Bignum* numerator, - Bignum* denominator, Bignum* delta_minus, - Bignum* delta_plus) { - bool in_range; - if (is_even) { - // For IEEE doubles half-way cases (in decimal system numbers ending with 5) - // are rounded to the closest floating-point number with even significand. - in_range = Bignum::PlusCompare(*numerator, *delta_plus, *denominator) >= 0; - } else { - in_range = Bignum::PlusCompare(*numerator, *delta_plus, *denominator) > 0; - } - if (in_range) { - // Since numerator + delta_plus >= denominator we already have - // 1 <= numerator/denominator < 10. Simply update the estimated_power. - *decimal_point = estimated_power + 1; - } else { - *decimal_point = estimated_power; - numerator->Times10(); - if (Bignum::Equal(*delta_minus, *delta_plus)) { - delta_minus->Times10(); - delta_plus->AssignBignum(*delta_minus); - } else { - delta_minus->Times10(); - delta_plus->Times10(); - } - } -} - -} // namespace double_conversion diff --git a/third_party/double-conversion/bignum-dtoa.h b/third_party/double-conversion/bignum-dtoa.h deleted file mode 100644 index 34b96199..00000000 --- a/third_party/double-conversion/bignum-dtoa.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_ -#define DOUBLE_CONVERSION_BIGNUM_DTOA_H_ - -#include "utils.h" - -namespace double_conversion { - -enum BignumDtoaMode { - // Return the shortest correct representation. - // For example the output of 0.299999999999999988897 is (the less accurate but - // correct) 0.3. - BIGNUM_DTOA_SHORTEST, - // Same as BIGNUM_DTOA_SHORTEST but for single-precision floats. - BIGNUM_DTOA_SHORTEST_SINGLE, - // Return a fixed number of digits after the decimal point. - // For instance fixed(0.1, 4) becomes 0.1000 - // If the input number is big, the output will be big. - BIGNUM_DTOA_FIXED, - // Return a fixed number of digits, no matter what the exponent is. - BIGNUM_DTOA_PRECISION -}; - -// Converts the given double 'v' to ascii. -// The result should be interpreted as buffer * 10^(point-length). -// The buffer will be null-terminated. -// -// The input v must be > 0 and different from NaN, and Infinity. -// -// The output depends on the given mode: -// - SHORTEST: produce the least amount of digits for which the internal -// identity requirement is still satisfied. If the digits are printed -// (together with the correct exponent) then reading this number will give -// 'v' again. The buffer will choose the representation that is closest to -// 'v'. If there are two at the same distance, than the number is round up. -// In this mode the 'requested_digits' parameter is ignored. -// - FIXED: produces digits necessary to print a given number with -// 'requested_digits' digits after the decimal point. The produced digits -// might be too short in which case the caller has to fill the gaps with '0's. -// Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2. -// Halfway cases are rounded up. The call toFixed(0.15, 2) thus returns -// buffer="2", point=0. -// Note: the length of the returned buffer has no meaning wrt the significance -// of its digits. That is, just because it contains '0's does not mean that -// any other digit would not satisfy the internal identity requirement. -// - PRECISION: produces 'requested_digits' where the first digit is not '0'. -// Even though the length of produced digits usually equals -// 'requested_digits', the function is allowed to return fewer digits, in -// which case the caller has to fill the missing digits with '0's. -// Halfway cases are again rounded up. -// 'BignumDtoa' expects the given buffer to be big enough to hold all digits -// and a terminating null-character. -void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, - Vector buffer, int* length, int* point); - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_BIGNUM_DTOA_H_ diff --git a/third_party/double-conversion/bignum.cc b/third_party/double-conversion/bignum.cc deleted file mode 100644 index 2b3a8a26..00000000 --- a/third_party/double-conversion/bignum.cc +++ /dev/null @@ -1,775 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "libc/macros.h" -#include "third_party/double-conversion/bignum.h" -#include "third_party/double-conversion/utils.h" - -asm(".ident\t\"\\n\\n\ -double-conversion (BSD-3)\\n\ -Copyright 2010 the V8 project authors\""); -asm(".include \"libc/disclaimer.inc\""); - -namespace double_conversion { - -Bignum::Chunk& Bignum::RawBigit(const int index) { - DOUBLE_CONVERSION_ASSERT(static_cast(index) < kBigitCapacity); - return bigits_buffer_[index]; -} - -const Bignum::Chunk& Bignum::RawBigit(const int index) const { - DOUBLE_CONVERSION_ASSERT(static_cast(index) < kBigitCapacity); - return bigits_buffer_[index]; -} - -template -static int BitSize(const S value) { - (void)value; // Mark variable as used. - return 8 * sizeof(value); -} - -// Guaranteed to lie in one Bigit. -void Bignum::AssignUInt16(const uint16_t value) { - DOUBLE_CONVERSION_ASSERT(kBigitSize >= BitSize(value)); - Zero(); - if (value > 0) { - RawBigit(0) = value; - used_bigits_ = 1; - } -} - -void Bignum::AssignUInt64(uint64_t value) { - Zero(); - for (int i = 0; value > 0; ++i) { - RawBigit(i) = value & kBigitMask; - value >>= kBigitSize; - ++used_bigits_; - } -} - -void Bignum::AssignBignum(const Bignum& other) { - exponent_ = other.exponent_; - for (int i = 0; i < other.used_bigits_; ++i) { - RawBigit(i) = other.RawBigit(i); - } - used_bigits_ = other.used_bigits_; -} - -static uint64_t ReadUInt64(const Vector buffer, const int from, - const int digits_to_read) { - uint64_t result = 0; - for (int i = from; i < from + digits_to_read; ++i) { - const int digit = buffer[i] - '0'; - DOUBLE_CONVERSION_ASSERT(0 <= digit && digit <= 9); - result = result * 10 + digit; - } - return result; -} - -void Bignum::AssignDecimalString(const Vector value) { - // 2^64 = 18446744073709551616 > 10^19 - static const int kMaxUint64DecimalDigits = 19; - Zero(); - int length = value.length(); - unsigned pos = 0; - // Let's just say that each digit needs 4 bits. - while (length >= kMaxUint64DecimalDigits) { - const uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); - pos += kMaxUint64DecimalDigits; - length -= kMaxUint64DecimalDigits; - MultiplyByPowerOfTen(kMaxUint64DecimalDigits); - AddUInt64(digits); - } - const uint64_t digits = ReadUInt64(value, pos, length); - MultiplyByPowerOfTen(length); - AddUInt64(digits); - Clamp(); -} - -static uint64_t HexCharValue(const int c) { - if ('0' <= c && c <= '9') { - return c - '0'; - } - if ('a' <= c && c <= 'f') { - return 10 + c - 'a'; - } - DOUBLE_CONVERSION_ASSERT('A' <= c && c <= 'F'); - return 10 + c - 'A'; -} - -// Unlike AssignDecimalString(), this function is "only" used -// for unit-tests and therefore not performance critical. -void Bignum::AssignHexString(Vector value) { - Zero(); - // Required capacity could be reduced by ignoring leading zeros. - EnsureCapacity(((value.length() * 4) + kBigitSize - 1) / kBigitSize); - DOUBLE_CONVERSION_ASSERT(sizeof(uint64_t) * 8 >= - kBigitSize + 4); // TODO: static_assert - // Accumulates converted hex digits until at least kBigitSize bits. - // Works with non-factor-of-four kBigitSizes. - uint64_t tmp = 0; // Accumulates converted hex digits until at least - for (int cnt = 0; !value.is_empty(); value.pop_back()) { - tmp |= (HexCharValue(value.last()) << cnt); - if ((cnt += 4) >= kBigitSize) { - RawBigit(used_bigits_++) = (tmp & kBigitMask); - cnt -= kBigitSize; - tmp >>= kBigitSize; - } - } - if (tmp > 0) { - RawBigit(used_bigits_++) = tmp; - } - Clamp(); -} - -void Bignum::AddUInt64(const uint64_t operand) { - if (operand == 0) { - return; - } - Bignum other; - other.AssignUInt64(operand); - AddBignum(other); -} - -void Bignum::AddBignum(const Bignum& other) { - DOUBLE_CONVERSION_ASSERT(IsClamped()); - DOUBLE_CONVERSION_ASSERT(other.IsClamped()); - - // If this has a greater exponent than other append zero-bigits to this. - // After this call exponent_ <= other.exponent_. - Align(other); - - // There are two possibilities: - // aaaaaaaaaaa 0000 (where the 0s represent a's exponent) - // bbbbb 00000000 - // ---------------- - // ccccccccccc 0000 - // or - // aaaaaaaaaa 0000 - // bbbbbbbbb 0000000 - // ----------------- - // cccccccccccc 0000 - // In both cases we might need a carry bigit. - - EnsureCapacity(1 + MAX(BigitLength(), other.BigitLength()) - exponent_); - Chunk carry = 0; - int bigit_pos = other.exponent_ - exponent_; - DOUBLE_CONVERSION_ASSERT(bigit_pos >= 0); - for (int i = used_bigits_; i < bigit_pos; ++i) { - RawBigit(i) = 0; - } - for (int i = 0; i < other.used_bigits_; ++i) { - const Chunk my = (bigit_pos < used_bigits_) ? RawBigit(bigit_pos) : 0; - const Chunk sum = my + other.RawBigit(i) + carry; - RawBigit(bigit_pos) = sum & kBigitMask; - carry = sum >> kBigitSize; - ++bigit_pos; - } - while (carry != 0) { - const Chunk my = (bigit_pos < used_bigits_) ? RawBigit(bigit_pos) : 0; - const Chunk sum = my + carry; - RawBigit(bigit_pos) = sum & kBigitMask; - carry = sum >> kBigitSize; - ++bigit_pos; - } - used_bigits_ = MAX(bigit_pos, static_cast(used_bigits_)); - DOUBLE_CONVERSION_ASSERT(IsClamped()); -} - -void Bignum::SubtractBignum(const Bignum& other) { - DOUBLE_CONVERSION_ASSERT(IsClamped()); - DOUBLE_CONVERSION_ASSERT(other.IsClamped()); - // We require this to be bigger than other. - DOUBLE_CONVERSION_ASSERT(LessEqual(other, *this)); - - Align(other); - - const int offset = other.exponent_ - exponent_; - Chunk borrow = 0; - int i; - for (i = 0; i < other.used_bigits_; ++i) { - DOUBLE_CONVERSION_ASSERT((borrow == 0) || (borrow == 1)); - const Chunk difference = RawBigit(i + offset) - other.RawBigit(i) - borrow; - RawBigit(i + offset) = difference & kBigitMask; - borrow = difference >> (kChunkSize - 1); - } - while (borrow != 0) { - const Chunk difference = RawBigit(i + offset) - borrow; - RawBigit(i + offset) = difference & kBigitMask; - borrow = difference >> (kChunkSize - 1); - ++i; - } - Clamp(); -} - -void Bignum::ShiftLeft(const int shift_amount) { - if (used_bigits_ == 0) { - return; - } - exponent_ += (shift_amount / kBigitSize); - const int local_shift = shift_amount % kBigitSize; - EnsureCapacity(used_bigits_ + 1); - BigitsShiftLeft(local_shift); -} - -void Bignum::MultiplyByUInt32(const uint32_t factor) { - if (factor == 1) { - return; - } - if (factor == 0) { - Zero(); - return; - } - if (used_bigits_ == 0) { - return; - } - // The product of a bigit with the factor is of size kBigitSize + 32. - // Assert that this number + 1 (for the carry) fits into double chunk. - DOUBLE_CONVERSION_ASSERT(kDoubleChunkSize >= kBigitSize + 32 + 1); - DoubleChunk carry = 0; - for (int i = 0; i < used_bigits_; ++i) { - const DoubleChunk product = - static_cast(factor) * RawBigit(i) + carry; - RawBigit(i) = static_cast(product & kBigitMask); - carry = (product >> kBigitSize); - } - while (carry != 0) { - EnsureCapacity(used_bigits_ + 1); - RawBigit(used_bigits_) = carry & kBigitMask; - used_bigits_++; - carry >>= kBigitSize; - } -} - -void Bignum::MultiplyByUInt64(const uint64_t factor) { - if (factor == 1) { - return; - } - if (factor == 0) { - Zero(); - return; - } - if (used_bigits_ == 0) { - return; - } - DOUBLE_CONVERSION_ASSERT(kBigitSize < 32); - uint64_t carry = 0; - const uint64_t low = factor & 0xFFFFFFFF; - const uint64_t high = factor >> 32; - for (int i = 0; i < used_bigits_; ++i) { - const uint64_t product_low = low * RawBigit(i); - const uint64_t product_high = high * RawBigit(i); - const uint64_t tmp = (carry & kBigitMask) + product_low; - RawBigit(i) = tmp & kBigitMask; - carry = (carry >> kBigitSize) + (tmp >> kBigitSize) + - (product_high << (32 - kBigitSize)); - } - while (carry != 0) { - EnsureCapacity(used_bigits_ + 1); - RawBigit(used_bigits_) = carry & kBigitMask; - used_bigits_++; - carry >>= kBigitSize; - } -} - -void Bignum::MultiplyByPowerOfTen(const int exponent) { - static const uint64_t kFive27 = - DOUBLE_CONVERSION_UINT64_2PART_C(0x6765c793, fa10079d); - static const uint16_t kFive1 = 5; - static const uint16_t kFive2 = kFive1 * 5; - static const uint16_t kFive3 = kFive2 * 5; - static const uint16_t kFive4 = kFive3 * 5; - static const uint16_t kFive5 = kFive4 * 5; - static const uint16_t kFive6 = kFive5 * 5; - static const uint32_t kFive7 = kFive6 * 5; - static const uint32_t kFive8 = kFive7 * 5; - static const uint32_t kFive9 = kFive8 * 5; - static const uint32_t kFive10 = kFive9 * 5; - static const uint32_t kFive11 = kFive10 * 5; - static const uint32_t kFive12 = kFive11 * 5; - static const uint32_t kFive13 = kFive12 * 5; - static const uint32_t kFive1_to_12[] = {kFive1, kFive2, kFive3, kFive4, - kFive5, kFive6, kFive7, kFive8, - kFive9, kFive10, kFive11, kFive12}; - - DOUBLE_CONVERSION_ASSERT(exponent >= 0); - - if (exponent == 0) { - return; - } - if (used_bigits_ == 0) { - return; - } - // We shift by exponent at the end just before returning. - int remaining_exponent = exponent; - while (remaining_exponent >= 27) { - MultiplyByUInt64(kFive27); - remaining_exponent -= 27; - } - while (remaining_exponent >= 13) { - MultiplyByUInt32(kFive13); - remaining_exponent -= 13; - } - if (remaining_exponent > 0) { - MultiplyByUInt32(kFive1_to_12[remaining_exponent - 1]); - } - ShiftLeft(exponent); -} - -void Bignum::Square() { - DOUBLE_CONVERSION_ASSERT(IsClamped()); - const int product_length = 2 * used_bigits_; - EnsureCapacity(product_length); - - // Comba multiplication: compute each column separately. - // Example: r = a2a1a0 * b2b1b0. - // r = 1 * a0b0 + - // 10 * (a1b0 + a0b1) + - // 100 * (a2b0 + a1b1 + a0b2) + - // 1000 * (a2b1 + a1b2) + - // 10000 * a2b2 - // - // In the worst case we have to accumulate nb-digits products of digit*digit. - // - // Assert that the additional number of bits in a DoubleChunk are enough to - // sum up used_digits of Bigit*Bigit. - if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_bigits_) { - DOUBLE_CONVERSION_UNIMPLEMENTED(); - } - DoubleChunk accumulator = 0; - // First shift the digits so we don't overwrite them. - const int copy_offset = used_bigits_; - for (int i = 0; i < used_bigits_; ++i) { - RawBigit(copy_offset + i) = RawBigit(i); - } - // We have two loops to avoid some 'if's in the loop. - for (int i = 0; i < used_bigits_; ++i) { - // Process temporary digit i with power i. - // The sum of the two indices must be equal to i. - int bigit_index1 = i; - int bigit_index2 = 0; - // Sum all of the sub-products. - while (bigit_index1 >= 0) { - const Chunk chunk1 = RawBigit(copy_offset + bigit_index1); - const Chunk chunk2 = RawBigit(copy_offset + bigit_index2); - accumulator += static_cast(chunk1) * chunk2; - bigit_index1--; - bigit_index2++; - } - RawBigit(i) = static_cast(accumulator) & kBigitMask; - accumulator >>= kBigitSize; - } - for (int i = used_bigits_; i < product_length; ++i) { - int bigit_index1 = used_bigits_ - 1; - int bigit_index2 = i - bigit_index1; - // Invariant: sum of both indices is again equal to i. - // Inner loop runs 0 times on last iteration, emptying accumulator. - while (bigit_index2 < used_bigits_) { - const Chunk chunk1 = RawBigit(copy_offset + bigit_index1); - const Chunk chunk2 = RawBigit(copy_offset + bigit_index2); - accumulator += static_cast(chunk1) * chunk2; - bigit_index1--; - bigit_index2++; - } - // The overwritten RawBigit(i) will never be read in further loop - // iterations, because bigit_index1 and bigit_index2 are always greater than - // i - used_bigits_. - RawBigit(i) = static_cast(accumulator) & kBigitMask; - accumulator >>= kBigitSize; - } - // Since the result was guaranteed to lie inside the number the - // accumulator must be 0 now. - DOUBLE_CONVERSION_ASSERT(accumulator == 0); - - // Don't forget to update the used_digits and the exponent. - used_bigits_ = product_length; - exponent_ *= 2; - Clamp(); -} - -void Bignum::AssignPowerUInt16(uint16_t base, const int power_exponent) { - DOUBLE_CONVERSION_ASSERT(base != 0); - DOUBLE_CONVERSION_ASSERT(power_exponent >= 0); - if (power_exponent == 0) { - AssignUInt16(1); - return; - } - Zero(); - int shifts = 0; - // We expect base to be in range 2-32, and most often to be 10. - // It does not make much sense to implement different algorithms for counting - // the bits. - while ((base & 1) == 0) { - base >>= 1; - shifts++; - } - int bit_size = 0; - int tmp_base = base; - while (tmp_base != 0) { - tmp_base >>= 1; - bit_size++; - } - const int final_size = bit_size * power_exponent; - // 1 extra bigit for the shifting, and one for rounded final_size. - EnsureCapacity(final_size / kBigitSize + 2); - - // Left to Right exponentiation. - int mask = 1; - while (power_exponent >= mask) mask <<= 1; - - // The mask is now pointing to the bit above the most significant 1-bit of - // power_exponent. - // Get rid of first 1-bit; - mask >>= 2; - uint64_t this_value = base; - - bool delayed_multiplication = false; - const uint64_t max_32bits = 0xFFFFFFFF; - while (mask != 0 && this_value <= max_32bits) { - this_value = this_value * this_value; - // Verify that there is enough space in this_value to perform the - // multiplication. The first bit_size bits must be 0. - if ((power_exponent & mask) != 0) { - DOUBLE_CONVERSION_ASSERT(bit_size > 0); - const uint64_t base_bits_mask = - ~((static_cast(1) << (64 - bit_size)) - 1); - const bool high_bits_zero = (this_value & base_bits_mask) == 0; - if (high_bits_zero) { - this_value *= base; - } else { - delayed_multiplication = true; - } - } - mask >>= 1; - } - AssignUInt64(this_value); - if (delayed_multiplication) { - MultiplyByUInt32(base); - } - - // Now do the same thing as a bignum. - while (mask != 0) { - Square(); - if ((power_exponent & mask) != 0) { - MultiplyByUInt32(base); - } - mask >>= 1; - } - - // And finally add the saved shifts. - ShiftLeft(shifts * power_exponent); -} - -// Precondition: this/other < 16bit. -uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { - DOUBLE_CONVERSION_ASSERT(IsClamped()); - DOUBLE_CONVERSION_ASSERT(other.IsClamped()); - DOUBLE_CONVERSION_ASSERT(other.used_bigits_ > 0); - - // Easy case: if we have less digits than the divisor than the result is 0. - // Note: this handles the case where this == 0, too. - if (BigitLength() < other.BigitLength()) { - return 0; - } - - Align(other); - - uint16_t result = 0; - - // Start by removing multiples of 'other' until both numbers have the same - // number of digits. - while (BigitLength() > other.BigitLength()) { - // This naive approach is extremely inefficient if `this` divided by other - // is big. This function is implemented for doubleToString where - // the result should be small (less than 10). - DOUBLE_CONVERSION_ASSERT(other.RawBigit(other.used_bigits_ - 1) >= - ((1 << kBigitSize) / 16)); - DOUBLE_CONVERSION_ASSERT(RawBigit(used_bigits_ - 1) < 0x10000); - // Remove the multiples of the first digit. - // Example this = 23 and other equals 9. -> Remove 2 multiples. - result += static_cast(RawBigit(used_bigits_ - 1)); - SubtractTimes(other, RawBigit(used_bigits_ - 1)); - } - - DOUBLE_CONVERSION_ASSERT(BigitLength() == other.BigitLength()); - - // Both bignums are at the same length now. - // Since other has more than 0 digits we know that the access to - // RawBigit(used_bigits_ - 1) is safe. - const Chunk this_bigit = RawBigit(used_bigits_ - 1); - const Chunk other_bigit = other.RawBigit(other.used_bigits_ - 1); - - if (other.used_bigits_ == 1) { - // Shortcut for easy (and common) case. - int quotient = this_bigit / other_bigit; - RawBigit(used_bigits_ - 1) = this_bigit - other_bigit * quotient; - DOUBLE_CONVERSION_ASSERT(quotient < 0x10000); - result += static_cast(quotient); - Clamp(); - return result; - } - - const int division_estimate = this_bigit / (other_bigit + 1); - DOUBLE_CONVERSION_ASSERT(division_estimate < 0x10000); - result += static_cast(division_estimate); - SubtractTimes(other, division_estimate); - - if (other_bigit * (division_estimate + 1) > this_bigit) { - // No need to even try to subtract. Even if other's remaining digits were 0 - // another subtraction would be too much. - return result; - } - - while (LessEqual(other, *this)) { - SubtractBignum(other); - result++; - } - return result; -} - -template -static int SizeInHexChars(S number) { - DOUBLE_CONVERSION_ASSERT(number > 0); - int result = 0; - while (number != 0) { - number >>= 4; - result++; - } - return result; -} - -static char HexCharOfValue(const int value) { - DOUBLE_CONVERSION_ASSERT(0 <= value && value <= 16); - if (value < 10) { - return static_cast(value + '0'); - } - return static_cast(value - 10 + 'A'); -} - -bool Bignum::ToHexString(char* buffer, const int buffer_size) const { - DOUBLE_CONVERSION_ASSERT(IsClamped()); - // Each bigit must be printable as separate hex-character. - DOUBLE_CONVERSION_ASSERT(kBigitSize % 4 == 0); - static const int kHexCharsPerBigit = kBigitSize / 4; - - if (used_bigits_ == 0) { - if (buffer_size < 2) { - return false; - } - buffer[0] = '0'; - buffer[1] = '\0'; - return true; - } - // We add 1 for the terminating '\0' character. - const int needed_chars = (BigitLength() - 1) * kHexCharsPerBigit + - SizeInHexChars(RawBigit(used_bigits_ - 1)) + 1; - if (needed_chars > buffer_size) { - return false; - } - int string_index = needed_chars - 1; - buffer[string_index--] = '\0'; - for (int i = 0; i < exponent_; ++i) { - for (int j = 0; j < kHexCharsPerBigit; ++j) { - buffer[string_index--] = '0'; - } - } - for (int i = 0; i < used_bigits_ - 1; ++i) { - Chunk current_bigit = RawBigit(i); - for (int j = 0; j < kHexCharsPerBigit; ++j) { - buffer[string_index--] = HexCharOfValue(current_bigit & 0xF); - current_bigit >>= 4; - } - } - // And finally the last bigit. - Chunk most_significant_bigit = RawBigit(used_bigits_ - 1); - while (most_significant_bigit != 0) { - buffer[string_index--] = HexCharOfValue(most_significant_bigit & 0xF); - most_significant_bigit >>= 4; - } - return true; -} - -Bignum::Chunk Bignum::BigitOrZero(const int index) const { - if (index >= BigitLength()) { - return 0; - } - if (index < exponent_) { - return 0; - } - return RawBigit(index - exponent_); -} - -int Bignum::Compare(const Bignum& a, const Bignum& b) { - DOUBLE_CONVERSION_ASSERT(a.IsClamped()); - DOUBLE_CONVERSION_ASSERT(b.IsClamped()); - const int bigit_length_a = a.BigitLength(); - const int bigit_length_b = b.BigitLength(); - if (bigit_length_a < bigit_length_b) { - return -1; - } - if (bigit_length_a > bigit_length_b) { - return +1; - } - for (int i = bigit_length_a - 1; i >= MIN(a.exponent_, b.exponent_); --i) { - const Chunk bigit_a = a.BigitOrZero(i); - const Chunk bigit_b = b.BigitOrZero(i); - if (bigit_a < bigit_b) { - return -1; - } - if (bigit_a > bigit_b) { - return +1; - } - // Otherwise they are equal up to this digit. Try the next digit. - } - return 0; -} - -int Bignum::PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c) { - DOUBLE_CONVERSION_ASSERT(a.IsClamped()); - DOUBLE_CONVERSION_ASSERT(b.IsClamped()); - DOUBLE_CONVERSION_ASSERT(c.IsClamped()); - if (a.BigitLength() < b.BigitLength()) { - return PlusCompare(b, a, c); - } - if (a.BigitLength() + 1 < c.BigitLength()) { - return -1; - } - if (a.BigitLength() > c.BigitLength()) { - return +1; - } - // The exponent encodes 0-bigits. So if there are more 0-digits in 'a' than - // 'b' has digits, then the bigit-length of 'a'+'b' must be equal to the one - // of 'a'. - if (a.exponent_ >= b.BigitLength() && a.BigitLength() < c.BigitLength()) { - return -1; - } - - Chunk borrow = 0; - // Starting at min_exponent all digits are == 0. So no need to compare them. - const int min_exponent = MIN(MIN(a.exponent_, b.exponent_), c.exponent_); - for (int i = c.BigitLength() - 1; i >= min_exponent; --i) { - const Chunk chunk_a = a.BigitOrZero(i); - const Chunk chunk_b = b.BigitOrZero(i); - const Chunk chunk_c = c.BigitOrZero(i); - const Chunk sum = chunk_a + chunk_b; - if (sum > chunk_c + borrow) { - return +1; - } else { - borrow = chunk_c + borrow - sum; - if (borrow > 1) { - return -1; - } - borrow <<= kBigitSize; - } - } - if (borrow == 0) { - return 0; - } - return -1; -} - -void Bignum::Clamp() { - while (used_bigits_ > 0 && RawBigit(used_bigits_ - 1) == 0) { - used_bigits_--; - } - if (used_bigits_ == 0) { - // Zero. - exponent_ = 0; - } -} - -void Bignum::Align(const Bignum& other) { - if (exponent_ > other.exponent_) { - // If "X" represents a "hidden" bigit (by the exponent) then we are in the - // following case (a == this, b == other): - // a: aaaaaaXXXX or a: aaaaaXXX - // b: bbbbbbX b: bbbbbbbbXX - // We replace some of the hidden digits (X) of a with 0 digits. - // a: aaaaaa000X or a: aaaaa0XX - const int zero_bigits = exponent_ - other.exponent_; - EnsureCapacity(used_bigits_ + zero_bigits); - for (int i = used_bigits_ - 1; i >= 0; --i) { - RawBigit(i + zero_bigits) = RawBigit(i); - } - for (int i = 0; i < zero_bigits; ++i) { - RawBigit(i) = 0; - } - used_bigits_ += zero_bigits; - exponent_ -= zero_bigits; - - DOUBLE_CONVERSION_ASSERT(used_bigits_ >= 0); - DOUBLE_CONVERSION_ASSERT(exponent_ >= 0); - } -} - -void Bignum::BigitsShiftLeft(const int shift_amount) { - DOUBLE_CONVERSION_ASSERT(shift_amount < kBigitSize); - DOUBLE_CONVERSION_ASSERT(shift_amount >= 0); - Chunk carry = 0; - for (int i = 0; i < used_bigits_; ++i) { - const Chunk new_carry = RawBigit(i) >> (kBigitSize - shift_amount); - RawBigit(i) = ((RawBigit(i) << shift_amount) + carry) & kBigitMask; - carry = new_carry; - } - if (carry != 0) { - RawBigit(used_bigits_) = carry; - used_bigits_++; - } -} - -void Bignum::SubtractTimes(const Bignum& other, const int factor) { - DOUBLE_CONVERSION_ASSERT(exponent_ <= other.exponent_); - if (factor < 3) { - for (int i = 0; i < factor; ++i) { - SubtractBignum(other); - } - return; - } - Chunk borrow = 0; - const int exponent_diff = other.exponent_ - exponent_; - for (int i = 0; i < other.used_bigits_; ++i) { - const DoubleChunk product = - static_cast(factor) * other.RawBigit(i); - const DoubleChunk remove = borrow + product; - const Chunk difference = - RawBigit(i + exponent_diff) - (remove & kBigitMask); - RawBigit(i + exponent_diff) = difference & kBigitMask; - borrow = static_cast((difference >> (kChunkSize - 1)) + - (remove >> kBigitSize)); - } - for (int i = other.used_bigits_ + exponent_diff; i < used_bigits_; ++i) { - if (borrow == 0) { - return; - } - const Chunk difference = RawBigit(i) - borrow; - RawBigit(i) = difference & kBigitMask; - borrow = difference >> (kChunkSize - 1); - } - Clamp(); -} - -} // namespace double_conversion diff --git a/third_party/double-conversion/bignum.h b/third_party/double-conversion/bignum.h deleted file mode 100644 index ac6e712f..00000000 --- a/third_party/double-conversion/bignum.h +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef DOUBLE_CONVERSION_BIGNUM_H_ -#define DOUBLE_CONVERSION_BIGNUM_H_ - -#include "third_party/double-conversion/utils.h" - -namespace double_conversion { - -class Bignum { - public: - // 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately. - // This bignum can encode much bigger numbers, since it contains an - // exponent. - static const int kMaxSignificantBits = 3584; - - Bignum() : used_bigits_(0), exponent_(0) {} - - void AssignUInt16(const uint16_t value); - void AssignUInt64(uint64_t value); - void AssignBignum(const Bignum& other); - - void AssignDecimalString(const Vector value); - void AssignHexString(const Vector value); - - void AssignPowerUInt16(uint16_t base, const int exponent); - - void AddUInt64(const uint64_t operand); - void AddBignum(const Bignum& other); - // Precondition: this >= other. - void SubtractBignum(const Bignum& other); - - void Square(); - void ShiftLeft(const int shift_amount); - void MultiplyByUInt32(const uint32_t factor); - void MultiplyByUInt64(const uint64_t factor); - void MultiplyByPowerOfTen(const int exponent); - void Times10() { return MultiplyByUInt32(10); } - // Pseudocode: - // int result = this / other; - // this = this % other; - // In the worst case this function is in O(this/other). - uint16_t DivideModuloIntBignum(const Bignum& other); - - bool ToHexString(char* buffer, const int buffer_size) const; - - // Returns - // -1 if a < b, - // 0 if a == b, and - // +1 if a > b. - static int Compare(const Bignum& a, const Bignum& b); - static bool Equal(const Bignum& a, const Bignum& b) { - return Compare(a, b) == 0; - } - static bool LessEqual(const Bignum& a, const Bignum& b) { - return Compare(a, b) <= 0; - } - static bool Less(const Bignum& a, const Bignum& b) { - return Compare(a, b) < 0; - } - // Returns Compare(a + b, c); - static int PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c); - // Returns a + b == c - static bool PlusEqual(const Bignum& a, const Bignum& b, const Bignum& c) { - return PlusCompare(a, b, c) == 0; - } - // Returns a + b <= c - static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) { - return PlusCompare(a, b, c) <= 0; - } - // Returns a + b < c - static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) { - return PlusCompare(a, b, c) < 0; - } - - private: - typedef uint32_t Chunk; - typedef uint64_t DoubleChunk; - - static const int kChunkSize = sizeof(Chunk) * 8; - static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8; - // With bigit size of 28 we loose some bits, but a double still fits easily - // into two chunks, and more importantly we can use the Comba multiplication. - static const int kBigitSize = 28; - static const Chunk kBigitMask = (1 << kBigitSize) - 1; - // Every instance allocates kBigitLength chunks on the stack. Bignums cannot - // grow. There are no checks if the stack-allocated space is sufficient. - static const int kBigitCapacity = kMaxSignificantBits / kBigitSize; - - static void EnsureCapacity(const int size) { - if (size > kBigitCapacity) { - DOUBLE_CONVERSION_UNREACHABLE(); - } - } - void Align(const Bignum& other); - void Clamp(); - bool IsClamped() const { - return used_bigits_ == 0 || RawBigit(used_bigits_ - 1) != 0; - } - void Zero() { - used_bigits_ = 0; - exponent_ = 0; - } - // Requires this to have enough capacity (no tests done). - // Updates used_bigits_ if necessary. - // shift_amount must be < kBigitSize. - void BigitsShiftLeft(const int shift_amount); - // BigitLength includes the "hidden" bigits encoded in the exponent. - int BigitLength() const { return used_bigits_ + exponent_; } - Chunk& RawBigit(const int index); - const Chunk& RawBigit(const int index) const; - Chunk BigitOrZero(const int index) const; - void SubtractTimes(const Bignum& other, const int factor); - - // The Bignum's value is value(bigits_buffer_) * 2^(exponent_ * kBigitSize), - // where the value of the buffer consists of the lower kBigitSize bits of - // the first used_bigits_ Chunks in bigits_buffer_, first chunk has lowest - // significant bits. - int16_t used_bigits_; - int16_t exponent_; - Chunk bigits_buffer_[kBigitCapacity]; - - DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Bignum); -}; - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_BIGNUM_H_ diff --git a/third_party/double-conversion/diy-fp.h b/third_party/double-conversion/diy-fp.h deleted file mode 100644 index a7e64799..00000000 --- a/third_party/double-conversion/diy-fp.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef DOUBLE_CONVERSION_DIY_FP_H_ -#define DOUBLE_CONVERSION_DIY_FP_H_ - -#include "third_party/double-conversion/utils.h" - -namespace double_conversion { - -// This "Do It Yourself Floating Point" class implements a floating-point number -// with a uint64 significand and an int exponent. Normalized DiyFp numbers will -// have the most significant bit of the significand set. -// Multiplication and Subtraction do not normalize their results. -// DiyFp store only non-negative numbers and are not designed to contain special -// doubles (NaN and Infinity). -class DiyFp { - public: - static const int kSignificandSize = 64; - - DiyFp() : f_(0), e_(0) {} - DiyFp(const uint64_t significand, const int32_t exponent) - : f_(significand), e_(exponent) {} - - // this -= other. - // The exponents of both numbers must be the same and the significand of this - // must be greater or equal than the significand of other. - // The result will not be normalized. - void Subtract(const DiyFp& other) { - DOUBLE_CONVERSION_ASSERT(e_ == other.e_); - DOUBLE_CONVERSION_ASSERT(f_ >= other.f_); - f_ -= other.f_; - } - - // Returns a - b. - // The exponents of both numbers must be the same and a must be greater - // or equal than b. The result will not be normalized. - static DiyFp Minus(const DiyFp& a, const DiyFp& b) { - DiyFp result = a; - result.Subtract(b); - return result; - } - - // this *= other. - void Multiply(const DiyFp& other) { - // Simply "emulates" a 128 bit multiplication. - // However: the resulting number only contains 64 bits. The least - // significant 64 bits are only used for rounding the most significant 64 - // bits. - const uint64_t kM32 = 0xFFFFFFFFU; - const uint64_t a = f_ >> 32; - const uint64_t b = f_ & kM32; - const uint64_t c = other.f_ >> 32; - const uint64_t d = other.f_ & kM32; - const uint64_t ac = a * c; - const uint64_t bc = b * c; - const uint64_t ad = a * d; - const uint64_t bd = b * d; - // By adding 1U << 31 to tmp we round the final result. - // Halfway cases will be rounded up. - const uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32) + (1U << 31); - e_ += other.e_ + 64; - f_ = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); - } - - // returns a * b; - static DiyFp Times(const DiyFp& a, const DiyFp& b) { - DiyFp result = a; - result.Multiply(b); - return result; - } - - void Normalize() { - DOUBLE_CONVERSION_ASSERT(f_ != 0); - uint64_t significand = f_; - int32_t exponent = e_; - - // This method is mainly called for normalizing boundaries. In general, - // boundaries need to be shifted by 10 bits, and we optimize for this case. - const uint64_t k10MSBits = - DOUBLE_CONVERSION_UINT64_2PART_C(0xFFC00000, 00000000); - while ((significand & k10MSBits) == 0) { - significand <<= 10; - exponent -= 10; - } - while ((significand & kUint64MSB) == 0) { - significand <<= 1; - exponent--; - } - f_ = significand; - e_ = exponent; - } - - static DiyFp Normalize(const DiyFp& a) { - DiyFp result = a; - result.Normalize(); - return result; - } - - uint64_t f() const { return f_; } - int32_t e() const { return e_; } - - void set_f(uint64_t new_value) { f_ = new_value; } - void set_e(int32_t new_value) { e_ = new_value; } - - private: - static const uint64_t kUint64MSB = - DOUBLE_CONVERSION_UINT64_2PART_C(0x80000000, 00000000); - - uint64_t f_; - int32_t e_; -}; - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_DIY_FP_H_ diff --git a/third_party/double-conversion/double-conversion.mk b/third_party/double-conversion/double-conversion.mk deleted file mode 100644 index 6ab840fc..00000000 --- a/third_party/double-conversion/double-conversion.mk +++ /dev/null @@ -1,54 +0,0 @@ -#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ -#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ - -PKGS += THIRD_PARTY_DOUBLE_CONVERSION - -THIRD_PARTY_DOUBLE_CONVERSION_ARTIFACTS += THIRD_PARTY_DOUBLE_CONVERSION_A -THIRD_PARTY_DOUBLE_CONVERSION = $(THIRD_PARTY_DOUBLE_CONVERSION_A_DEPS) $(THIRD_PARTY_DOUBLE_CONVERSION_A) -THIRD_PARTY_DOUBLE_CONVERSION_A = o/$(MODE)/third_party/double-conversion/double-conversion.a -THIRD_PARTY_DOUBLE_CONVERSION_A_FILES := $(wildcard third_party/double-conversion/*) -THIRD_PARTY_DOUBLE_CONVERSION_A_HDRS = $(filter %.h,$(THIRD_PARTY_DOUBLE_CONVERSION_A_FILES)) -THIRD_PARTY_DOUBLE_CONVERSION_A_SRCS_CC = $(filter %.cc,$(THIRD_PARTY_DOUBLE_CONVERSION_A_FILES)) - -THIRD_PARTY_DOUBLE_CONVERSION_A_SRCS = \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A_SRCS_CC) - -THIRD_PARTY_DOUBLE_CONVERSION_A_OBJS = \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A_SRCS:%=o/$(MODE)/%.zip.o) \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A_SRCS_CC:%.cc=o/$(MODE)/%.o) - -THIRD_PARTY_DOUBLE_CONVERSION_A_CHECKS = \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A).pkg \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A_HDRS:%=o/$(MODE)/%.ok) - -THIRD_PARTY_DOUBLE_CONVERSION_A_DIRECTDEPS = \ - LIBC_STUBS - -THIRD_PARTY_DOUBLE_CONVERSION_A_DEPS := \ - $(call uniq,$(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_A_DIRECTDEPS),$($(x)))) - -$(THIRD_PARTY_DOUBLE_CONVERSION_A): \ - third_party/double-conversion/ \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A).pkg \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A_OBJS) - -$(THIRD_PARTY_DOUBLE_CONVERSION_A).pkg: \ - $(THIRD_PARTY_DOUBLE_CONVERSION_A_OBJS) \ - $(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_A_DIRECTDEPS),$($(x)_A).pkg) - -$(THIRD_PARTY_DOUBLE_CONVERSION_A_OBJS): \ - OVERRIDE_CXXFLAGS += \ - $(IEEE_MATH) \ - -fvisibility=hidden \ - -ffunction-sections \ - -fdata-sections - -THIRD_PARTY_DOUBLE_CONVERSION_LIBS = $(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_ARTIFACTS),$($(x))) -THIRD_PARTY_DOUBLE_CONVERSION_SRCS = $(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_ARTIFACTS),$($(x)_SRCS)) -THIRD_PARTY_DOUBLE_CONVERSION_HDRS = $(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_ARTIFACTS),$($(x)_HDRS)) -THIRD_PARTY_DOUBLE_CONVERSION_CHECKS = $(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_ARTIFACTS),$($(x)_CHECKS)) -THIRD_PARTY_DOUBLE_CONVERSION_OBJS = $(foreach x,$(THIRD_PARTY_DOUBLE_CONVERSION_ARTIFACTS),$($(x)_OBJS)) -$(THIRD_PARTY_DOUBLE_CONVERSION_OBJS): third_party/double-conversion/double-conversion.mk - -.PHONY: o/$(MODE)/third_party/double-conversion -o/$(MODE)/third_party/double-conversion: $(THIRD_PARTY_DOUBLE_CONVERSION_CHECKS) diff --git a/third_party/double-conversion/ieee.h b/third_party/double-conversion/ieee.h deleted file mode 100644 index c33742ff..00000000 --- a/third_party/double-conversion/ieee.h +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright 2012 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef DOUBLE_CONVERSION_DOUBLE_H_ -#define DOUBLE_CONVERSION_DOUBLE_H_ - -#include "third_party/double-conversion/diy-fp.h" - -namespace double_conversion { - -// We assume that doubles and uint64_t have the same endianness. -static uint64_t double_to_uint64(double d) { return BitCast(d); } -static double uint64_to_double(uint64_t d64) { return BitCast(d64); } -static uint32_t float_to_uint32(float f) { return BitCast(f); } -static float uint32_to_float(uint32_t d32) { return BitCast(d32); } - -// Helper functions for doubles. -class Double { - public: - static const uint64_t kSignMask = - DOUBLE_CONVERSION_UINT64_2PART_C(0x80000000, 00000000); - static const uint64_t kExponentMask = - DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000); - static const uint64_t kSignificandMask = - DOUBLE_CONVERSION_UINT64_2PART_C(0x000FFFFF, FFFFFFFF); - static const uint64_t kHiddenBit = - DOUBLE_CONVERSION_UINT64_2PART_C(0x00100000, 00000000); - static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit. - static const int kSignificandSize = 53; - static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; - static const int kMaxExponent = 0x7FF - kExponentBias; - - Double() : d64_(0) {} - explicit Double(double d) : d64_(double_to_uint64(d)) {} - explicit Double(uint64_t d64) : d64_(d64) {} - explicit Double(DiyFp diy_fp) : d64_(DiyFpToUint64(diy_fp)) {} - - // The value encoded by this Double must be greater or equal to +0.0. - // It must not be special (infinity, or NaN). - DiyFp AsDiyFp() const { - DOUBLE_CONVERSION_ASSERT(Sign() > 0); - DOUBLE_CONVERSION_ASSERT(!IsSpecial()); - return DiyFp(Significand(), Exponent()); - } - - // The value encoded by this Double must be strictly greater than 0. - DiyFp AsNormalizedDiyFp() const { - DOUBLE_CONVERSION_ASSERT(value() > 0.0); - uint64_t f = Significand(); - int e = Exponent(); - - // The current double could be a denormal. - while ((f & kHiddenBit) == 0) { - f <<= 1; - e--; - } - // Do the final shifts in one go. - f <<= DiyFp::kSignificandSize - kSignificandSize; - e -= DiyFp::kSignificandSize - kSignificandSize; - return DiyFp(f, e); - } - - // Returns the double's bit as uint64. - uint64_t AsUint64() const { return d64_; } - - // Returns the next greater double. Returns +infinity on input +infinity. - double NextDouble() const { - if (d64_ == kInfinity) return Double(kInfinity).value(); - if (Sign() < 0 && Significand() == 0) { - // -0.0 - return 0.0; - } - if (Sign() < 0) { - return Double(d64_ - 1).value(); - } else { - return Double(d64_ + 1).value(); - } - } - - double PreviousDouble() const { - if (d64_ == (kInfinity | kSignMask)) return -Infinity(); - if (Sign() < 0) { - return Double(d64_ + 1).value(); - } else { - if (Significand() == 0) return -0.0; - return Double(d64_ - 1).value(); - } - } - - int Exponent() const { - if (IsDenormal()) return kDenormalExponent; - - uint64_t d64 = AsUint64(); - int biased_e = - static_cast((d64 & kExponentMask) >> kPhysicalSignificandSize); - return biased_e - kExponentBias; - } - - uint64_t Significand() const { - uint64_t d64 = AsUint64(); - uint64_t significand = d64 & kSignificandMask; - if (!IsDenormal()) { - return significand + kHiddenBit; - } else { - return significand; - } - } - - // Returns true if the double is a denormal. - bool IsDenormal() const { - uint64_t d64 = AsUint64(); - return (d64 & kExponentMask) == 0; - } - - // We consider denormals not to be special. - // Hence only Infinity and NaN are special. - bool IsSpecial() const { - uint64_t d64 = AsUint64(); - return (d64 & kExponentMask) == kExponentMask; - } - - bool IsNan() const { - uint64_t d64 = AsUint64(); - return ((d64 & kExponentMask) == kExponentMask) && - ((d64 & kSignificandMask) != 0); - } - - bool IsInfinite() const { - uint64_t d64 = AsUint64(); - return ((d64 & kExponentMask) == kExponentMask) && - ((d64 & kSignificandMask) == 0); - } - - int Sign() const { - uint64_t d64 = AsUint64(); - return (d64 & kSignMask) == 0 ? 1 : -1; - } - - // Precondition: the value encoded by this Double must be greater or equal - // than +0.0. - DiyFp UpperBoundary() const { - DOUBLE_CONVERSION_ASSERT(Sign() > 0); - return DiyFp(Significand() * 2 + 1, Exponent() - 1); - } - - // Computes the two boundaries of this. - // The bigger boundary (m_plus) is normalized. The lower boundary has the same - // exponent as m_plus. - // Precondition: the value encoded by this Double must be greater than 0. - void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { - DOUBLE_CONVERSION_ASSERT(value() > 0.0); - DiyFp v = this->AsDiyFp(); - DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); - DiyFp m_minus; - if (LowerBoundaryIsCloser()) { - m_minus = DiyFp((v.f() << 2) - 1, v.e() - 2); - } else { - m_minus = DiyFp((v.f() << 1) - 1, v.e() - 1); - } - m_minus.set_f(m_minus.f() << (m_minus.e() - m_plus.e())); - m_minus.set_e(m_plus.e()); - *out_m_plus = m_plus; - *out_m_minus = m_minus; - } - - bool LowerBoundaryIsCloser() const { - // The boundary is closer if the significand is of the form f == 2^p-1 then - // the lower boundary is closer. - // Think of v = 1000e10 and v- = 9999e9. - // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but - // at a distance of 1e8. - // The only exception is for the smallest normal: the largest denormal is - // at the same distance as its successor. - // Note: denormals have the same exponent as the smallest normals. - bool physical_significand_is_zero = ((AsUint64() & kSignificandMask) == 0); - return physical_significand_is_zero && (Exponent() != kDenormalExponent); - } - - double value() const { return uint64_to_double(d64_); } - - // Returns the significand size for a given order of magnitude. - // If v = f*2^e with 2^p-1 <= f <= 2^p then p+e is v's order of magnitude. - // This function returns the number of significant binary digits v will have - // once it's encoded into a double. In almost all cases this is equal to - // kSignificandSize. The only exceptions are denormals. They start with - // leading zeroes and their effective significand-size is hence smaller. - static int SignificandSizeForOrderOfMagnitude(int order) { - if (order >= (kDenormalExponent + kSignificandSize)) { - return kSignificandSize; - } - if (order <= kDenormalExponent) return 0; - return order - kDenormalExponent; - } - - static double Infinity() { return Double(kInfinity).value(); } - - static double NaN() { return Double(kNaN).value(); } - - private: - static const int kDenormalExponent = -kExponentBias + 1; - static const uint64_t kInfinity = - DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000); - static const uint64_t kNaN = - DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF80000, 00000000); - - const uint64_t d64_; - - static uint64_t DiyFpToUint64(DiyFp diy_fp) { - uint64_t significand = diy_fp.f(); - int exponent = diy_fp.e(); - while (significand > kHiddenBit + kSignificandMask) { - significand >>= 1; - exponent++; - } - if (exponent >= kMaxExponent) { - return kInfinity; - } - if (exponent < kDenormalExponent) { - return 0; - } - while (exponent > kDenormalExponent && (significand & kHiddenBit) == 0) { - significand <<= 1; - exponent--; - } - uint64_t biased_exponent; - if (exponent == kDenormalExponent && (significand & kHiddenBit) == 0) { - biased_exponent = 0; - } else { - biased_exponent = static_cast(exponent + kExponentBias); - } - return (significand & kSignificandMask) | - (biased_exponent << kPhysicalSignificandSize); - } - - DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Double); -}; - -class Single { - public: - static const uint32_t kSignMask = 0x80000000; - static const uint32_t kExponentMask = 0x7F800000; - static const uint32_t kSignificandMask = 0x007FFFFF; - static const uint32_t kHiddenBit = 0x00800000; - static const int kPhysicalSignificandSize = 23; // Excludes the hidden bit. - static const int kSignificandSize = 24; - - Single() : d32_(0) {} - explicit Single(float f) : d32_(float_to_uint32(f)) {} - explicit Single(uint32_t d32) : d32_(d32) {} - - // The value encoded by this Single must be greater or equal to +0.0. - // It must not be special (infinity, or NaN). - DiyFp AsDiyFp() const { - DOUBLE_CONVERSION_ASSERT(Sign() > 0); - DOUBLE_CONVERSION_ASSERT(!IsSpecial()); - return DiyFp(Significand(), Exponent()); - } - - // Returns the single's bit as uint64. - uint32_t AsUint32() const { return d32_; } - - int Exponent() const { - if (IsDenormal()) return kDenormalExponent; - - uint32_t d32 = AsUint32(); - int biased_e = - static_cast((d32 & kExponentMask) >> kPhysicalSignificandSize); - return biased_e - kExponentBias; - } - - uint32_t Significand() const { - uint32_t d32 = AsUint32(); - uint32_t significand = d32 & kSignificandMask; - if (!IsDenormal()) { - return significand + kHiddenBit; - } else { - return significand; - } - } - - // Returns true if the single is a denormal. - bool IsDenormal() const { - uint32_t d32 = AsUint32(); - return (d32 & kExponentMask) == 0; - } - - // We consider denormals not to be special. - // Hence only Infinity and NaN are special. - bool IsSpecial() const { - uint32_t d32 = AsUint32(); - return (d32 & kExponentMask) == kExponentMask; - } - - bool IsNan() const { - uint32_t d32 = AsUint32(); - return ((d32 & kExponentMask) == kExponentMask) && - ((d32 & kSignificandMask) != 0); - } - - bool IsInfinite() const { - uint32_t d32 = AsUint32(); - return ((d32 & kExponentMask) == kExponentMask) && - ((d32 & kSignificandMask) == 0); - } - - int Sign() const { - uint32_t d32 = AsUint32(); - return (d32 & kSignMask) == 0 ? 1 : -1; - } - - // Computes the two boundaries of this. - // The bigger boundary (m_plus) is normalized. The lower boundary has the same - // exponent as m_plus. - // Precondition: the value encoded by this Single must be greater than 0. - void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { - DOUBLE_CONVERSION_ASSERT(value() > 0.0); - DiyFp v = this->AsDiyFp(); - DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); - DiyFp m_minus; - if (LowerBoundaryIsCloser()) { - m_minus = DiyFp((v.f() << 2) - 1, v.e() - 2); - } else { - m_minus = DiyFp((v.f() << 1) - 1, v.e() - 1); - } - m_minus.set_f(m_minus.f() << (m_minus.e() - m_plus.e())); - m_minus.set_e(m_plus.e()); - *out_m_plus = m_plus; - *out_m_minus = m_minus; - } - - // Precondition: the value encoded by this Single must be greater or equal - // than +0.0. - DiyFp UpperBoundary() const { - DOUBLE_CONVERSION_ASSERT(Sign() > 0); - return DiyFp(Significand() * 2 + 1, Exponent() - 1); - } - - bool LowerBoundaryIsCloser() const { - // The boundary is closer if the significand is of the form f == 2^p-1 then - // the lower boundary is closer. - // Think of v = 1000e10 and v- = 9999e9. - // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but - // at a distance of 1e8. - // The only exception is for the smallest normal: the largest denormal is - // at the same distance as its successor. - // Note: denormals have the same exponent as the smallest normals. - bool physical_significand_is_zero = ((AsUint32() & kSignificandMask) == 0); - return physical_significand_is_zero && (Exponent() != kDenormalExponent); - } - - float value() const { return uint32_to_float(d32_); } - - static float Infinity() { return Single(kInfinity).value(); } - - static float NaN() { return Single(kNaN).value(); } - - private: - static const int kExponentBias = 0x7F + kPhysicalSignificandSize; - static const int kDenormalExponent = -kExponentBias + 1; - static const int kMaxExponent = 0xFF - kExponentBias; - static const uint32_t kInfinity = 0x7F800000; - static const uint32_t kNaN = 0x7FC00000; - - const uint32_t d32_; - - DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Single); -}; - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_DOUBLE_H_ diff --git a/third_party/double-conversion/utils.h b/third_party/double-conversion/utils.h deleted file mode 100644 index 1255e561..00000000 --- a/third_party/double-conversion/utils.h +++ /dev/null @@ -1,308 +0,0 @@ -#ifndef DOUBLE_CONVERSION_UTILS_H_ -#define DOUBLE_CONVERSION_UTILS_H_ -#include "libc/assert.h" -#include "libc/mem/mem.h" -#include "libc/runtime/runtime.h" -#include "libc/str/str.h" - -#ifndef DOUBLE_CONVERSION_ASSERT -#define DOUBLE_CONVERSION_ASSERT(condition) assert(condition); -#endif -#ifndef DOUBLE_CONVERSION_UNIMPLEMENTED -#define DOUBLE_CONVERSION_UNIMPLEMENTED() (abort()) -#endif -#ifndef DOUBLE_CONVERSION_NO_RETURN -#ifdef _MSC_VER -#define DOUBLE_CONVERSION_NO_RETURN __declspec(noreturn) -#else -#define DOUBLE_CONVERSION_NO_RETURN __attribute__((noreturn)) -#endif -#endif -#ifndef DOUBLE_CONVERSION_UNREACHABLE -#ifdef _MSC_VER -void DOUBLE_CONVERSION_NO_RETURN abort_noreturn(); -inline void abort_noreturn() { abort(); } -#define DOUBLE_CONVERSION_UNREACHABLE() (abort_noreturn()) -#else -#define DOUBLE_CONVERSION_UNREACHABLE() (abort()) -#endif -#endif - -#ifndef DOUBLE_CONVERSION_UNUSED -#ifdef __GNUC__ -#define DOUBLE_CONVERSION_UNUSED __attribute__((unused)) -#else -#define DOUBLE_CONVERSION_UNUSED -#endif -#endif - -// Double operations detection based on target architecture. -// Linux uses a 80bit wide floating point stack on x86. This induces double -// rounding, which in turn leads to wrong results. -// An easy way to test if the floating-point operations are correct is to -// evaluate: 89255.0/1e22. If the floating-point stack is 64 bits wide then -// the result is equal to 89255e-22. -// The best way to test this, is to create a division-function and to compare -// the output of the division with the expected result. (Inlining must be -// disabled.) -// On Linux,x86 89255e-22 != Div_double(89255.0/1e22) -// -// For example: -/* -// -- in div.c -double Div_double(double x, double y) { return x / y; } - -// -- in main.c -double Div_double(double x, double y); // Forward declaration. - -int main(int argc, char** argv) { - return Div_double(89255.0, 1e22) == 89255e-22; -} -*/ -// Run as follows ./main || echo "correct" -// -// If it prints "correct" then the architecture should be here, in the "correct" -// section. -#if defined(_M_X64) || defined(__x86_64__) || defined(__ARMEL__) || \ - defined(__avr32__) || defined(_M_ARM) || defined(_M_ARM64) || \ - defined(__hppa__) || defined(__ia64__) || defined(__mips__) || \ - defined(__nios2__) || defined(__powerpc__) || defined(__ppc__) || \ - defined(__ppc64__) || defined(_POWER) || defined(_ARCH_PPC) || \ - defined(_ARCH_PPC64) || defined(__sparc__) || defined(__sparc) || \ - defined(__s390__) || defined(__SH4__) || defined(__alpha__) || \ - defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) || \ - defined(__AARCH64EL__) || defined(__aarch64__) || \ - defined(__AARCH64EB__) || defined(__riscv) || defined(__e2k__) || \ - defined(__or1k__) || defined(__arc__) || defined(__microblaze__) || \ - defined(__XTENSA__) || defined(__EMSCRIPTEN__) || defined(__wasm32__) -#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 -#elif defined(__mc68000__) || defined(__pnacl__) || defined(__native_client__) -#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS -#elif defined(_M_IX86) || defined(__i386__) || defined(__i386) -#if defined(_WIN32) -// Windows uses a 64bit wide floating point stack. -#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 -#else -#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS -#endif // _WIN32 -#else -#error Target architecture was not detected as supported by Double-Conversion. -#endif - -typedef uint16_t uc16; - -// The following macro works on both 32 and 64-bit platforms. -// Usage: instead of writing 0x1234567890123456 -// write DOUBLE_CONVERSION_UINT64_2PART_C(0x12345678,90123456); -#define DOUBLE_CONVERSION_UINT64_2PART_C(a, b) \ - (((static_cast(a) << 32) + 0x##b##u)) - -// The expression DOUBLE_CONVERSION_ARRAY_SIZE(a) is a compile-time constant of -// type size_t which represents the number of elements of the given array. You -// should only use DOUBLE_CONVERSION_ARRAY_SIZE on statically allocated arrays. -#ifndef DOUBLE_CONVERSION_ARRAY_SIZE -#define DOUBLE_CONVERSION_ARRAY_SIZE(a) \ - ((sizeof(a) / sizeof(*(a))) / \ - static_cast(!(sizeof(a) % sizeof(*(a))))) -#endif - -// A macro to disallow the evil copy constructor and operator= functions -// This should be used in the private: declarations for a class -#ifndef DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN -#define DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) -#endif - -// A macro to disallow all the implicit constructors, namely the -// default constructor, copy constructor and operator= functions. -// -// This should be used in the private: declarations for a class -// that wants to prevent anyone from instantiating it. This is -// especially useful for classes containing only static methods. -#ifndef DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS -#define DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName(); \ - DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName) -#endif - -namespace double_conversion { - -inline int StrLength(const char* string) { - size_t length = strlen(string); - DOUBLE_CONVERSION_ASSERT(length == - static_cast(static_cast(length))); - return static_cast(length); -} - -// This is a simplified version of V8's Vector class. -template -class Vector { - public: - Vector() : start_(NULL), length_(0) {} - Vector(T* data, int len) : start_(data), length_(len) { - DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL)); - } - - // Returns a vector using the same backing storage as this one, - // spanning from and including 'from', to but not including 'to'. - Vector SubVector(int from, int to) { - DOUBLE_CONVERSION_ASSERT(to <= length_); - DOUBLE_CONVERSION_ASSERT(from < to); - DOUBLE_CONVERSION_ASSERT(0 <= from); - return Vector(start() + from, to - from); - } - - // Returns the length of the vector. - int length() const { return length_; } - - // Returns whether or not the vector is empty. - bool is_empty() const { return length_ == 0; } - - // Returns the pointer to the start of the data in the vector. - T* start() const { return start_; } - - // Access individual vector elements - checks bounds in debug mode. - T& operator[](int index) const { - DOUBLE_CONVERSION_ASSERT(0 <= index && index < length_); - return start_[index]; - } - - T& first() { return start_[0]; } - - T& last() { return start_[length_ - 1]; } - - void pop_back() { - DOUBLE_CONVERSION_ASSERT(!is_empty()); - --length_; - } - - private: - T* start_; - int length_; -}; - -// Helper class for building result strings in a character buffer. The -// purpose of the class is to use safe operations that checks the -// buffer bounds on all operations in debug mode. -class StringBuilder { - public: - StringBuilder(char* buffer, int buffer_size) - : buffer_(buffer, buffer_size), position_(0) {} - - ~StringBuilder() { - if (!is_finalized()) Finalize(); - } - - int size() const { return buffer_.length(); } - - // Get the current position in the builder. - int position() const { - DOUBLE_CONVERSION_ASSERT(!is_finalized()); - return position_; - } - - // Reset the position. - void Reset() { position_ = 0; } - - // Add a single character to the builder. It is not allowed to add - // 0-characters; use the Finalize() method to terminate the string - // instead. - void AddCharacter(char c) { - DOUBLE_CONVERSION_ASSERT(c != '\0'); - DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ < buffer_.length()); - buffer_[position_++] = c; - } - - // Add an entire string to the builder. Uses strlen() internally to - // compute the length of the input string. - void AddString(const char* s) { AddSubstring(s, StrLength(s)); } - - // Add the first 'n' characters of the given string 's' to the - // builder. The input string must have enough characters. - void AddSubstring(const char* s, int n) { - DOUBLE_CONVERSION_ASSERT(!is_finalized() && - position_ + n < buffer_.length()); - DOUBLE_CONVERSION_ASSERT(static_cast(n) <= strlen(s)); - __builtin_memmove(&buffer_[position_], s, n); - position_ += n; - } - - // Add character padding to the builder. If count is non-positive, - // nothing is added to the builder. - void AddPadding(char c, int count) { - for (int i = 0; i < count; i++) { - AddCharacter(c); - } - } - - // Finalize the string by 0-terminating it and returning the buffer. - char* Finalize() { - DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ < buffer_.length()); - buffer_[position_] = '\0'; - // Make sure nobody managed to add a 0-character to the - // buffer while building the string. - DOUBLE_CONVERSION_ASSERT(strlen(buffer_.start()) == - static_cast(position_)); - position_ = -1; - DOUBLE_CONVERSION_ASSERT(is_finalized()); - return buffer_.start(); - } - - private: - Vector buffer_; - int position_; - - bool is_finalized() const { return position_ < 0; } - - DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); -}; - -// The type-based aliasing rule allows the compiler to assume that pointers of -// different types (for some definition of different) never alias each other. -// Thus the following code does not work: -// -// float f = foo(); -// int fbits = *(int*)(&f); -// -// The compiler 'knows' that the int pointer can't refer to f since the types -// don't match, so the compiler may cache f in a register, leaving random data -// in fbits. Using C++ style casts makes no difference, however a pointer to -// char data is assumed to alias any other pointer. This is the 'memcpy -// exception'. -// -// Bit_cast uses the memcpy exception to move the bits from a variable of one -// type of a variable of another type. Of course the end result is likely to -// be implementation dependent. Most compilers (gcc-4.2 and MSVC 2005) -// will completely optimize BitCast away. -// -// There is an additional use for BitCast. -// Recent gccs will warn when they see casts that may result in breakage due to -// the type-based aliasing rule. If you have checked that there is no breakage -// you can use BitCast to cast one pointer type to another. This confuses gcc -// enough that it can no longer see that you have cast one pointer type to -// another thus avoiding the warning. -template -Dest BitCast(const Source& source) { - // Compile time assertion: sizeof(Dest) == sizeof(Source) - // A compile error here means your Dest and Source have different sizes. -#if __cplusplus >= 201103L - static_assert(sizeof(Dest) == sizeof(Source)); -#else - DOUBLE_CONVERSION_UNUSED - typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1]; -#endif - - Dest dest; - memmove(&dest, &source, sizeof(dest)); - return dest; -} - -template -Dest BitCast(Source* source) { - return BitCast(reinterpret_cast(source)); -} - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_UTILS_H_ diff --git a/third_party/editline/ChangeLog.md b/third_party/editline/ChangeLog.md deleted file mode 100644 index b2a0be66..00000000 --- a/third_party/editline/ChangeLog.md +++ /dev/null @@ -1,248 +0,0 @@ -Change Log -========== - -All notable changes to the project are documented in this file. - - -[1.16.1] - 2019-06-07 ---------------------- - -### Changes -- Major updates to the `editline.3` man page -- Cleanup of examples `cli.c` and `fileman.c` -- Add example of hidden input prompt to `cli.c` - -### Fixes -- Fix #20: `configure --disable-eof` does not bite -- Fix #23: Make Ctrl-L clear the screan instead of starting a new line - Like Ctrl-D, which exits, Ctrl-L only clears the screen when the line - is empty and the cursor is at the start of the line, otherwise Ctrl-L - will redraw/refresh the current line. -- Fix #24: Fix behavior when TTY is narrower than column width, by Will Dietz -- Fix #25: Avoid continuously duplicate commands in history -- Fix #31: Aborting i-search with Ctrl-C should not generate signal - - -[1.16.0][] - 2018-09-16 ------------------------ - -Event loop callback support. - -### Changes -- `rl_unintialize()`, new function to free all memory, by Claus Fischer -- `rl_insert_text()`, new GNU Readline compat function -- `rl_refresh_line()`, new GNU Readline compat function -- `rl_callback_*()`, alternate interface to plain `readline()` for event - loops. Modeled after the GNU Readline API -- `rl_completion_entry_function`, and `rl_attempted_completion_function` - are two new GNU Readline compat user hooks for the completion framework -- `rl_completion_matches()` and `rl_filename_completion_function()` - are two new GNU Readline compat functions -- Add new example: `fileman.c` from GNU Readline to demonstrate the - level of compatibility of the revamped completion framework -- Add support for Ctrl-Right and Ctrl-Left, forward/backward word -- Add .deb package to official release target - -### Fixes -- Fixed header guards, avoid using leading `__` -- Spell check fixes -- Remove duplicate code in history check -- Use `NULL` instead of `0`, and `-1` instead of `NULL`, where applicable -- Misc. minor Coverity Scan fixes -- Misc. minor fixes to `testit.c` example code -- Add `-Wextra` to std `CFLAGS` -- Check `fclose()` return value in in `write_history()` and `read_history()` -- Initialize global variables and reset to `NULL` on `free()` -- Fix off-by-one in forward kill word, avoid deleting too much -- Skip (or kill) leading whitespace when skipping (or killing) forwards - - -[1.15.3][] - 2017-09-07 ------------------------ - -Bug fix release. - -### Changes -- Refactor all enable/disable configure options, same problem as in #7 - -### Fixes -- Fix #7: `--enable-termcap` configure option does not work. The script - enabled termcap by default rather than the other way around. - - Also, check for terminfo as well, when `--enable-termcap` is selected. - - -[1.15.2][] - 2016-06-06 ------------------------ - -Bug fixes and minor feature creep in `pkg-config` support. - -### Changes -- Prevent mangling of symbols when linking with C++. Patch courtesy of - Jakub Pawlowski -- Add `libeditline.pc` for `pkg-config` - -### Fixes -- Do not assume a termcap library exists, check for `tgetent()` in - curses, ncurses, tinfo and termcap libraries -- Call `tty_flush()` when user calls `rl_forced_update_display()` - to prevent screen becoming garbled. Patch by Jakub Pawlowski - - -[1.15.1][] - 2015-11-16 ------------------------ - -Bug fixes only. - -### Changes -- Update README with origin of this version of editline - -### Fixes -- Fix build system, don't force automake v1.11, require at least v1.11 -- Fix build problem with examples using `--enable-termcap` - - -[1.15.0][] - 2015-09-10 ------------------------ - -### Changes -- Add support for `--disable-eof` and `--disable-sigint` to disable - default Ctrl-D and Ctrl-C behavior -- Add support for `el_no_hist` to disable access to and auto-save of history -- GNU readline compat functions for prompt handling and redisplay -- Refactor: replace variables named 'new' with non-reserved word -- Add support for [Travis-CI][], continuous integration with GitHub -- Add support for [Coverity Scan][], the best static code analyzer, - integrated with [Travis-CI][] -- scan runs for each push to master -- Rename NEWS.md --> ChangeLog.md, with symlinks for make install -- Attempt to align with http://keepachangelog.com/ for this file -- Cleanup and improve Markdown syntax in [README.md][] -- Add API and example to [README.md][], inspired by [libuEv][] -- Removed generated files from version control. Use `./autogen.sh` - to generate the `configure` script when working from GIT. This - does not affect distributed tarballs - -### Fixes -- Fix issue #2, regression in Ctrl-D (EOF) behavior. Regression - introduced in [1.14.1][]. Fixed by @TobyGoodwin -- Fix memory leak in completion handler. Found by [Coverity Scan][]. -- Fix suspicious use of `sizeof(char **)`, same as `sizeof(char *)` but - non-portable. Found by [Coverity Scan][] -- Fix out-of-bounds access in user key binding routines - Found by [Coverity Scan][]. -- Fix invisible example code in man page - - -[1.14.2][] - 2014-09-14 ------------------------ - -Bug fixes only. - -### Fixes - - Fix `el_no_echo` bug causing secrets to leak when disabling no-echo - - Handle `EINTR` in syscalls better - - -[1.14.1][] - 2014-09-14 ------------------------ - -Minor fixes and additions. - -### Changes -- Don't print status message on `stderr` in key binding funcions -- Export `el_del_char()` -- Check for and return pending signals when detected -- Allow custom key bindings ... - -### Fixes -- Bug fixes ... - - -[1.14.0][] - 2010-08-10 ------------------------ - -Major cleanups and further merges with Debian editline package. - -### Changes -- Merge in changes to `debian/` from `editline_1.12-6.debian.tar.gz` -- Migrate to use libtool -- Make `UNIQUE_HISTORY` configurable -- Make scrollback history (`HIST_SIZE`) configurable -- Configure options for toggling terminal bell and `SIGSTOP` (Ctrl-Z) -- Configure option for using termcap to read/control terminal size -- Rename Signal to `el_intr_pending`, from Festival speech-tools -- Merge support for capitalizing words (`M-c`) from Festival - speech-tools by Alan W Black -- Fallback backspace handling, in case `tgetstr("le")` fails - -### Fixes -- Cleanups and fixes thanks to the Sparse static code analysis tool -- Merge `el_no_echo` patch from Festival speech-tools -- Merge fixes from Heimdal project -- Completely refactor `rl_complete()` and `rl_list_possib()` with - fixes from the Heimdal project. Use `rl_set_complete_func()` and - `rl_set_list_possib_func()`. Default completion callbacks are now - available as a configure option `--enable-default-complete` -- Memory leak fixes -- Actually fix 8-bit handling by reverting old Debian patch -- Merge patch to improve compatibility with GNU readline, thanks to - Steve Tell from way back in 1997 and 1998 - - -[1.13.0][] - 2010-03-09 ------------------------ - -Adaptations to Debian editline package. - -### Changes -- Major version number bump, adapt to Jim Studt's v1.12 -- Import `debian/` directory and adapt it to configure et al. -- Change library name to libeditline to distinguish it from BSD libedit - - -[0.3.0][] - 2009-02-08 ----------------------- - -### Changes -- Support for ANSI arrow keys using configure --enable-arrow-keys - - -[0.2.3][] - 2008-12-02 ----------------------- - -### Changes -- Patches from Debian package merged -- Support for custom command completion - - -[0.1.0][] - 2008-06-07 ----------------------- - -### Changes -- First version, forked from Minix current 2008-06-06 - - -[UNRELEASED]: https://github.com/troglobit/finit/compare/1.16.0...HEAD -[1.16.1]: https://github.com/troglobit/finit/compare/1.16.0...1.16.1 -[1.16.0]: https://github.com/troglobit/finit/compare/1.15.3...1.16.0 -[1.15.3]: https://github.com/troglobit/finit/compare/1.15.2...1.15.3 -[1.15.2]: https://github.com/troglobit/finit/compare/1.15.1...1.15.2 -[1.15.1]: https://github.com/troglobit/finit/compare/1.15.0...1.15.1 -[1.15.0]: https://github.com/troglobit/finit/compare/1.14.2...1.15.0 -[1.14.2]: https://github.com/troglobit/finit/compare/1.14.1...1.14.2 -[1.14.1]: https://github.com/troglobit/finit/compare/1.14.0...1.14.1 -[1.14.0]: https://github.com/troglobit/finit/compare/1.13.0...1.14.0 -[1.13.0]: https://github.com/troglobit/finit/compare/0.3.0...1.13.0 -[0.3.0]: https://github.com/troglobit/finit/compare/0.2.3...0.3.0 -[0.2.3]: https://github.com/troglobit/finit/compare/0.1.0...0.2.3 -[0.1.0]: https://github.com/troglobit/finit/compare/0.0.0...0.1.0 -[libuEv]: http://github.com/troglobit/libuev -[Travis-CI]: https://travis-ci.org/troglobit/uftpd -[Coverity Scan]: https://scan.coverity.com/projects/2947 -[README.md]: https://github.com/troglobit/editline/blob/master/README.md - - diff --git a/third_party/editline/LICENSE b/third_party/editline/LICENSE deleted file mode 100644 index 1c0d909d..00000000 --- a/third_party/editline/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ - Copyright 1992,1993 Simmule Turner and Rich Salz - All rights reserved. - - This software is not subject to any license of the American Telephone - and Telegraph Company or of the Regents of the University of California. - - Permission is granted to anyone to use this software for any purpose on - any computer system, and to alter it and redistribute it freely, subject - to the following restrictions: - 1. The authors are not responsible for the consequences of use of this - software, no matter how awful, even if they arise from flaws in it. - 2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. Since few users ever read sources, - credits must appear in the documentation. - 3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. Since few users - ever read sources, credits must appear in the documentation. - 4. This notice may not be removed or altered. diff --git a/third_party/editline/complete.c b/third_party/editline/complete.c deleted file mode 100644 index 54aafb6e..00000000 --- a/third_party/editline/complete.c +++ /dev/null @@ -1,362 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ 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; version 2 of the License. │ -│ │ -│ 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 │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/alg/alg.h" -#include "libc/calls/calls.h" -#include "libc/calls/struct/dirent.h" -#include "libc/fmt/fmt.h" -#include "libc/mem/mem.h" -#include "libc/str/str.h" -#include "third_party/editline/editline.h" -#include "third_party/editline/internal.h" - -asm(".ident\t\"\\n\\n\ -Cosmopolitan Linenoise (BSD-like license)\\n\ -Copyright 2019 Justine Alexandra Roberts Tunney\\n\ -Copyright 1992,1993 Simmule Turner and Rich Salz\\n\ -All rights reserved.\\n\ -\\n\ -This software is not subject to any license of the American Telephone\\n\ -and Telegraph Company or of the Regents of the University of California.\\n\ -\\n\ -Permission is granted to anyone to use this software for any purpose on\\n\ -any computer system, and to alter it and redistribute it freely, subject\\n\ -to the following restrictions:\\n\ -1. The authors are not responsible for the consequences of use of this\\n\ - software, no matter how awful, even if they arise from flaws in it.\\n\ -2. The origin of this software must not be misrepresented, either by\\n\ - explicit claim or by omission. Since few users ever read sources,\\n\ - credits must appear in the documentation.\\n\ -3. Altered versions must be plainly marked as such, and must not be\\n\ - misrepresented as being the original software. Since few users\\n\ - ever read sources, credits must appear in the documentation.\\n\ -4. This notice may not be removed or altered.\""); -asm(".include \"libc/disclaimer.inc\""); - -#define MAX_TOTAL_MATCHES (256 << sizeof(char *)) - -int rl_attempted_completion_over = 0; -rl_completion_func_t *rl_attempted_completion_function = NULL; -rl_compentry_func_t *rl_completion_entry_function = NULL; - -/* Wrap strcmp() for qsort() -- weird construct to pass -Wcast-qual */ -static int compare(const void *p1, const void *p2) { - char *const *v1 = (char *const *)p1; - char *const *v2 = (char *const *)p2; - return strcmp(*v1, *v2); -} - -/* Fill in *avp with an array of names that match file, up to its length. - * Ignore . and .. . */ -static int FindMatches(char *dir, char *file, char ***avp) { - char **av; - char **word; - char *p; - DIR *dp; - struct dirent *ep; - size_t ac; - size_t len; - size_t choices; - size_t total; - if ((dp = opendir(dir)) == NULL) return 0; - av = NULL; - ac = 0; - len = strlen(file); - choices = 0; - total = 0; - while ((ep = readdir(dp)) != NULL) { - p = ep->d_name; - if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0'))) - continue; - if (len && strncmp(p, file, len) != 0) continue; - choices++; - if ((total += strlen(p)) > MAX_TOTAL_MATCHES) { - /* This is a bit too much. */ - while (ac > 0) free(av[--ac]); - continue; - } - if ((ac % MEM_INC) == 0) { - word = malloc(sizeof(char *) * (ac + MEM_INC)); - if (!word) { - total = 0; - break; - } - if (ac) { - memcpy(word, av, ac * sizeof(char *)); - free(av); - } - *avp = av = word; - } - if ((av[ac] = strdup(p)) == NULL) { - if (ac == 0) free(av); - total = 0; - break; - } - ac++; - } - /* Clean up and return. */ - closedir(dp); - if (total > MAX_TOTAL_MATCHES) { - char many[sizeof(total) * 3]; - p = many + sizeof(many); - *--p = '\0'; - while (choices > 0) { - *--p = '0' + choices % 10; - choices /= 10; - } - while (p > many + sizeof(many) - 8) *--p = ' '; - if ((p = strdup(p)) != NULL) av[ac++] = p; - if ((p = strdup("choices")) != NULL) av[ac++] = p; - } else { - if (ac) qsort(av, ac, sizeof(char *), compare); - } - return ac; -} - -/* Split a pathname into allocated directory and trailing filename parts. */ -static int SplitPath(const char *path, char **dirpart, char **filepart) { - static char DOT[] = "."; - char *dpart; - char *fpart; - if ((fpart = strrchr(path, '/')) == NULL) { - if ((dpart = strdup(DOT)) == NULL) return -1; - if ((fpart = strdup(path)) == NULL) { - free(dpart); - return -1; - } - } else { - if ((dpart = strdup(path)) == NULL) return -1; - dpart[fpart - path + 1] = '\0'; - if ((fpart = strdup(fpart + 1)) == NULL) { - free(dpart); - return -1; - } - } - *dirpart = dpart; - *filepart = fpart; - return 0; -} - -static rl_complete_func_t *el_complete_func = NULL; - -/* For compatibility with the Heimdal project. */ -rl_complete_func_t *rl_set_complete_func(rl_complete_func_t *func) { - rl_complete_func_t *old = el_complete_func; - el_complete_func = func; - return old; -} - -/* Attempt to complete the pathname, returning an allocated copy. - * Fill in *match if we completed it, or set it to 0 if ambiguous. */ -char *el_filename_complete(char *pathname, int *match) { - char **av; - char *dir; - char *file; - char *path; - char *p; - size_t ac; - size_t end; - size_t i; - size_t j; - size_t len; - if (SplitPath((const char *)pathname, &dir, &file) < 0) return NULL; - if ((ac = FindMatches(dir, file, &av)) == 0) { - free(dir); - free(file); - return NULL; - } - p = NULL; - len = strlen(file); - if (ac == 1) { - /* Exactly one match -- finish it off. */ - *match = 1; - j = strlen(av[0]) - len + 2; - p = malloc(sizeof(char) * (j + 1)); - if (p) { - memcpy(p, av[0] + len, j); - len = strlen(dir) + strlen(av[0]) + 2; - path = malloc(sizeof(char) * len); - if (path) { - snprintf(path, len, "%s/%s", dir, av[0]); - rl_add_slash(path, p); - free(path); - } - } - } else { - *match = 0; - if (len) { - /* Find largest matching substring. */ - for (i = len, end = strlen(av[0]); i < end; i++) { - for (j = 1; j < ac; j++) { - if (av[0][i] != av[j][i]) goto breakout; - } - } - breakout: - if (i > len) { - j = i - len + 1; - p = malloc(sizeof(char) * j); - if (p) { - memcpy(p, av[0] + len, j); - p[j - 1] = '\0'; - } - } - } - } - /* Clean up and return. */ - free(dir); - free(file); - for (i = 0; i < ac; i++) free(av[i]); - free(av); - return p; -} - -char *rl_filename_completion_function(const char *text, int state) { - char *dir; - char *file; - static char **av; - static size_t i, ac; - if (!state) { - if (SplitPath(text, &dir, &file) < 0) return NULL; - ac = FindMatches(dir, file, &av); - free(dir); - free(file); - if (!ac) return NULL; - i = 0; - } - if (i < ac) return av[i++]; - do { - free(av[--i]); - } while (i > 0); - return NULL; -} - -/* Similar to el_find_word(), but used by GNU Readline API */ -static char *rl_find_token(size_t *len) { - char *ptr; - int pos; - for (pos = rl_point; pos < rl_end; pos++) { - if (isspace(rl_line_buffer[pos])) { - if (pos > 0) pos--; - break; - } - } - ptr = &rl_line_buffer[pos]; - while (pos >= 0 && !isspace(rl_line_buffer[pos])) { - if (pos == 0) break; - pos--; - } - if (ptr != &rl_line_buffer[pos]) { - *len = (size_t)(ptr - &rl_line_buffer[pos]); - return &rl_line_buffer[pos]; - } - return NULL; -} - -/* - * "uses an application-supplied generator function to generate the list - * of possible matches, and then returns the array of these matches. The - * caller should place the address of its generator function in - * rl_completion_entry_function" - */ -char **rl_completion_matches(const char *token, - rl_compentry_func_t *generator) { - int state = 0, num = 0; - char **array, *entry; - if (!generator) { - generator = rl_completion_entry_function; - if (!generator) generator = rl_filename_completion_function; - } - if (!generator) return NULL; - array = malloc(512 * sizeof(char *)); - if (!array) return NULL; - while (num < 511 && (entry = generator(token, state))) { - state = 1; - array[num++] = entry; - } - array[num] = NULL; - if (!num) { - free(array); - return NULL; - } - return array; -} - -static char *complete(char *token, int *match) { - size_t len = 0; - char *word, **words = NULL; - int start, end; - word = rl_find_token(&len); - if (!word) goto fallback; - start = word - rl_line_buffer; - end = start + len; - word = strndup(word, len); - if (!word) goto fallback; - rl_attempted_completion_over = 0; - words = rl_attempted_completion_function(word, start, end); - if (!rl_attempted_completion_over && !words) - words = rl_completion_matches(word, NULL); - if (words) { - int i = 0; - free(word); - word = NULL; - if (words[0]) word = strdup(words[0] + len); - while (words[i]) free(words[i++]); - free(words); - if (word) return word; - } -fallback: - return el_filename_complete(token, match); -} - -/* - * First check for editline specific custom completion function, then - * for any GNU Readline compat, then fallback to filename completion. - */ -char *rl_complete(char *token, int *match) { - if (el_complete_func) return el_complete_func(token, match); - if (rl_attempted_completion_function) return complete(token, match); - return el_filename_complete(token, match); -} - -static rl_list_possib_func_t *el_list_possib_func = NULL; - -/* For compatibility with the Heimdal project. */ -rl_list_possib_func_t *rl_set_list_possib_func(rl_list_possib_func_t *func) { - rl_list_possib_func_t *old = el_list_possib_func; - el_list_possib_func = func; - return old; -} - -/* Default possible completions. */ -int el_filename_list_possib(char *pathname, char ***av) { - char *dir; - char *file; - int ac; - if (SplitPath(pathname, &dir, &file) < 0) return 0; - ac = FindMatches(dir, file, av); - free(dir); - free(file); - return ac; -} - -/* Return all possible completions. */ -int rl_list_possib(char *token, char ***av) { - if (el_list_possib_func) return el_list_possib_func(token, av); - return el_filename_list_possib(token, av); -} diff --git a/third_party/editline/editline.3 b/third_party/editline/editline.3 deleted file mode 100644 index b062c429..00000000 --- a/third_party/editline/editline.3 +++ /dev/null @@ -1,274 +0,0 @@ -.Dd April 27, 2019 -.Dt "THIRD_PARTY_EDITLINE" 30 "Cosmopolitan Field Manual" -.Os COSMOPOLITAN -.Sh NAME -.Nm "THIRD_PARTY_EDITLINE" -.Nd command-line editing library with history -.Sh SYNOPSIS -.Pp -.Sy #include "third_party/editline/editline.h" -.Pp -.Fn "char *readline" "const char *prompt" -.Fn "void add_history" "const char *line" -.Fn "int read_history" "const char *filename" -.Fn "int write_history" "const char *filename" -.Sh DESCRIPTION -.Nm -is a library that provides n line-editing interface with history. It -is intended to be functionally equivalent with the -.Nm readline -library provided by the Free Software Foundation, but much smaller. The -bulk of this manual page describes the basic user interface. More APIs, -both native and for -.Nm readline -compatibility , -are also available. See the -.Cm editline.h -header file for details. -.Pp -The -.Fn readline -function displays the given -.Fa prompt -on stdout, waits for user input on stdin and then returns a line of text -with the trailing newline removed. The data is returned in a buffer -allocated with -.Xr malloc 3 , -so the space should be released with -.Xr free 3 -when the calling program is done with it. -.Pp -Each line returned is automatically saved in the internal history list, -unless it happens to be equal to the previous line. This is -configurable if you are building editline from source, i.e. if you would -rather like to call -.Fn add_history -manually. -.Pp -The -.Fn read_history -and -.Fn write_history -functions can be used to load and store the history of your application. -.Em Note: -these APIs do not do any tilde or environment variable expansion of the -given filename. -.Ss User Interface -A program that uses this library provides a simple emacs-like editing -interface to its users. A line may be edited before it is sent to the -calling program by typing either control characters or escape sequences. -A control character, shown as a caret followed by a letter, is typed by -holding down the control key while the letter is typed. For example, -.Cm ^A -is a control-A. An escape sequence is entered by typing the escape key -followed by one or more characters. The escape key is abbreviated as -.Cm ESC . -Note that unlike control keys, case matters in escape sequences; -.Cm ESC F -is not the same as -.Cm ESC f . -.Pp -An editing command may be typed anywhere on the line, not just at the -beginning. In addition, a return may also be typed anywhere on the -line, not just at the end. -.Pp -Most editing commands may be given a repeat count, -.Ar n , -where -.Ar n -is a number. To enter a repeat count, type the escape key, the number, -and then the command to execute. For example, -.Cm ESC 4 ^f -moves forward four characters. If a command may be given a repeat count -then the text -.Cm [n] -is given at the end of its description. -.Pp -The following control characters are accepted: -.Pp -.Bl -tag -width "ESC DEL " -compact -.It ^A -Move to the beginning of the line -.It ^B -Move left (backwards) [n] -.It ^D -Delete character [n] -.It ^E -Move to end of line -.It ^F -Move right (forwards) [n] -.It ^G -Ring the bell -.It ^H -Delete character before cursor (backspace key) [n] -.It ^I -Complete filename (tab key); see below -.It ^J -Done with line (return key) -.It ^K -Kill to end of line (or column [n]) -.It ^L -Redisplay line -.It ^M -Done with line (alternate return key) -.It ^N -Get next line from history [n] -.It ^P -Get previous line from history [n] -.It ^R -Search backward (forward if [n]) through history for text; prefixing the -string with a caret (^) forces it to match only at the beginning of a -history line -.It ^T -Transpose characters -.It ^V -Insert next character, even if it is an edit command -.It ^W -Wipe to the mark -.It ^X^X -Exchange current location and mark -.It ^Y -Yank back last killed text -.It ^[ -Start an escape sequence (escape key) -.It ^]c -Move forward to next character -.Cm c -.It ^? -Delete character before cursor (delete key) [n] -.Ed -.Pp -The following escape sequences are provided: -.Pp -.Bl -tag -width "ESC DEL " -compact -.It ESC ^H -Delete previous word (backspace key) [n] -.It ESC DEL -Delete previous word (delete key) [n] -.It ESC SP -Set the mark (space key); see ^X^X and ^Y above -.It ESC\ . -Get the last (or [n]'th) word from previous line -.It ESC\ ? -Show possible completions; see below -.It ESC < -Move to start of history -.It ESC > -Move to end of history -.It ESC b -Move backward a word [n] -.It ESC d -Delete word under cursor [n] -.It ESC f -Move forward a word [n] -.It ESC l -Make word lowercase [n] -.It ESC m -Toggle if 8bit chars display normally or with an -.Ar M- -prefix -.It ESC u -Make word uppercase [n] -.It ESC y -Yank back last killed text -.It ESC v -Show library version -.It ESC w -Make area up to mark yankable -.It ESC nn -Set repeat count to the number nn -.It ESC C -Read from environment variable -.Ar $C , -where -.Ar C -is an uppercase letter -.El -.Pp -The -.Nm -library has a small macro facility. If you type the escape key followed -by an uppercase letter, -.Ar C , -then the contents of the environment variable -.Ar $C -are read in as if you had typed them at the keyboard. For example, if -the variable -.Ar $L -contains the following: -.Pp -.Dl ^A^Kecho '^V^[[H^V^[[2J'^M -.Pp -Then typing -.Cm ESC L -will move to the beginning of the line, kill the entire line, enter the -echo command needed to clear the terminal (if your terminal is like a -VT-100), and send the line back to the shell. -.Pp -The -.Nm -library also does filename completion. Suppose the root directory has -the following files in it: -.Pp -.Dl bin vmunix -.Dl core vmunix.old -.Pp -If you type -.Cm rm /v -and then the tab key, -.Nm -will then finish off as much of the name as possible by adding -.Ar munix . -Because the name is not unique, it will then beep. If you type the -escape key and a question mark, it will display the two choices. If you -then type a period and a tab, the library will finish off the filename -for you: -.Pp -.Bd -ragged -offset indent -rm /v[TAB] -.Em munix -\&.[TAB] -.Em old -.Ed -.Pp -The tab key is shown by [TAB] and the automatically-entered text -is shown in italics, or underline. -.Sh USAGE -To include -.Nm -in your program, call it as you do any other function and link your -program with -.Ar -leditline . -.Ss Example -The following brief example lets you enter a line and edit it, then displays it. -.Pp -.Bd -literal -offset indent -#include -#include -#include - -int main(void) -{ - char *p; - - while ((p = readline("CLI> "))) { - puts(p); - free(p); - } - - return 0; -} -.El -.Sh AUTHORS -The original editline library was posted to comp.sources.unix newsgroup -by created by Simmule R. Turner and Rich Salz in 1992. It now exists in -several forks: Debian, Minix, Heimdal, Festival speech tools, Mozilla, -Google Gadgets for Linux, and many other places. The original manual -page was made by David W. Sanderson. -.Pp -This version was originally based on the Minix 2 sources, but has since -evolved to include patches from all relevant forks. It is currently -maintained by Joachim Nilsson at GitHub, -.Aq http://github.com/troglobit/editline -.Sh BUGS -Does not handle multiple lines well. diff --git a/third_party/editline/editline.c b/third_party/editline/editline.c deleted file mode 100644 index 8d95f9e7..00000000 --- a/third_party/editline/editline.c +++ /dev/null @@ -1,1557 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ 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; version 2 of the License. │ -│ │ -│ 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 │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" -#include "libc/calls/termios.h" -#include "libc/dce.h" -#include "libc/errno.h" -#include "libc/macros.h" -#include "libc/mem/mem.h" -#include "libc/runtime/runtime.h" -#include "libc/str/str.h" -#include "libc/sysv/consts/termios.h" -#include "third_party/editline/editline.h" -#include "third_party/editline/internal.h" - -asm(".ident\t\"\\n\\n\ -Cosmopolitan Linenoise (BSD-like license)\\n\ -Copyright 2019 Justine Alexandra Roberts Tunney\\n\ -Copyright 1992,1993 Simmule Turner and Rich Salz\\n\ -All rights reserved.\\n\ -\\n\ -This software is not subject to any license of the American Telephone\\n\ -and Telegraph Company or of the Regents of the University of California.\\n\ -\\n\ -Permission is granted to anyone to use this software for any purpose on\\n\ -any computer system, and to alter it and redistribute it freely, subject\\n\ -to the following restrictions:\\n\ -1. The authors are not responsible for the consequences of use of this\\n\ - software, no matter how awful, even if they arise from flaws in it.\\n\ -2. The origin of this software must not be misrepresented, either by\\n\ - explicit claim or by omission. Since few users ever read sources,\\n\ - credits must appear in the documentation.\\n\ -3. Altered versions must be plainly marked as such, and must not be\\n\ - misrepresented as being the original software. Since few users\\n\ - ever read sources, credits must appear in the documentation.\\n\ -4. This notice may not be removed or altered.\""); -asm(".include \"libc/disclaimer.inc\""); - -#define SCREEN_COLS 80 -#define SCREEN_ROWS 24 -#define EL_STDIN 0 -#define EL_STDOUT 1 -#define NO_ARG (-1) -#define DEL 127 -#define SEPS "\"#$&'()*:;<=>?[\\]^`{|}~\n\t " - -enum EditlineCase { TOupper, TOlower, TOcapitalize }; - -struct EditlineKeymap { - int Key; - el_status_t (*Function)(void); -}; - -struct EditlineHistory { - int Size; - int Pos; - char **Lines; -}; - -rl_getc_func_t *rl_getc_function = rl_getc; -rl_hook_func_t *rl_event_hook; -rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal; -rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal; - -int rl_eof; -int rl_erase; -int rl_intr; -int rl_kill; -int rl_quit; -int rl_susp; -int el_hist_size = 15; - -static struct EditlineHistory g_hist = { - .Size = 0, - .Pos = 0, - .Lines = NULL, -}; - -static char NILSTR[] = ""; -static const char *el_input = NILSTR; -static char *Yanked; -static char *Screen; -static char NEWLINE[] = "\r\n"; -static char CLEAR[] = "\ec"; -static const char *el_term = "dumb"; -static int Repeat; -static int old_point; -static int el_push_back; -static int el_pushed; -static int el_intr_pending; -static int el_infd = EL_STDIN; -static int el_outfd = EL_STDOUT; -static struct EditlineKeymap Map[]; -static struct EditlineKeymap MetaMap[]; -static size_t Length = 0; -static size_t ScreenCount; -static size_t ScreenSize; -static char *backspace = "\b"; -static char *old_search = NULL; -static int tty_cols = SCREEN_COLS; -static int tty_rows = SCREEN_ROWS; -static int Searching = 0; -static const char *(*search_move)(void); -static const char *old_prompt = NULL; -static rl_vcpfunc_t *line_handler = NULL; -static const char *rl_saved_prompt = NULL; - -int el_no_echo = 0; /* e.g., under Emacs */ -int el_no_hist = 0; -int rl_point; -int rl_mark; -int rl_end; -int rl_meta_chars = 0; /* 8-bit chars as actual char(0) or `M-x'(1)? */ -int rl_inhibit_complete = 0; -char *rl_line_buffer = NULL; -const char *rl_prompt = NULL; -const char *rl_readline_name = - NULL; /* Set by calling program, for conditional parsing of ~/.inputrc - Not - supported yet! */ -FILE *rl_instream = NULL; /* The stdio stream from which input is read. Defaults - to stdin if NULL */ -FILE *rl_outstream = NULL; /* The stdio stream to which output is flushed. - Defaults to stdout if NULL */ - -/* Declarations. */ -static char *editinput(int complete); -#ifdef CONFIG_USE_TERMCAP -extern char *tgetstr(const char *, char **); -extern int tgetent(char *, const char *); -extern int tgetnum(const char *); -#endif - -/* -** Misc. local helper functions. -*/ -static int is_alpha_num(unsigned char c) { - if (isalnum(c)) return 1; - if (ISMETA(c)) return 1; - if (ISCTL(c)) return 1; - return 0; -} - -/* -** TTY input/output functions. -*/ - -static void tty_flush(void) { - ssize_t res; - if (!ScreenCount) return; - if (!el_no_echo) { - res = write(el_outfd, Screen, ScreenCount); - if (res > 0) ScreenCount = 0; - } -} - -static void tty_put(const char c) { - if (el_no_echo) return; - Screen[ScreenCount] = c; - if (++ScreenCount >= ScreenSize) { - ScreenSize += SCREEN_INC; - Screen = realloc(Screen, sizeof(char) * ScreenSize); - } -} - -static void tty_puts(const char *p) { - while (*p) tty_put(*p++); -} - -static void tty_show(unsigned char c) { - if (c == DEL) { - tty_put('^'); - tty_put('?'); - } else if (ISCTL(c)) { - tty_put('^'); - tty_put(UNCTL(c)); - } else if (rl_meta_chars && ISMETA(c)) { - tty_put('M'); - tty_put('-'); - tty_put(UNMETA(c)); - } else { - tty_put(c); - } -} - -static void tty_string(char *p) { - while (*p) tty_show(*p++); -} - -static void tty_push(int c) { - el_pushed = 1; - el_push_back = c; -} - -int rl_getc(void) { - int r; - char c; - do { - r = read(el_infd, &c, 1); - } while (r == -1 && errno == EINTR); - return r == 1 ? c : EOF; -} - -static int tty_get(void) { - tty_flush(); - if (el_pushed) { - el_pushed = 0; - return el_push_back; - } - if (*el_input) return *el_input++; - return rl_getc_function(); -} - -#define tty_back() tty_puts(backspace) - -static void tty_backn(int n) { - while (--n >= 0) tty_back(); -} - -static void tty_info(void) { - rl_reset_terminal(NULL); -} - -/* -** Glue routines to rl_ttyset() -*/ -void rl_prep_terminal(int meta_flag) { - rl_meta_chars = !meta_flag; - rl_ttyset(0); -} - -void rl_deprep_terminal(void) { - rl_ttyset(1); -} - -/* -** Print an array of words in columns. -*/ -void el_print_columns(int ac, char **av) { - char *p; - int i; - int j; - int k; - int len; - int skip; - int longest; - int cols; - int colwidth; - /* Find longest name, determine column count from that. */ - for (longest = 0, i = 0; i < ac; i++) { - if ((j = strlen((char *)av[i])) > longest) longest = j; - } - colwidth = longest + 3; - if (colwidth > tty_cols) colwidth = tty_cols; - cols = tty_cols / colwidth; - tty_puts(NEWLINE); - for (skip = ac / cols + 1, i = 0; i < skip; i++) { - for (j = i; j < ac; j += skip) { - for (p = av[j], len = strlen((char *)p), k = len; --k >= 0; p++) - tty_put(*p); - if (j + skip < ac) { - while (++len < colwidth) tty_put(' '); - } - } - tty_puts(NEWLINE); - } -} - -static void reposition(void) { - int i; - tty_put('\r'); - tty_puts(rl_prompt); - for (i = 0; i < rl_point; i++) tty_show(rl_line_buffer[i]); -} - -static void left(el_status_t Change) { - if (rl_point) { - tty_back(); - if (ISMETA(rl_line_buffer[rl_point - 1])) { - if (rl_meta_chars) { - tty_back(); - tty_back(); - } - } else if (ISCTL(rl_line_buffer[rl_point - 1])) { - tty_back(); - } - } - if (Change == CSmove) rl_point--; -} - -static void right(el_status_t Change) { - tty_show(rl_line_buffer[rl_point]); - if (Change == CSmove) rl_point++; -} - -el_status_t el_ring_bell(void) { - tty_put('\07'); - tty_flush(); - return CSstay; -} - -static el_status_t do_macro(int c) { - char name[4]; - name[0] = '_'; - name[1] = c; - name[2] = '_'; - name[3] = '\0'; - if ((el_input = (char *)getenv((char *)name)) == NULL) { - el_input = NILSTR; - return el_ring_bell(); - } - return CSstay; -} - -/* Skip forward to start of next word. If @move is set we also move the cursor. - */ -static el_status_t do_forward(el_status_t move) { - int i; - char *p; - i = 0; - do { - p = &rl_line_buffer[rl_point]; - /* Skip leading whitespace, like FSF Readline */ - for (; rl_point < rl_end && (p[0] == ' ' || !is_alpha_num(p[0])); - rl_point++, p++) { - if (move == CSmove) right(CSstay); - } - /* Skip to end of word, if inside a word. */ - for (; rl_point < rl_end && is_alpha_num(p[0]); rl_point++, p++) { - if (move == CSmove) right(CSstay); - } - /* Skip to next word, or skip leading white space if outside a word. */ - for (; rl_point < rl_end && (p[0] == ' ' || !is_alpha_num(p[0])); - rl_point++, p++) { - if (move == CSmove) right(CSstay); - } - if (rl_point == rl_end) break; - } while (++i < Repeat); - return CSstay; -} - -static el_status_t do_case(enum EditlineCase type) { - int i; - int end; - int count; - char *p; - do_forward(CSstay); - if (old_point != rl_point) { - if ((count = rl_point - old_point) < 0) count = -count; - rl_point = old_point; - if ((end = rl_point + count) > rl_end) end = rl_end; - for (i = rl_point, p = &rl_line_buffer[i]; rl_point < end; p++) { - if ((type == TOupper) || (type == TOcapitalize && rl_point == i)) { - if (islower(*p)) *p = toupper(*p); - } else if (isupper(*p)) { - *p = tolower(*p); - } - right(CSmove); - } - } - return CSstay; -} - -static el_status_t case_down_word(void) { - return do_case(TOlower); -} - -static el_status_t case_up_word(void) { - return do_case(TOupper); -} - -static el_status_t case_cap_word(void) { - return do_case(TOcapitalize); -} - -static void ceol(void) { - int extras = 0; - int i; - char *p; - while (rl_point < 0) { - tty_put(' '); - rl_point++; - extras++; - } - for (i = rl_point, p = &rl_line_buffer[i]; i <= rl_end; i++, p++) { - tty_put(' '); - if (ISMETA(*p)) { - if (rl_meta_chars) { - tty_put(' '); - tty_put(' '); - extras += 2; - } - } else if (ISCTL(*p)) { - tty_put(' '); - extras++; - } - } - for (i += extras; i > rl_point; i--) tty_back(); -} - -static void clear_line(void) { - rl_point = -(int)strlen(rl_prompt); - tty_put('\r'); - ceol(); - rl_point = 0; - rl_end = 0; - rl_line_buffer[0] = '\0'; -} - -static el_status_t insert_string(const char *p) { - size_t len; - int i; - char *line; - char *q; - len = strlen(p); - if (rl_end + len >= Length) { - line = malloc(sizeof(char) * (Length + len + MEM_INC)); - if (!line) return CSstay; - if (Length) { - memcpy(line, rl_line_buffer, Length); - free(rl_line_buffer); - } - rl_line_buffer = line; - Length += len + MEM_INC; - } - for (q = &rl_line_buffer[rl_point], i = rl_end - rl_point; --i >= 0;) - q[len + i] = q[i]; - memcpy(&rl_line_buffer[rl_point], p, len); - rl_end += len; - rl_line_buffer[rl_end] = '\0'; - tty_string(&rl_line_buffer[rl_point]); - rl_point += len; - return rl_point == rl_end ? CSstay : CSmove; -} - -int rl_insert_text(const char *text) { - int mark = rl_point; - insert_string(text); - ceol(); - return rl_point - mark; -} - -static el_status_t redisplay(int cls) { - if (cls && rl_point == 0 && rl_end == 0) - tty_puts(CLEAR); - else - tty_puts("\r\e[K"); - tty_puts(rl_prompt); - tty_string(rl_line_buffer); - return CSmove; -} - -static el_status_t refresh(void) { - return redisplay(1); -} - -int rl_refresh_line(int ignore1 __attribute__((unused)), - int ignore2 __attribute__((unused))) { - redisplay(0); - return 0; -} - -static el_status_t toggle_meta_mode(void) { - rl_meta_chars = !rl_meta_chars; - return redisplay(0); -} - -const char *el_next_hist(void) { - return g_hist.Pos >= g_hist.Size - 1 ? NULL : g_hist.Lines[++g_hist.Pos]; -} - -const char *el_prev_hist(void) { - return g_hist.Pos == 0 ? NULL : g_hist.Lines[--g_hist.Pos]; -} - -static el_status_t do_insert_hist(const char *p) { - if (p == NULL) return el_ring_bell(); - clear_line(); - rl_point = 0; - reposition(); - rl_end = 0; - return insert_string(p); -} - -static el_status_t do_hist(const char *(*move)(void)) { - const char *p; - int i = 0; - do { - if ((p = move()) == NULL) return el_ring_bell(); - } while (++i < Repeat); - return do_insert_hist(p); -} - -static el_status_t h_next(void) { - if (el_no_hist) return CSstay; - return do_hist(el_next_hist); -} - -static el_status_t h_prev(void) { - if (el_no_hist) return CSstay; - return do_hist(el_prev_hist); -} - -static el_status_t h_first(void) { - return do_insert_hist(g_hist.Lines[g_hist.Pos = 0]); -} - -static el_status_t h_last(void) { - return do_insert_hist(g_hist.Lines[g_hist.Pos = g_hist.Size - 1]); -} - -/* -** Return zero if pat appears as a substring in text. -*/ -static int substrcmp(const char *text, const char *pat, size_t len) { - char c; - if ((c = *pat) == '\0') return *text == '\0'; - for (; *text; text++) { - if (*text == c && strncmp(text, pat, len) == 0) return 0; - } - return 1; -} - -static const char *search_hist(const char *search, const char *(*move)(void)) { - int len; - int pos; - int (*match)(const char *s1, const char *s2, size_t n); - const char *pat; - /* Save or get remembered search pattern. */ - if (search && *search) { - if (old_search) free(old_search); - old_search = strdup(search); - } else { - if (old_search == NULL || *old_search == '\0') return NULL; - search = old_search; - } - /* Set up pattern-finder. */ - if (*search == '^') { - match = strncmp; - pat = search + 1; - } else { - match = substrcmp; - pat = search; - } - len = strlen(pat); - pos = g_hist.Pos; /* Save g_hist.Pos */ - while (move()) { - if (match(g_hist.Lines[g_hist.Pos], pat, len) == 0) - return g_hist.Lines[g_hist.Pos]; - } - g_hist.Pos = pos; /* Restore g_hist.Pos */ - return NULL; -} - -static el_status_t h_search_end(const char *p) { - rl_prompt = old_prompt; - Searching = 0; - if (el_intr_pending > 0) { - el_intr_pending = 0; - clear_line(); - return redisplay(0); - } - p = search_hist(p, search_move); - if (p == NULL) { - el_ring_bell(); - clear_line(); - return redisplay(0); - } - return do_insert_hist(p); -} - -static el_status_t h_search(void) { - if (Searching) return el_ring_bell(); - Searching = 1; - clear_line(); - old_prompt = rl_prompt; - rl_prompt = "Search: "; - tty_puts(rl_prompt); - search_move = Repeat == NO_ARG ? el_prev_hist : el_next_hist; - if (line_handler) { - editinput(0); - return CSstay; - } - return h_search_end(editinput(1)); -} - -static el_status_t fd_char(void) { - int i = 0; - do { - if (rl_point >= rl_end) break; - right(CSmove); - } while (++i < Repeat); - return CSstay; -} - -static void save_yank(int begin, int i) { - if (Yanked) { - free(Yanked); - Yanked = NULL; - } - if (i < 1) return; - Yanked = malloc(sizeof(char) * (i + 1)); - if (Yanked) { - memcpy(Yanked, &rl_line_buffer[begin], i); - Yanked[i] = '\0'; - } -} - -static el_status_t delete_string(int count) { - int i; - char *p; - if (count <= 0 || rl_end == rl_point) return el_ring_bell(); - if (count == 1 && rl_point == rl_end - 1) { - /* Optimize common case of delete at end of line. */ - rl_end--; - p = &rl_line_buffer[rl_point]; - i = 1; - tty_put(' '); - if (ISCTL(*p)) { - i = 2; - tty_put(' '); - } else if (rl_meta_chars && ISMETA(*p)) { - i = 3; - tty_put(' '); - tty_put(' '); - } - tty_backn(i); - *p = '\0'; - return CSmove; - } - if (rl_point + count > rl_end && (count = rl_end - rl_point) <= 0) - return CSstay; - if (count > 1) save_yank(rl_point, count); - for (p = &rl_line_buffer[rl_point], i = rl_end - (rl_point + count) + 1; - --i >= 0; p++) - p[0] = p[count]; - ceol(); - rl_end -= count; - tty_string(&rl_line_buffer[rl_point]); - return CSmove; -} - -static el_status_t bk_char(void) { - int i = 0; - do { - if (rl_point == 0) break; - left(CSmove); - } while (++i < Repeat); - return CSstay; -} - -static el_status_t bk_del_char(void) { - int i = 0; - do { - if (rl_point == 0) break; - left(CSmove); - } while (++i < Repeat); - return delete_string(i); -} - -static el_status_t kill_line(void) { - int i; - if (Repeat != NO_ARG) { - if (Repeat < rl_point) { - i = rl_point; - rl_point = Repeat; - reposition(); - delete_string(i - rl_point); - } else if (Repeat > rl_point) { - right(CSmove); - delete_string(Repeat - rl_point - 1); - } - return CSmove; - } - save_yank(rl_point, rl_end - rl_point); - rl_line_buffer[rl_point] = '\0'; - ceol(); - rl_end = rl_point; - return CSstay; -} - -static el_status_t insert_char(int c) { - el_status_t s; - char buff[2]; - char *p; - char *q; - int i; - if (Repeat == NO_ARG || Repeat < 2) { - buff[0] = c; - buff[1] = '\0'; - return insert_string(buff); - } - p = malloc(sizeof(char) * (Repeat + 1)); - if (!p) return CSstay; - for (i = Repeat, q = p; --i >= 0;) *q++ = c; - *q = '\0'; - Repeat = 0; - s = insert_string(p); - free(p); - return s; -} - -static el_status_t beg_line(void) { - if (rl_point) { - rl_point = 0; - return CSmove; - } - return CSstay; -} - -static el_status_t end_line(void) { - if (rl_point != rl_end) { - rl_point = rl_end; - return CSmove; - } - return CSstay; -} - -static el_status_t del_char(void) { - return delete_string(Repeat == NO_ARG ? CSeof : Repeat); -} - -el_status_t el_del_char(void) { - return del_char(); -} - -static el_status_t fd_word(void) { - return do_forward(CSmove); -} - -static el_status_t bk_word(void) { - int i; - char *p; - i = 0; - do { - for (p = &rl_line_buffer[rl_point]; - p > rl_line_buffer && !is_alpha_num(p[-1]); p--) - left(CSmove); - for (; p > rl_line_buffer && !isblank(p[-1]) && is_alpha_num(p[-1]); p--) - left(CSmove); - if (rl_point == 0) break; - } while (++i < Repeat); - return CSstay; -} - -static el_status_t meta(void) { - int c; - struct EditlineKeymap *kp; - if ((c = tty_get()) == EOF) return CSeof; -#ifdef CONFIG_ANSI_ARROWS - /* Also include VT-100 arrows. */ - if (c == '[' || c == 'O') { - switch (tty_get()) { - case EOF: - return CSeof; - case '1': { - char seq[4] = {0}; - for (c = 0; c < 3; c++) seq[c] = tty_get(); - if (!strncmp(seq, ";5C", 3)) return fd_word(); /* Ctrl+Right */ - if (!strncmp(seq, ";5D", 3)) return bk_word(); /* Ctrl+Left */ - break; - } - case '2': - tty_get(); - return CSstay; /* Insert */ - case '3': - tty_get(); - return del_char(); /* Delete */ - case '5': - tty_get(); - return CSstay; /* PgUp */ - case '6': - tty_get(); - return CSstay; /* PgDn */ - case 'A': - return h_prev(); /* Up */ - case 'B': - return h_next(); /* Down */ - case 'C': - return fd_char(); /* Left */ - case 'D': - return bk_char(); /* Right */ - case 'F': - return end_line(); /* End */ - case 'H': - return beg_line(); /* Home */ - default: /* Fall through */ - break; - } - return el_ring_bell(); - } -#endif /* CONFIG_ANSI_ARROWS */ - if (isdigit(c)) { - for (Repeat = c - '0'; (c = tty_get()) != EOF && isdigit(c);) - Repeat = Repeat * 10 + c - '0'; - tty_push(c); - return CSstay; - } - if (isupper(c)) return do_macro(c); - for (kp = MetaMap; kp->Function; kp++) { - if (kp->Key == c) return kp->Function(); - } - return el_ring_bell(); -} - -static el_status_t emacs(int c) { - el_status_t s; - struct EditlineKeymap *kp; - /* Save point before interpreting input character 'c'. */ - old_point = rl_point; - if (rl_meta_chars && ISMETA(c)) { - tty_push(UNMETA(c)); - return meta(); - } - for (kp = Map; kp->Function; kp++) { - if (kp->Key == c) break; - } - if (kp->Function) { - s = kp->Function(); - if (s == CSdispatch) /* If Function is inhibited. */ - s = insert_char(c); - } else { - s = insert_char(c); - } - if (!el_pushed) { - /* No pushback means no repeat count; hacky, but true. */ - Repeat = NO_ARG; - } - return s; -} - -static el_status_t tty_special(int c) { -#ifdef CONFIG_SIGINT - if (c == rl_intr) { - el_intr_pending = SIGINT; - return CSsignal; - } -#endif - if (c == rl_quit) { - el_intr_pending = SIGQUIT; - return CSeof; - } -#ifdef CONFIG_SIGSTOP - if (c == rl_susp) { - el_intr_pending = SIGTSTP; - return CSsignal; - } -#endif - if (rl_meta_chars && ISMETA(c)) return CSdispatch; - if (c == rl_erase || c == DEL) return bk_del_char(); - if (c == rl_kill) { - if (rl_point != 0) { - rl_point = 0; - reposition(); - } - Repeat = NO_ARG; - return kill_line(); - } -#ifdef CONFIG_EOF - if (c == rl_eof && rl_point == 0 && rl_end == 0) return CSeof; -#endif - return CSdispatch; -} - -static char *editinput(int complete) { - int c; - do { - c = tty_get(); - if (c == EOF) break; - switch (tty_special(c)) { - case CSdone: - return rl_line_buffer; - case CSeof: - return NULL; - case CSsignal: - return (char *)""; - case CSmove: - reposition(); - break; - case CSdispatch: - switch (emacs(c)) { - case CSdone: - return rl_line_buffer; - case CSeof: - return NULL; - case CSsignal: - return (char *)""; - case CSmove: - reposition(); - break; - case CSdispatch: - case CSstay: - break; - } - break; - case CSstay: - break; - } - } while (complete); - return NULL; -} - -static void hist_alloc(void) { - if (!g_hist.Lines) g_hist.Lines = calloc(el_hist_size, sizeof(char *)); -} - -static void hist_add(const char *p) { - int i; - char *s; -#ifdef CONFIG_UNIQUE_HISTORY - if (g_hist.Size && strcmp(p, g_hist.Lines[g_hist.Size - 1]) == 0) return; -#endif - s = strdup(p); - if (s == NULL) return; - if (g_hist.Size < el_hist_size) { - g_hist.Lines[g_hist.Size++] = s; - } else { - free(g_hist.Lines[0]); - for (i = 0; i < el_hist_size - 1; i++) - g_hist.Lines[i] = g_hist.Lines[i + 1]; - g_hist.Lines[i] = s; - } - g_hist.Pos = g_hist.Size - 1; -} - -static char *read_redirected(void) { - int size = MEM_INC; - char *p; - char *line; - char *end; - p = line = malloc(sizeof(char) * size); - if (!p) return NULL; - end = p + size; - while (1) { - if (p == end) { - int oldpos = end - line; - size += MEM_INC; - p = line = realloc(line, sizeof(char) * size); - if (!p) return NULL; - end = p + size; - p += oldpos; /* Continue where we left off... */ - } - if (read(el_infd, p, 1) <= 0) { - /* Ignore "incomplete" lines at EOF, just like we do for a tty. */ - free(line); - return NULL; - } - if (*p == '\n') break; - p++; - } - *p = '\0'; - return line; -} - -/* For compatibility with FSF readline. */ -void rl_reset_terminal(const char *terminal_name) { -#ifdef CONFIG_USE_TERMCAP - char buf[1024]; - char *bp; -#endif -#ifdef TIOCGWINSZ - struct winsize W; -#endif - if (terminal_name) { - el_term = terminal_name; - } else if ((el_term = getenv("TERM")) == NULL) { - el_term = "dumb"; - } - /* Initialize to faulty values to trigger fallback if nothing else works. */ - tty_cols = tty_rows = -1; -#ifdef CONFIG_USE_TERMCAP - bp = buf; - if (-1 != tgetent(buf, el_term)) { - if ((backspace = tgetstr("le", &bp)) != NULL) backspace = strdup(backspace); - tty_cols = tgetnum("co"); - tty_rows = tgetnum("li"); - } - /* Make sure to check width & rows and fallback to TIOCGWINSZ if available. */ -#endif - if (tty_cols <= 0 || tty_rows <= 0) { -#ifdef TIOCGWINSZ - if (ioctl(el_outfd, TIOCGWINSZ, &W) >= 0 && W.ws_col > 0 && W.ws_row > 0) { - tty_cols = (int)W.ws_col; - tty_rows = (int)W.ws_row; - return; - } -#endif - tty_cols = SCREEN_COLS; - tty_rows = SCREEN_ROWS; - } -} - -void rl_initialize(void) { - if (!rl_prompt) rl_prompt = "? "; - hist_alloc(); - /* Setup I/O descriptors */ - if (!rl_instream) - el_infd = EL_STDIN; - else - el_infd = fileno(rl_instream); - if (el_infd < 0) el_infd = EL_STDIN; - if (!rl_outstream) - el_outfd = EL_STDOUT; - else - el_outfd = fileno(rl_outstream); - if (el_outfd < 0) el_outfd = EL_STDOUT; -} - -void rl_uninitialize(void) { - int i; - /* Uninitialize the history */ - if (g_hist.Lines) { - for (i = 0; i < el_hist_size; i++) { - if (g_hist.Lines[i]) free(g_hist.Lines[i]); - g_hist.Lines[i] = NULL; - } - free(g_hist.Lines); - g_hist.Lines = NULL; - } - g_hist.Size = 0; - g_hist.Pos = 0; - if (old_search) free(old_search); - old_search = NULL; - /* Uninitialize the line buffer */ - if (rl_line_buffer) free(rl_line_buffer); - rl_line_buffer = NULL; - Length = 0; -} - -void rl_save_prompt(void) { - rl_saved_prompt = rl_prompt; -} - -void rl_restore_prompt(void) { - if (rl_saved_prompt) rl_prompt = rl_saved_prompt; -} - -void rl_set_prompt(const char *prompt) { - rl_prompt = prompt; -} - -void rl_clear_message(void) { /* Nothing to do atm. */ -} - -void rl_forced_update_display() { - redisplay(0); - tty_flush(); -} - -static int el_prep(const char *prompt) { - rl_initialize(); - if (!rl_line_buffer) { - Length = MEM_INC; - rl_line_buffer = malloc(sizeof(char) * Length); - if (!rl_line_buffer) return -1; - } - tty_info(); - rl_prep_term_function(!rl_meta_chars); - hist_add(NILSTR); - ScreenSize = SCREEN_INC; - Screen = malloc(sizeof(char) * ScreenSize); - if (!Screen) return -1; - rl_prompt = prompt ? prompt : NILSTR; - if (el_no_echo) { - int old = el_no_echo; - el_no_echo = 0; - tty_puts(rl_prompt); - tty_flush(); - el_no_echo = old; - } else { - tty_puts(rl_prompt); - } - Repeat = NO_ARG; - old_point = rl_point = rl_mark = rl_end = 0; - rl_line_buffer[0] = '\0'; - el_intr_pending = -1; - return 0; -} - -static char *el_deprep(char *line) { - if (line) { - line = strdup(line); - tty_puts(NEWLINE); - tty_flush(); - } - rl_deprep_term_function(); - if (Screen) { - free(Screen); - Screen = NULL; - } - free(g_hist.Lines[--g_hist.Size]); - g_hist.Lines[g_hist.Size] = NULL; - /* Add to history, unless no-echo or no-history mode ... */ - if (!el_no_echo && !el_no_hist) { - if (line != NULL && *line != '\0') hist_add(line); - } - if (el_intr_pending > 0) { - int signo = el_intr_pending; - el_intr_pending = 0; - kill(getpid(), signo); - } - return line; -} - -void rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *lhandler) { - if (!lhandler) return; - line_handler = lhandler; - /* - * Any error from el_prep() is handled by the lhandler callbck as - * soon as the user calls rl_callback_read_char(). - */ - el_prep(prompt); - tty_flush(); -} - -/* - * Reads one character at a time, when a complete line has been received - * the lhandler from rl_callback_handler_install() is called with the - * line as argument. - * - * If the callback returns the terminal is prepped for reading a new - * line. - * - * If any error occurs, either in the _install() phase, or while reading - * one character, this function restores the terminal and calls lhandler - * with a NULL argument. - */ -void rl_callback_read_char(void) { - char *line; - if (!line_handler) { - errno = EINVAL; - return; - } - /* - * Check if rl_callback_handler_install() failed - * This is the only point where we can tell user - */ - if (!Screen || !rl_line_buffer) { - errno = ENOMEM; - line_handler(el_deprep(NULL)); - return; - } - line = editinput(0); - if (line) { - char *l; - if (Searching) { - h_search_end(line); - tty_flush(); - return; - } - l = el_deprep(line); - line_handler(l); - if (el_prep(rl_prompt)) line_handler(NULL); - } - tty_flush(); -} - -void rl_callback_handler_remove(void) { - if (!line_handler) return; - el_deprep(NULL); - line_handler = NULL; -} - -char *readline(const char *prompt) { - /* Unless called by the user already. */ - rl_initialize(); - if (!isatty(el_infd)) { - tty_flush(); - return read_redirected(); - } - if (el_prep(prompt)) return NULL; - return el_deprep(editinput(1)); -} - -/* - * Even though readline() itself adds history automatically, the user - * can also add lines. This is for compatibility with GNU Readline. - */ -void add_history(const char *p) { - if (p == NULL || *p == '\0') return; - hist_add(p); -} - -int read_history(const char *filename) { - FILE *fp; - char buf[SCREEN_INC]; - hist_alloc(); - fp = fopen(filename, "r"); - if (fp) { - g_hist.Size = 0; - while (g_hist.Size < el_hist_size) { - if (!fgets(buf, SCREEN_INC, fp)) break; - buf[strlen(buf) - 1] = 0; /* Remove '\n' */ - add_history(buf); - } - return fclose(fp); - } - return errno; -} - -int write_history(const char *filename) { - FILE *fp; - hist_alloc(); - fp = fopen(filename, "w"); - if (fp) { - int i = 0; - while (i < g_hist.Size) fprintf(fp, "%s\n", g_hist.Lines[i++]); - return fclose(fp); - } - return errno; -} - -/* -** Move back to the beginning of the current word and return an -** allocated copy of it. -*/ -char *el_find_word(void) { - char *p, *q; - char *word; - size_t len; - p = &rl_line_buffer[rl_point]; - while (p > rl_line_buffer) { - p--; - if (p > rl_line_buffer && p[-1] == '\\') { - p--; - } else { - if (strchr(SEPS, (char)*p) != NULL) { - p++; - break; - } - } - } - len = rl_point - (p - rl_line_buffer) + 1; - word = malloc(sizeof(char) * len); - if (!word) return NULL; - q = word; - while (p < &rl_line_buffer[rl_point]) { - if (*p == '\\') { - if (++p == &rl_line_buffer[rl_point]) break; - } - *q++ = *p++; - } - *q = '\0'; - return word; -} - -static el_status_t c_possible(void) { - char **av; - char *word; - int ac; - word = el_find_word(); - ac = rl_list_possib(word, &av); - if (word) free(word); - if (ac) { - el_print_columns(ac, av); - while (--ac >= 0) free(av[ac]); - free(av); - return CSmove; - } - return el_ring_bell(); -} - -static el_status_t c_complete(void) { - char *p, *q; - char *word, *string; - size_t len; - int unique; - el_status_t s = CSdone; - if (rl_inhibit_complete) return CSdispatch; - word = el_find_word(); - p = rl_complete(word, &unique); - if (word) free(word); - if (p) { - len = strlen(p); - word = p; - string = q = malloc(sizeof(char) * (2 * len + 1)); - if (!string) { - free(word); - return CSstay; - } - while (*p) { - if ((*p < ' ' || strchr(SEPS, *p) != NULL) && (!unique || p[1] != 0)) { - *q++ = '\\'; - } - *q++ = *p++; - } - *q = '\0'; - free(word); - if (len > 0) { - s = insert_string(string); -#ifdef CONFIG_TERMINAL_BELL - if (!unique) el_ring_bell(); -#endif - } - free(string); - if (len > 0) return s; - } - return c_possible(); -} - -static el_status_t accept_line(void) { - rl_line_buffer[rl_end] = '\0'; - return CSdone; -} - -static el_status_t end_of_input(void) { - rl_line_buffer[rl_end] = '\0'; - return CSeof; -} - -static el_status_t ctrl_z(void) { - if (IsWindows()) { - return end_of_input(); - } else { - return el_ring_bell(); - } -} - -static el_status_t transpose_(void) { - char c; - if (rl_point) { - if (rl_point == rl_end) left(CSmove); - c = rl_line_buffer[rl_point - 1]; - left(CSstay); - rl_line_buffer[rl_point - 1] = rl_line_buffer[rl_point]; - tty_show(rl_line_buffer[rl_point - 1]); - rl_line_buffer[rl_point++] = c; - tty_show(c); - } - return CSstay; -} - -static el_status_t quote(void) { - int c; - return (c = tty_get()) == EOF ? CSeof : insert_char((int)c); -} - -static el_status_t mk_set(void) { - rl_mark = rl_point; - return CSstay; -} - -static el_status_t exchange(void) { - int c; - if ((c = tty_get()) != CTL('X')) return c == EOF ? CSeof : el_ring_bell(); - if ((c = rl_mark) <= rl_end) { - rl_mark = rl_point; - rl_point = c; - return CSmove; - } - return CSstay; -} - -static el_status_t yank(void) { - if (Yanked && *Yanked) return insert_string(Yanked); - return CSstay; -} - -static el_status_t copy_region(void) { - if (rl_mark > rl_end) return el_ring_bell(); - if (rl_point > rl_mark) - save_yank(rl_mark, rl_point - rl_mark); - else - save_yank(rl_point, rl_mark - rl_point); - return CSstay; -} - -static el_status_t move_to_char(void) { - int i, c; - char *p; - if ((c = tty_get()) == EOF) return CSeof; - for (i = rl_point + 1, p = &rl_line_buffer[i]; i < rl_end; i++, p++) { - if (*p == c) { - rl_point = i; - return CSmove; - } - } - return CSstay; -} - -static el_status_t fd_kill_word(void) { - int i; - do_forward(CSstay); - if (old_point != rl_point) { - i = rl_point - old_point - 1; - rl_point = old_point; - return delete_string(i); - } - return CSstay; -} - -static el_status_t bk_kill_word(void) { - bk_word(); - if (old_point != rl_point) return delete_string(old_point - rl_point); - return CSstay; -} - -static int argify(char *line, char ***avp) { - char *c; - char **p; - char **arg; - int ac; - int i; - i = MEM_INC; - *avp = p = malloc(sizeof(char *) * i); - if (!p) return 0; - for (c = line; isspace(*c); c++) continue; - if (*c == '\n' || *c == '\0') return 0; - for (ac = 0, p[ac++] = c; *c && *c != '\n';) { - if (!isspace(*c)) { - c++; - continue; - } - *c++ = '\0'; - if (*c && *c != '\n') { - if (ac + 1 == i) { - arg = malloc(sizeof(char *) * (i + MEM_INC)); - if (!arg) { - p[ac] = NULL; - return ac; - } - memcpy(arg, p, i * sizeof(char *)); - i += MEM_INC; - free(p); - *avp = p = arg; - } - p[ac++] = c; - } - } - *c = '\0'; - p[ac] = NULL; - return ac; -} - -static el_status_t last_argument(void) { - char **av = NULL; - char *p; - el_status_t s; - int ac; - if (g_hist.Size == 1 || (p = (char *)g_hist.Lines[g_hist.Size - 2]) == NULL) - return el_ring_bell(); - p = strdup(p); - if (!p) return CSstay; - ac = argify(p, &av); - if (Repeat != NO_ARG) - s = Repeat < ac ? insert_string(av[Repeat]) : el_ring_bell(); - else - s = ac ? insert_string(av[ac - 1]) : CSstay; - if (av) free(av); - free(p); - return s; -} - -static struct EditlineKeymap MetaMap[64] = { - {CTL('H'), bk_kill_word}, {DEL, bk_kill_word}, {' ', mk_set}, - {'.', last_argument}, {'<', h_first}, {'>', h_last}, - {'?', c_possible}, {'b', bk_word}, {'c', case_cap_word}, - {'d', fd_kill_word}, {'f', fd_word}, {'l', case_down_word}, - {'m', toggle_meta_mode}, {'u', case_up_word}, {'y', yank}, - {'w', copy_region}, {0, NULL}, -}; - -static size_t find_key_in_map(int key, struct EditlineKeymap map[], - size_t mapsz) { - size_t i; - for (i = 0; map[i].Function && i < mapsz; i++) { - if (map[i].Key == key) return i; - } - if (i < mapsz) return i; - return mapsz; -} - -static el_status_t el_bind_key_in_map(int key, el_keymap_func_t function, - struct EditlineKeymap map[], - size_t mapsz) { - size_t creat, pos = find_key_in_map(key, map, mapsz); - /* Must check that pos is not the next to last array position, - * otherwise we will write out-of-bounds to terminate the list. */ - if (pos + 1 >= mapsz) { - errno = ENOMEM; - return CSeof; - } - /* Add at end, create new? */ - creat = map[pos].Function == NULL; - /* A new key so have to add it to end */ - map[pos].Key = key; - map[pos].Function = function; - /* Terminate list */ - if (creat) { - map[pos + 1].Key = 0; - map[pos + 1].Function = NULL; - } - return CSdone; -} - -static struct EditlineKeymap Map[64] = { - {CTL('@'), mk_set}, - {CTL('A'), beg_line}, - {CTL('B'), bk_char}, - {CTL('D'), del_char}, - {CTL('E'), end_line}, - {CTL('F'), fd_char}, - {CTL('G'), el_ring_bell}, - {CTL('H'), bk_del_char}, - {CTL('I'), c_complete}, - {CTL('J'), accept_line}, - {CTL('K'), kill_line}, - {CTL('L'), refresh}, - {CTL('M'), accept_line}, - {CTL('N'), h_next}, - {CTL('O'), el_ring_bell}, - {CTL('P'), h_prev}, - {CTL('Q'), el_ring_bell}, - {CTL('R'), h_search}, - {CTL('S'), el_ring_bell}, - {CTL('T'), transpose_}, - {CTL('U'), el_ring_bell}, - {CTL('V'), quote}, - {CTL('W'), bk_kill_word}, - {CTL('X'), exchange}, - {CTL('Y'), yank}, - {CTL('Z'), ctrl_z}, - {CTL('['), meta}, - {CTL(']'), move_to_char}, - {CTL('^'), el_ring_bell}, - {CTL('_'), el_ring_bell}, - {0, NULL}, -}; - -el_status_t el_bind_key(int key, el_keymap_func_t function) { - return el_bind_key_in_map(key, function, Map, ARRAYLEN(Map)); -} - -el_status_t el_bind_key_in_metamap(int key, el_keymap_func_t function) { - return el_bind_key_in_map(key, function, MetaMap, ARRAYLEN(MetaMap)); -} - -rl_getc_func_t *rl_set_getc_func(rl_getc_func_t *func) { - rl_getc_func_t *old = rl_getc_function; - rl_getc_function = func; - return old; -} diff --git a/third_party/editline/editline.h b/third_party/editline/editline.h deleted file mode 100644 index a094490c..00000000 --- a/third_party/editline/editline.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef COSMOPOLITAN_THIRD_PARTY_EDITLINE_EDITLINE_H_ -#define COSMOPOLITAN_THIRD_PARTY_EDITLINE_EDITLINE_H_ -#include "libc/stdio/stdio.h" - -#define CTL(x) ((x)&0x1F) -#define ISCTL(x) ((x) && (x) < ' ') -#define UNCTL(x) ((x) + 64) -#define META(x) ((x) | 0x80) -#define ISMETA(x) ((x)&0x80) -#define UNMETA(x) ((x)&0x7F) - -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -typedef enum { - CSdone = 0, /* OK */ - CSeof, /* Error, or EOF */ - CSmove, - CSdispatch, - CSstay, - CSsignal -} el_status_t; - -typedef int rl_list_possib_func_t(char *, char ***); -typedef el_status_t el_keymap_func_t(void); -typedef int rl_hook_func_t(void); -typedef int rl_getc_func_t(void); -typedef void rl_voidfunc_t(void); -typedef void rl_vintfunc_t(int); -typedef void rl_vcpfunc_t(char *); -compatfn typedef char *rl_complete_func_t(char *, int *); -compatfn typedef char *rl_compentry_func_t(const char *, int); -compatfn typedef char **rl_completion_func_t(const char *, int, int); - -extern int rl_point; -extern int rl_mark; -extern int rl_end; -extern int rl_inhibit_complete; -extern char *rl_line_buffer; -extern const char *rl_readline_name; -extern FILE *rl_instream; /* The stdio stream from which input is read. Defaults - to stdin if NULL - Not supported yet! */ -extern FILE *rl_outstream; /* The stdio stream to which output is flushed. - Defaults to stdout if NULL - Not supported yet! */ -extern int el_no_echo; /* E.g under emacs, don't echo except prompt */ -extern int el_no_hist; /* Disable auto-save of and access to history -- e.g. for - password prompts or wizards */ -extern int el_hist_size; /* size of history scrollback buffer, default: 15 */ -extern int rl_meta_chars; /* Display 8-bit chars "as-is" or as `M-x'? Toggle - with M-m. (Default:0 - "as-is") */ -extern rl_completion_func_t *rl_attempted_completion_function; - -char **rl_completion_matches(const char *, rl_compentry_func_t *); -char *el_find_word(void); -char *readline(const char *); -char *rl_complete(char *, int *); -char *rl_filename_completion_function(const char *, int); -const char *el_next_hist(void); -const char *el_prev_hist(void); -el_status_t el_bind_key(int, el_keymap_func_t); -el_status_t el_bind_key_in_metamap(int, el_keymap_func_t); -el_status_t el_del_char(void); -el_status_t el_ring_bell(void); -int read_history(const char *); -int rl_getc(void); -int rl_insert_text(const char *); -int rl_list_possib(char *, char ***); -int rl_refresh_line(int, int); -int write_history(const char *); -rl_complete_func_t *rl_set_complete_func(rl_complete_func_t *); -rl_getc_func_t *rl_set_getc_func(rl_getc_func_t *); -rl_list_possib_func_t *rl_set_list_possib_func(rl_list_possib_func_t *); -void add_history(const char *); -void el_print_columns(int, char **); -void rl_callback_handler_install(const char *, rl_vcpfunc_t *); -void rl_callback_handler_remove(void); -void rl_callback_read_char(void); -void rl_clear_message(void); -void rl_deprep_terminal(void); -void rl_forced_update_display(void); -void rl_initialize(void); -void rl_prep_terminal(int); -void rl_reset_terminal(const char *); -void rl_restore_prompt(void); -void rl_save_prompt(void); -void rl_set_prompt(const char *); -void rl_uninitialize(void); - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_THIRD_PARTY_EDITLINE_EDITLINE_H_ */ diff --git a/third_party/editline/editline.mk b/third_party/editline/editline.mk deleted file mode 100644 index d98bc7cd..00000000 --- a/third_party/editline/editline.mk +++ /dev/null @@ -1,57 +0,0 @@ -#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ -#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ - -PKGS += THIRD_PARTY_EDITLINE - -THIRD_PARTY_EDITLINE_ARTIFACTS += THIRD_PARTY_EDITLINE_A -THIRD_PARTY_EDITLINE = $(THIRD_PARTY_EDITLINE_A_DEPS) $(THIRD_PARTY_EDITLINE_A) -THIRD_PARTY_EDITLINE_A = o/$(MODE)/third_party/editline/editline.a -THIRD_PARTY_EDITLINE_A_FILES := $(wildcard third_party/editline/*) -THIRD_PARTY_EDITLINE_A_HDRS = $(filter %.h,$(THIRD_PARTY_EDITLINE_A_FILES)) -THIRD_PARTY_EDITLINE_A_SRCS = $(filter %.c,$(THIRD_PARTY_EDITLINE_A_FILES)) - -THIRD_PARTY_EDITLINE_A_OBJS = \ - $(THIRD_PARTY_EDITLINE_A_SRCS:%=o/$(MODE)/%.zip.o) \ - $(THIRD_PARTY_EDITLINE_A_SRCS:%.c=o/$(MODE)/%.o) - -THIRD_PARTY_EDITLINE_A_CHECKS = \ - $(THIRD_PARTY_EDITLINE_A).pkg - -THIRD_PARTY_EDITLINE_A_DIRECTDEPS = \ - LIBC_ALG \ - LIBC_CALLS \ - LIBC_CALLS_HEFTY \ - LIBC_FMT \ - LIBC_LOG \ - LIBC_MEM \ - LIBC_NEXGEN32E \ - LIBC_STDIO \ - LIBC_STR \ - LIBC_STUBS \ - LIBC_SYSV - -THIRD_PARTY_EDITLINE_A_DEPS := \ - $(call uniq,$(foreach x,$(THIRD_PARTY_EDITLINE_A_DIRECTDEPS),$($(x)))) - -$(THIRD_PARTY_EDITLINE_A): \ - third_party/editline/ \ - $(THIRD_PARTY_EDITLINE_A).pkg \ - $(THIRD_PARTY_EDITLINE_A_OBJS) - -$(THIRD_PARTY_EDITLINE_A).pkg: \ - $(THIRD_PARTY_EDITLINE_A_OBJS) \ - $(foreach x,$(THIRD_PARTY_EDITLINE_A_DIRECTDEPS),$($(x)_A).pkg) - -THIRD_PARTY_EDITLINE_LIBS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x))) -THIRD_PARTY_EDITLINE_SRCS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x)_SRCS)) -THIRD_PARTY_EDITLINE_HDRS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x)_HDRS)) -THIRD_PARTY_EDITLINE_BINS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x)_BINS)) -THIRD_PARTY_EDITLINE_CHECKS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x)_CHECKS)) -THIRD_PARTY_EDITLINE_OBJS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x)_OBJS)) -THIRD_PARTY_EDITLINE_TESTS = $(foreach x,$(THIRD_PARTY_EDITLINE_ARTIFACTS),$($(x)_TESTS)) -$(THIRD_PARTY_EDITLINE_OBJS): third_party/editline/editline.mk - -.PHONY: o/$(MODE)/third_party/editline -o/$(MODE)/third_party/editline: \ - $(THIRD_PARTY_EDITLINE) \ - $(THIRD_PARTY_EDITLINE_CHECKS) diff --git a/third_party/editline/internal.h b/third_party/editline/internal.h deleted file mode 100644 index 6eccdd30..00000000 --- a/third_party/editline/internal.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef COSMOPOLITAN_THIRD_PARTY_EDITLINE_INTERNAL_H_ -#define COSMOPOLITAN_THIRD_PARTY_EDITLINE_INTERNAL_H_ -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -#define MEM_INC 64 -#define SCREEN_INC 256 - -extern int rl_eof; -extern int rl_erase; -extern int rl_intr; -extern int rl_kill; -extern int rl_quit; -extern int rl_susp; - -void rl_ttyset(int); -void rl_add_slash(char *, char *); - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_THIRD_PARTY_EDITLINE_INTERNAL_H_ */ diff --git a/third_party/editline/sysunix.c b/third_party/editline/sysunix.c deleted file mode 100644 index ec52494c..00000000 --- a/third_party/editline/sysunix.c +++ /dev/null @@ -1,112 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ 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; version 2 of the License. │ -│ │ -│ 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 │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" -#include "libc/calls/struct/stat.h" -#include "libc/calls/termios.h" -#include "libc/errno.h" -#include "libc/log/log.h" -#include "libc/str/str.h" -#include "libc/sysv/consts/termios.h" -#include "third_party/editline/editline.h" -#include "third_party/editline/internal.h" - -asm(".ident\t\"\\n\\n\ -Cosmopolitan Linenoise (BSD-like license)\\n\ -Copyright 2019 Justine Alexandra Roberts Tunney\\n\ -Copyright 1992,1993 Simmule Turner and Rich Salz\\n\ -All rights reserved.\\n\ -\\n\ -This software is not subject to any license of the American Telephone\\n\ -and Telegraph Company or of the Regents of the University of California.\\n\ -\\n\ -Permission is granted to anyone to use this software for any purpose on\\n\ -any computer system, and to alter it and redistribute it freely, subject\\n\ -to the following restrictions:\\n\ -1. The authors are not responsible for the consequences of use of this\\n\ - software, no matter how awful, even if they arise from flaws in it.\\n\ -2. The origin of this software must not be misrepresented, either by\\n\ - explicit claim or by omission. Since few users ever read sources,\\n\ - credits must appear in the documentation.\\n\ -3. Altered versions must be plainly marked as such, and must not be\\n\ - misrepresented as being the original software. Since few users\\n\ - ever read sources, credits must appear in the documentation.\\n\ -4. This notice may not be removed or altered.\""); -asm(".include \"libc/disclaimer.inc\""); - -/* Wrapper for tcgetattr */ -static int getattr(int fd, struct termios *arg) { - int result, retries = 3; - while (-1 == (result = tcgetattr(fd, arg)) && retries > 0) { - retries--; - if (EINTR == errno) continue; - break; - } - return result; -} - -/* Wrapper for tcgetattr */ -static int setattr(int fd, int opt, const struct termios *arg) { - int result, retries = 3; - while (-1 == (result = tcsetattr(fd, opt, arg)) && retries > 0) { - retries--; - if (EINTR == errno) continue; - break; - } - return result; -} - -void rl_ttyset(int Reset) { - static struct termios old; - struct termios new; - if (!Reset) { - if (-1 == getattr(0, &old)) { - perror("Failed tcgetattr()"); - } - rl_erase = old.c_cc[VERASE]; - rl_kill = old.c_cc[VKILL]; - rl_eof = old.c_cc[VEOF]; - rl_intr = old.c_cc[VINTR]; - rl_quit = old.c_cc[VQUIT]; -#ifdef CONFIG_SIGSTOP - rl_susp = old.c_cc[VSUSP]; -#endif - new = old; - new.c_lflag &= ~(ECHO | ICANON | ISIG); - new.c_iflag &= ~INPCK; - if (rl_meta_chars) - new.c_iflag |= ISTRIP; - else - new.c_iflag &= ~ISTRIP; - new.c_cc[VMIN] = 1; - new.c_cc[VTIME] = 0; - if (-1 == setattr(0, TCSADRAIN, &new)) { - perror("Failed tcsetattr(TCSADRAIN)"); - } - } else { - if (-1 == setattr(0, TCSADRAIN, &old)) { - perror("Failed tcsetattr(TCSADRAIN)"); - } - } -} - -void rl_add_slash(char *path, char *p) { - struct stat Sb; - if (stat(path, &Sb) >= 0) strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " "); -} diff --git a/third_party/lex/COPYING b/third_party/lex/COPYING deleted file mode 100644 index aa3af4ef..00000000 --- a/third_party/lex/COPYING +++ /dev/null @@ -1,43 +0,0 @@ -.ident "\n -Flex carries the copyright used for BSD software, slightly modified -because it originated at the Lawrence Berkeley (not Livermore!) Laboratory, -which operates under a contract with the Department of Energy: - -Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Flex Project. - -Copyright (c) 1990, 1997 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. - -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. - -This basically says \"do whatever you please with this software except -remove this notice or take advantage of the University's (or the flex -authors') name\". - -Note that the \"flex.skl\" scanner skeleton carries no copyright notice. -You are free to do whatever you please with scanners generated using flex; -for them, you are not even bound by the above copyright." diff --git a/third_party/lex/ChangeLog b/third_party/lex/ChangeLog deleted file mode 100644 index 5276ae63..00000000 --- a/third_party/lex/ChangeLog +++ /dev/null @@ -1,8226 +0,0 @@ -2019-06-08 Justine Tunney - - * Lex is now available in Cosmopolitan, thanks to OpenBSD! - -2014-02-16 Translation Project - - * po/ru.po: update ru translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated da translation in release news - -2014-02-14 Translation Project - - * po/da.po: update da translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated es translation in release news - -2014-02-14 Translation Project - - * po/es.po: update es translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated ko translation in release news - -2014-02-14 Translation Project - - * po/ko.po: update ko translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated ro translation in release news - -2014-02-14 Translation Project - - * po/ro.po: update ro translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated ru translation in release news - -2014-02-14 Translation Project - - * po/ru.po: update ru translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated sv translation in news - -2014-02-14 Translation Project - - * po/sv.po: update sv translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated tr translation in news - -2014-02-14 Translation Project - - * po/tr.po: update tr translation from the translation project - -2014-02-14 Will Estes - - * NEWS: mention updated zh_CN in release news - -2014-02-14 Translation Project - - * po/zh_CN.po: update zh_CN translation from the translation project - -2014-02-14 Will Estes - - * NEWS, po/LINGUAS, po/zh_TW.po, po/zh_tw.po: rename zh_tw - translation to its proper zh_TW name - -2014-02-14 Will Estes - - * NEWS: mention updated nl, vi translations in release news - -2014-02-14 Translation Project - - * po/vi.po: update vi translation from the translation project - -2014-02-14 Translation Project - - * po/nl.po: update nl translation from the translation project - -2014-02-14 Will Estes - - * TODO: remove some unneeded entries from the todo list - -2014-02-13 Will Estes - - * doc/Makefile.am: list more generated files in CLEANFILES - -2014-02-13 Will Estes - - * doc/flex.xml: remove unmaintained xml documentation - -2014-02-13 Will Estes - - * configure.ac: bump AM_GNU_GETTEXT_VERSION to 0.18.1 - -2014-02-13 Will Estes - - * README: list new location of flex git repo - -2014-02-13 Will Estes - - * po/.gitignore: git ignore generated files from english quoting - variant translations - -2014-02-13 Will Estes - - * po/LINGUAS: name english quoting variants correctly - -2014-02-13 Will Estes - - * Makefile.am, configure.ac, tools/Makefile.am: removed tools/ - subdirectory from distribution Since it is not possible to rebuild the ChangeLog file without being - in a git working directory of flex, distributing the tools directory - is misleading. In particular, git2cl will always fail. - -2014-02-13 Will Estes - - * po/LINGUAS: removed unneeded blank line from translation list - -2014-02-13 Will Estes - - * po/LINGUAS: added en quoting variants to translation list - -2014-02-11 Will Estes - - * configure.ac: use gnu automake option instead of gnits option - -2014-02-11 Will Estes - - * README-alpha: remove README_alpha file since it is no longer - needed - -2014-02-10 Will Estes - - * configure.ac: increment version to 2.5.38 - -2013-11-27 Will Estes - - * NEWS: flesh out internationalization section of NEWS file; mention - pt_BR translation - -2013-11-27 Translation Project - - * po/pt_BR.po: update pt_BR translation from the translation project - -2013-10-31 Will Estes - - * NEWS: begin listing 2.5.38 version in NEWS; list new sr - translation - -2013-10-31 Will Estes - - * po/LINGUAS: list new sr translation in list of translations - -2013-10-31 Will Estes - - * po/sr.po: add sr translation from the translation project - -2013-07-02 Till Varoquaux - - * configure.ac, flex.skl, nfa.c, tests/Makefile.am, - tests/test-lineno-trailing/.gitignore, - tests/test-lineno-trailing/Makefile.am, - tests/test-lineno-trailing/scanner.l, - tests/test-lineno-trailing/test.input: Adjust yylineno properly when - rewinding trailing contexts. - -2013-05-28 Will Estes - - * Makefile.am: Remove incorrect / in install-exec-hook target - -2013-02-16 Translation Project - - * po/LINGUAS, po/zh_tw.po: add zh_tw translation from the - translation project - -2012-12-06 Christoph Junghans - - * Makefile.am, configure.ac: add version information to shared - library Signed-off-by: Will Estes - -2012-12-04 Christoph Junghans - - * .gitignore, Makefile.am, configure.ac, lib/Makefile.am: Build - libfl and libcompat using libtool; resolves #3586814 Signed-off-by: Will Estes - -2012-12-04 Translation Project - - * po/ca.po: update ca translation - -2012-10-31 Hugh Sasse - - * tests/test-extended/Makefile.am, tests/test-quotes/Makefile.am: - use cmp instead of diff in some tests for portability reasons Signed-off-by: Will Estes - -2012-10-31 Dennis Clarke - - * tests/TEMPLATE/Makefile.am, tests/test-alloc-extra/Makefile.am, - tests/test-array-nr/Makefile.am, tests/test-array-r/Makefile.am, - tests/test-basic-nr/Makefile.am, tests/test-basic-r/Makefile.am, - tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c++-basic/Makefile.am, - tests/test-c++-multiple-scanners/Makefile.am, - tests/test-c++-yywrap/Makefile.am, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-r/Makefile.am, tests/test-ccl/Makefile.am, - tests/test-debug-nr/Makefile.am, tests/test-debug-r/Makefile.am, - tests/test-extended/Makefile.am, tests/test-header-nr/Makefile.am, - tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-push/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-linedir-r/Makefile.am, tests/test-lineno-nr/Makefile.am, - tests/test-lineno-r/Makefile.am, tests/test-mem-nr/Makefile.am, - tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-noansi-nr/Makefile.am, tests/test-noansi-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-quotes/Makefile.am, - tests/test-reject/Makefile.am, tests/test-rescan-nr/Makefile.am, - tests/test-rescan-r/Makefile.am, tests/test-string-nr/Makefile.am, - tests/test-string-r/Makefile.am, tests/test-table-opts/Makefile.am, - tests/test-top/Makefile.am, tests/test-yyextra/Makefile.am: add - CFLAGS and CXXFLAGS options as appropriate to testsuite Makefile.am - files Signed-off-by: Will Estes - -2012-10-25 Will Estes - - * po/LINGUAS: add hr to list of translations - -2012-10-25 Translation Project - - * po/hr.po: add hr translation from the translation project - -2012-10-25 Translation Project - - * po/fr.po: new fr translation project from the translation project - -2012-09-08 Will Estes - - * po/LINGUAS: update languages list to include esperanto translation - -2012-09-08 Translation Project - - * po/eo.po: add eo translation from the translation project - -2012-08-26 Will Estes - - * configure.ac: add dist-xz to automake options; resolves #3561837 - -2012-08-26 Will Estes - - * autogen.sh, configure.ac: require gettext 0.18; force autoreconf - in autogen.sh; resolves #3561759 Autoconf had trouble finding the shared libraries for gettext. Using - gettext 0.18 fixes that. When updating the gettext version number, autoreconf could fail to - update files, since autopoint would assume the gettext-related files - had been locally modified. Passing --force prevents that from - happening. - -2012-08-15 Will Estes - - * Makefile.am: remove README.cvs from dist_doc_DATA in Makefile.am - -2012-08-13 Will Estes - - * : commit 9256a268e2a1000cb410766e95487912a7d66d61 Author: Will - Estes Date: Mon Aug 13 16:23:35 2012 -0400 - -2012-08-08 Will Estes - - * README, README.cvs: append README.cvs contents to README - -2012-08-08 Will Estes - - * gen.c: fix m4 error when useecs and nultrans are true; resolves - #1816878 - -2012-08-08 Robert Minsk - - * flex.skl: put user code after yyguts init; resolves #1744516 Signed-off-by: Will Estes - -2012-08-08 Robert Minsk - - * flex.skl, main.c: do not output yy_nxt to header with %option - full; resolves #1739922 Signed-off-by: Will Estes - -2012-08-07 Will Estes - - * main.c: let flex decide if yymore and reject are needed in lex - compatible mode This resolves bug #3510440. - -2012-08-06 Translation Project - - * po/vi.po: new vi translation from the translation project - -2012-08-06 Will Estes - - * .gitignore: add more patterns to .gitignore Undersome circumstances, the build process will generate conf.in~, - which we want to ignore. Also, some patch files will apply but not - cleanly and *.orig and *.rej files are generated. We want to ignore - them as well. - -2012-08-06 Will Estes - - * configure.ac, configure.in: rename configure.in to configure.ac to - prep for upcoming automake changes - -2012-08-06 Elias Pipping - - * tests/test-bison-yylloc/main.c, tests/test-bison-yylloc/parser.y, - tests/test-bison-yylval/main.c, tests/test-bison-yylval/parser.y: - Fix two tests to pass under bison 2.6 Given that bison is moving forward with the %parse-param instead of - YYPARSE_PARAM syntax, it makes sense to switch over to using the new - style declaration. In particular, this means that flex scanners that - use bison features will now require bison 2.6 or higher. Signed-off-by: Will Estes - -2012-08-04 Will Estes - - * po/nl.po: new nl translation from the translation project - -2012-08-04 Mike Frysinger - - * flexdef.h: add prototype for lerrsf_fatal to flexdef.h Signed-off-by: Will Estes - -2012-08-04 nomis52 - - * flex.skl, gen.c: Change variable types to silence compiler - warnings; resolves #3552806 Signed-off-by: Will Estes - -2012-08-03 Will Estes - - * NEWS: update NEWS to reflect changes in 2.5.37 - -2012-08-03 Will Estes - - * configure.in: update flex version to 2.5.37 - -2012-08-03 Will Estes - - * po/de.po: new de translation from the translation project - -2012-08-02 Will Estes - - * po/vi.po: new vi translation from the translation project - -2012-08-02 Will Estes - - * po/pl.po: new pl translation from the translation project - -2012-08-02 Will Estes - - * po/fi.po: new fi translation from the translation project - -2012-08-02 Will Estes - - * Makefile.am: Add -f option to LN_S to create flex++ The autoconf macro LN_S needs -f to successfully install flex++ if - flex++ already exists. Fortunately, ln, ln -s and cp -p, which are - the various forms that LN_S can take all will do the right thing - with a -f argument passed. - -2012-08-02 Will Estes - - * Makefile.am, tools/Makefile.am, tools/cvs2cl.pl, - tools/cvsauthors, tools/git2cl: replace cvs2cl with git2cl Add the git2cl script in tools/ and remove the (now unnecessary) - cvs2cl script. Remove tools/cvsauthors since git2cl does not need - that file. Account for all the above in Makefile.am and - tools/Makefile.am - -2012-07-29 Will Estes - - * tests/.cvsignore, tests/.gitignore, tests/TEMPLATE/.cvsignore, - tests/TEMPLATE/.gitignore, tests/test-alloc-extra/.cvsignore, - tests/test-alloc-extra/.gitignore, tests/test-array-nr/.cvsignore, - tests/test-array-nr/.gitignore, tests/test-array-r/.cvsignore, - tests/test-array-r/.gitignore, tests/test-basic-nr/.cvsignore, - tests/test-basic-nr/.gitignore, tests/test-basic-r/.cvsignore, - tests/test-basic-r/.gitignore, tests/test-bison-nr/.cvsignore, - tests/test-bison-nr/.gitignore, tests/test-bison-yylloc/.cvsignore, - tests/test-bison-yylloc/.gitignore, - tests/test-bison-yylval/.cvsignore, - tests/test-bison-yylval/.gitignore, - tests/test-c++-basic/.cvsignore, tests/test-c++-basic/.gitignore, - tests/test-c++-multiple-scanners/.cvsignore, - tests/test-c++-multiple-scanners/.gitignore, - tests/test-c++-yywrap/.cvsignore, tests/test-c++-yywrap/.gitignore, - tests/test-c-cpp-nr/.cvsignore, tests/test-c-cpp-nr/.gitignore, - tests/test-c-cpp-r/.cvsignore, tests/test-c-cpp-r/.gitignore, - tests/test-ccl/.cvsignore, tests/test-ccl/.gitignore, - tests/test-concatenated-options/.cvsignore, - tests/test-concatenated-options/.gitignore, - tests/test-debug-nr/.cvsignore, tests/test-debug-nr/.gitignore, - tests/test-debug-r/.cvsignore, tests/test-debug-r/.gitignore, - tests/test-extended/.cvsignore, tests/test-extended/.gitignore, - tests/test-header-nr/.cvsignore, tests/test-header-nr/.gitignore, - tests/test-header-r/.cvsignore, tests/test-header-r/.gitignore, - tests/test-include-by-buffer/.cvsignore, - tests/test-include-by-buffer/.gitignore, - tests/test-include-by-push/.cvsignore, - tests/test-include-by-push/.gitignore, - tests/test-include-by-reentrant/.cvsignore, - tests/test-include-by-reentrant/.gitignore, - tests/test-linedir-r/.cvsignore, tests/test-linedir-r/.gitignore, - tests/test-lineno-nr/.cvsignore, tests/test-lineno-nr/.gitignore, - tests/test-lineno-r/.cvsignore, tests/test-lineno-r/.gitignore, - tests/test-mem-nr/.cvsignore, tests/test-mem-nr/.gitignore, - tests/test-mem-r/.cvsignore, tests/test-mem-r/.gitignore, - tests/test-multiple-scanners-nr/.cvsignore, - tests/test-multiple-scanners-nr/.gitignore, - tests/test-multiple-scanners-r/.cvsignore, - tests/test-multiple-scanners-r/.gitignore, - tests/test-noansi-nr/.cvsignore, tests/test-noansi-nr/.gitignore, - tests/test-noansi-r/.cvsignore, tests/test-noansi-r/.gitignore, - tests/test-posix/.cvsignore, tests/test-posix/.gitignore, - tests/test-posixly-correct/.cvsignore, - tests/test-posixly-correct/.gitignore, - tests/test-prefix-nr/.cvsignore, tests/test-prefix-nr/.gitignore, - tests/test-prefix-r/.cvsignore, tests/test-prefix-r/.gitignore, - tests/test-pthread/.cvsignore, tests/test-pthread/.gitignore, - tests/test-quotes/.cvsignore, tests/test-quotes/.gitignore, - tests/test-reject/.cvsignore, tests/test-reject/.gitignore, - tests/test-rescan-nr/.cvsignore, tests/test-rescan-nr/.gitignore, - tests/test-rescan-r/.cvsignore, tests/test-rescan-r/.gitignore, - tests/test-string-nr/.cvsignore, tests/test-string-nr/.gitignore, - tests/test-string-r/.cvsignore, tests/test-string-r/.gitignore, - tests/test-table-opts/.cvsignore, tests/test-table-opts/.gitignore, - tests/test-top/.cvsignore, tests/test-top/.gitignore, - tests/test-yyextra/.cvsignore, tests/test-yyextra/.gitignore: rename - .cvsignore files in tests/ subdirectories to gitignore - -2012-07-23 Will Estes - - * examples/.cvsignore, examples/fastwc/.cvsignore, - examples/manual/.cvsignore, lib/.cvsignore, tools/.cvsignore: remove - unneeded .cvsignore files - -2012-07-22 Will Estes - - * .gitignore: add *.o and *.a to top level .gitignore The cvs tree did not need these additions because cvs assumed a lot - of C-style defaults for .cvsignore files. flex builds *.o object - files in the course of compilation and *.a files are built as a part - of the libraries that flex compiles in the build process. - -2012-07-22 Will Estes - - * .cvsignore, .gitignore, doc/.cvsignore, doc/.gitignore, - m4/.cvsignore, m4/.gitignore, po/.cvsignore, po/.gitignore: rename - .cvsignore files to .gitignore The .cvsignore files from the legacy cvs repository tracked what - files got autogenerated during various stages of the flex build. - Renaming the .cvsignore files to .gitignore lets git do the same - thing. git is better about letting higher level .gitignore files - not-track files in lower level directories. As I work my way through - the test directories, we may add additional .gitignore files from - the old .cvsignore files. The po/ directory has a lot of special files used by gettext, so the - patterns in po/.gitignore look very different. The doc/.gitignore file accounts for what texinfo/makeinfo do, and - so it also has special patterns. The m4 directory is mainly present for autoconf's benefit, but we - have to account for it so make can do the right thing. Hence, - m4/.gitignore says to ignore *.m4, as counterintuitive as that may - seem. - -2012-07-22 Will Estes - - * NEWS: update NEWS file to note release date of 2.5.36 - -2012-06-23 Will Estes - - * doc/flex.texi: fix call to version in manual - -2012-06-22 Will Estes - - * doc/flex.texi: add missing argument to call to yylex in manual - -2012-04-27 Will Estes - - * flex.skl: lintish cleanup in flex.skl; resolves #2040664 - -2012-04-27 Will Estes - - * doc/flex.texi: add a 7 to the c99 octal pattern; resolves #3518269 - -2012-03-31 Will Estes - - * doc/flex.texi: copyedit; resolves #3513670 - -2012-03-23 Will Estes - - * buf.c: escape backslashes in #line filenames in %top section; - resolves #3212400; patch submitted by scfc_de - -2012-03-21 Will Estes - - * Makefile.am, configure.in, lib/Makefile.am, lib/lib.c, - lib/malloc.c, lib/realloc.c: provide malloc() and realloc() for - systems that do not have satisfactory versions; resolves #1899047 - -2012-03-21 Will Estes - - * Makefile.am: install flex++ as a link; resolves bug #2939681 - -2012-03-21 Will Estes - - * tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am: fix dependencies for make -j in - test suite - -2012-03-19 Will Estes - - * flex.skl: add missing prototypes for yyset_column() and - yyget_column(); resolves #3029024; patch submitted by scfc_de - -2012-03-02 Will Estes - - * flex.skl, tests/test-reject/scanner.l, - tests/test-table-opts/scanner.l: wrap yy_fatal_error calls - appropriately - -2012-03-02 Will Estes - - * regex.c: fix overlapping data buffer issue; patch from Tim - Landsheet scfc_de - -2012-03-02 Will Estes - - * scan.l: better bracket handling in the scanner - -2012-03-02 Will Estes - - * flexdef.h, main.c, misc.c: Remove unneeded tracking of line/column - output; patch from Tim Landsheet scfc_de - -2012-03-02 Will Estes - - * configure.in: fix test for m4 to accept an m4 with -P and not jus - tGNU m4; patch from Tim Landsheet scfc_de on sourceforge - -2012-03-02 Will Estes - - * doc/flex.texi: fix order of td_lolen and td_hilen in - documentation; resolves #2913693; patch submitted by Andreas - Gruenbacher - -2012-03-02 Will Estes - - * doc/flex.texi: correct document of YY_FLUSH_BUFFER; resolves - #1723028 - -2012-02-17 Will Estes - - * dfa.c, flexdef.h, misc.c, parse.y: speed up things for complex - inputs; resolves #2891390 - -2012-02-17 Will Estes - - * doc/flex.texi: fix ipv6 pattern in manual; update manual copyright - to 2012 - -2012-02-17 Will Estes - - * flex.skl: fremove isatty() declaration; resolves #1984987 - -2012-02-17 Will Estes - - * doc/flex.texi: Add link for RFC 2396 - -2012-02-17 Will Estes - - * flex.skl: resolve #1990170 - -2012-02-17 Will Estes - - * flex.skl: fix documentation to reflect arguments actually used; - bug #2783023 - -2012-02-05 Will Estes - - * main.c: fix yywrap behavior for reentrant scanners - -2012-02-04 Will Estes - - * NEWS: Mmention tr translation - -2012-02-04 Will Estes - - * tables.c: prevent unused stuff from being compiled so as to reduce - warnings - -2012-02-03 Will Estes - - * buf.c, filter.c, main.c, misc.c, regex.c, scanflags.c: more better - error messages; more better memory handling - -2012-02-03 Will Estes - - * misc.c: more careful/paranoia - -2012-02-03 Will Estes - - * scanopt.c: more careful memory allocation in option processing - -2012-02-03 Will Estes - - * Makefile.am, configure.in: remove m4/ directory and generally - clean up automake/autoconf inputs - -2012-02-03 Will Estes - - * lib/.cvsignore: cvsignore files that need that - -2012-02-03 Will Estes - - * NEWS, po/da.po, po/es.po, po/ko.po, po/pt_BR.po, po/ro.po, - po/ru.po, po/sv.po, po/tr.po, po/zh_CN.po: check in translations - -2012-02-03 Will Estes - - * main.c: correct macro definition of yywrap - -2012-02-03 Will Estes - - * scan.l: Greater specificity in error messages - -2012-02-03 Will Estes - - * parse.y: improve rule handling at EOF - -2012-02-03 Will Estes - - * flex.skl: include cstdio for definition of EOF in all cases - -2012-02-03 Will Estes - - * flex.skl: suppress warning on unused yyguts_t - -2010-08-13 Will Estes - - * NEWS, po/LINGUAS, po/fi.po: new fi translation from the - translation project - -2009-03-31 Will Estes - - * doc/flex.texi: Include version.texi after @setfilename, so that @set values are correctly evaluated. (Start Conditions, Performance, Lex and Posix): Fix some markup errors. (Cxx): Likewise. Also, fix C++ example to actually be compilable. Patch from Ralf Wildenhues - -2008-12-28 Will Estes - - * configure.in: remove line break that broke configure - -2008-12-28 Will Estes - - * doc/flex.texi: specify the title on the title page since @settitle - doesn't do that for us; resolves bug #2043491 - -2008-12-28 Will Estes - - * configure.in, flexdef.h: check for regex.h; resolves bug #2337486 - -2008-07-23 Will Estes - - * NEWS, po/ga.po: new ga translation from the translation project - -2008-06-10 Will Estes - - * NEWS, po/ca.po: new ca translation - -2008-05-31 Will Estes - - * Makefile.am: move ABOUT-NLS back to EXTRA_DIST - -2008-05-31 Will Estes - - * Makefile.am: create new dist_doc_DATA; move some EXTRA_DIST files - to new dist_doc_DATA target - -2008-05-31 Will Estes - - * .cvsignore: ignore more automake generated config.status* files - -2008-05-31 Will Estes - - * NEWS: flex distribution now built with automake and autoconf - versions ... - -2008-05-31 Will Estes - - * README.cvs: document GNU auto* version changes for building flex - from cvs - -2008-05-31 Will Estes - - * .cvsignore, doc/Makefile.am: ignore automake-supplied ylwrap - -2008-05-15 Will Estes - - * NEWS, flex.skl: clean up types; resolves 1961902 - -2008-05-15 Will Estes - - * NEWS: update NEWS re manual - -2008-05-15 Will Estes - - * doc/flex.texi: correct eroneous references to 'nowrap' to refer to - 'noyywrap'; resolves bug #1739912 - -2008-05-14 Will Estes - - * filter.c: call clearerr on stdin before dup2'ing it; resolves bug - #1902612 - -2008-05-14 Will Estes - - * NEWS: generic updates to NEWS - -2008-05-14 Will Estes - - * tests/test-pthread/Makefile.am: move library flags in linker - command; resolves patch #1943403; patch submitted by - nullnix@users.sourceforge.net - -2008-05-14 Will Estes - - * doc/flex.texi: use ansi syntax in simple examples; resolves patch - #1909844; patch submitted by Tom Browder, - tbrowder2@users.sourceforge.net - -2008-04-10 Will Estes - - * doc/flex.texi: fix typo in example (from Paolo J. Matos - -2008-04-10 Will Estes - - * flexint.h: move endif to better account for what C99 defines for - integer types (fix from debian project) - -2008-04-10 Will Estes - - * gen.c: fix another int type to be size_t - -2008-03-30 Will Estes - - * NEWS, po/fr.po: new fr translation - -2008-03-30 Will Estes - - * NEWS, configure.in: start version 2.5.36 - -2008-02-26 Will Estes - - * NEWS: add date of release - -2008-02-15 Will Estes - - * NEWS, parse.y: fix bug that prevented comments from working - properly - -2008-02-12 Will Estes - - * po/de.po: new de translation - -2008-02-10 Will Estes - - * NEWS, po/vi.po: new vi translation - -2008-02-10 Will Estes - - * NEWS, po/nl.po: new nl translation - -2008-02-09 Will Estes - - * NEWS, po/pl.po: new pl translation - -2008-02-09 Will Estes - - * NEWS, po/de.po, po/pt_BR.po: new de, pt_br translations - -2008-02-09 Will Estes - - * NEWS, flex.skl: generate headers for all functions (resolves bug - #1628314) - -2008-02-09 Will Estes - - * NEWS, flex.skl: change yy_size_t to be size_t (resolves bug - #1849812) - -2008-02-09 Will Estes - - * configure.in: start work on version 2.5.35 - -2007-12-12 Will Estes - - * NEWS, configure.in: revert NEWS and configure.in to version 2.5.34 - -2007-09-12 Will Estes - - * NEWS, configure.in: update version number to 2.5.35 - -2007-09-10 Aaron Stone - - * tests/test-alloc-extra/scanner.l: Use %option extra-type. - -2007-09-10 Aaron Stone - - * NEWS, doc/flex.texi, flex.skl, flexdef.h, main.c, parse.y, scan.l: - Introduce %option extra-type="your_type *" (resolves bug #1744505). - -2007-08-15 Will Estes - - * po/nl.po: new nl translations from the translation project - -2007-06-28 Will Estes - - * NEWS: change release date - -2007-06-28 Will Estes - - * flex.skl: adjustment for prefix classes; patch submitted by Petr - Machata - -2007-06-28 Will Estes - - * NEWS: NEWS item for yy_init_extra - -2007-06-12 Aaron Stone - - * doc/flex.texi: Docs and example for yylex_init_extra. - -2007-06-01 Will Estes - - * tests/test-alloc-extra/.cvsignore: ignore OUTPUT file in - test-alloc-extra - -2007-06-01 Will Estes - - * tests/descriptions: add description of concatenated options test - -2007-05-31 Will Estes - - * tests/test-alloc-extra/.cvsignore: add missing .cvsignore to - test-alloc-extra - -2007-05-31 Aaron Stone - - * configure.in, flex.skl, gen.c, main.c: Changes to resolve SF bugs - 1568325 and 1563589. - -2007-05-31 Aaron Stone - - * tests/Makefile.am, tests/descriptions, - tests/test-alloc-extra/Makefile.am, - tests/test-alloc-extra/scanner.l, tests/test-alloc-extra/test.input: - Adding test cases for yylex_init_extra. - -2007-05-12 Will Estes - - * configure.in, tests/test-pthread/scanner.l: fixes to test-pthread - -2007-05-12 Will Estes - - * NEWS: NEWS item for concatenated options - -2007-05-12 Will Estes - - * configure.in, tests/Makefile.am, - tests/test-concatenated-options/.cvsignore, - tests/test-concatenated-options/Makefile.am: unit test to verify - concatenated options parsing - -2007-05-12 Will Estes - - * scanopt.c: parse multiple short concatenated options; patch - submitted by Petr Machata - - * autogen.sh: remove --force option from autogen.sh; much faster - without it - -2007-05-11 Will Estes - - * NEWS, configure.in: version 2.5.34 - -2007-05-08 Aaron Stone - - * NEWS, flex.skl: Better checking after yyalloc/yyrealloc (resolves - bug #1595967) - -2007-05-01 Will Estes - - * doc/flex.texi: change title of manual to 'Lexical Analysis with - Flex' - -2007-04-25 Will Estes - - * flex.skl: c++ memory leak plug - -2007-04-23 Will Estes - - * flex.skl: roll back c++ memory patch as it causes the test suite - no end of grief - -2007-04-23 Will Estes - - * flex.skl: fix function definitions for non-ANSI environments (from - Manoj Srivastava from Debian patchset) - -2007-04-23 Will Estes - - * flex.skl: fix c++ memory leak (from Manoj Srivastava from Debian - patchset) - -2007-04-23 Will Estes - - * flex.skl: fix parameter name in comment (patch from Manoj - Srivastava from the debian patchset - -2007-04-23 Will Estes - - * flex.skl: add a size_t cast (patch from Manoj Srivastava from the - debian patchset - -2007-04-16 Will Estes - - * tests/test-extended/Makefile.am, tests/test-quotes/Makefile.am: - cleanups to handle VPATH builds better; passifies make distcheck - -2007-04-16 Will Estes - - * doc/flex.texi: drop using the \ in \ escaping as it throws pdf - generation for a loop - -2007-04-14 Will Estes - - * .cvsignore: add compile and *.tar.bz2 to .cvsignore - -2007-04-14 Will Estes - - * main.c: add call to setlocale for ctype as per debian patchset - -2007-04-14 Will Estes - - * Makefile.am, NEWS: provide for a PIC version of libfl.a for shared - libraries using flex scanners - -2007-04-13 Will Estes - - * FlexLexer.h: annotate endifs since they're a bit far from their - opening #if statements - -2007-04-13 Will Estes - - * flexdef.h, parse.y: refactor and slightly redo alloca testing, - resolves bug #1675899 - -2007-04-13 Will Estes - - * : overhaul configure.in: use octathorps for comments so they're - passed through m4 processing; better bracketing of m4 arguments; - retool checks as per suggestions from autoscan(1) - -2007-04-13 Will Estes - - * flex.skl: fix skeleton for reentrant scanners - -2007-04-13 Will Estes - - * Makefile.am: remove homegrown tags target; automake does that for - us - -2007-04-12 Will Estes - - * flex.skl: fix skeleton for reentrant scanners, resolves bug - #1694318 - -2007-04-12 Will Estes - - * FlexLexer.h: declare some const where missing in c++ header file - -2007-04-10 Will Estes - - * doc/flex.texi: corrections to the manual as per suggestions from - flex-help@ - -2007-04-03 Will Estes - - * doc/flex.texi: include author names in online versions of the - manual - -2007-04-03 Will Estes - - * COPYING: update copyright notice - -2007-04-03 Will Estes - - * AUTHORS: rearrange and update AUTHORS - -2007-03-29 Will Estes - - * NEWS: note sf feature request 1658379 in NEWS - -2007-03-29 Will Estes - - * tools/cvsauthors: add sodabrew to cvsauthors file - -2007-03-29 Aaron Stone - - * flex.skl: SourceForge feature request #1658379: Expose YY_BUF_SIZE - in the header file. - -2007-03-07 Will Estes - - * NEWS, filter.c, flex.skl: apply patches submitted by sodabrew - -2007-03-07 Will Estes - - * README.cvs: more changes describing building flex from cvs - -2007-03-07 Will Estes - - * Makefile.am, README.cvs, README.cvs-snapshot: rename - README.cvs-snapshot to README.cvs - -2007-03-07 Will Estes - - * README.cvs-snapshot: update to explain where flex cvs lives - -2007-03-07 Will Estes - - * README, doc/flex.texi: correct how to submit bugs - -2007-02-16 Will Estes - - * NEWS: clarify NEWS item re man page and pdf manual - -2007-02-14 Will Estes - - * po/Makevars: update bug address to point to flex-devel instead of - lex-help - -2007-02-13 Will Estes - - * configure.in, doc/Makefile.am: make better use of AC_INIT; clean - up, simplify and make more robust the generation of the man page - -2007-02-13 Will Estes - - * configure.in: remove option check-news from call to - AM_INIT_AUTOMAKE as gnits implies check-news - -2007-02-13 Will Estes - - * Makefile.am, configure.in: move automake options from Makefile.am - to configure.in - -2007-02-13 Will Estes - - * autogen.sh: restore --install option to autogen.sh since --force - does not imply --install - -2007-02-13 Will Estes - - * tools/cvsauthors: add john43 to cvsauthors file - -2007-02-13 Will Estes - - * autogen.sh: call autoreconf with --force instead of --install - -2007-02-13 Will Estes - - * doc/.cvsignore: remove texinfo.tex from cvs tree - -2007-02-13 Will Estes - - * NEWS: updates to NEWS file to reflect recent changes - -2007-02-13 Will Estes - - * doc/Makefile.am: add flex.pdf to EXTRA_DIST - -2007-02-13 Will Estes - - * configure.in: remove flex.spec - -2007-02-13 Will Estes - - * Makefile.am: remove maintainercleanfiles - -2007-02-01 Will Estes - - * doc/Makefile.am: more changes to build system to distribute man - page - -2007-02-01 Will Estes - - * doc/Makefile.am: add flex man page to distribution - -2007-02-01 Will Estes - - * .cvsignore, flex.spec.in: remove flex spec file - -2006-11-17 Will Estes - - * tests/test-table-opts/Makefile.am: make test target depend on test - groupings, which in turn depend on building executables; cygwin - portability fix - -2006-11-10 Will Estes - - * tests/create-test: change create-test script to edit files in - place - -2006-11-09 Will Estes - - * tests/test-array-nr/Makefile.am, tests/test-array-r/Makefile.am, - tests/test-basic-nr/Makefile.am, tests/test-basic-r/Makefile.am, - tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c++-basic/Makefile.am, - tests/test-c++-multiple-scanners/Makefile.am, - tests/test-c++-yywrap/Makefile.am, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-r/Makefile.am, tests/test-ccl/Makefile.am, - tests/test-debug-nr/Makefile.am, tests/test-debug-r/Makefile.am, - tests/test-extended/Makefile.am, tests/test-header-nr/Makefile.am, - tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-push/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-linedir-r/Makefile.am, tests/test-lineno-nr/Makefile.am, - tests/test-lineno-r/Makefile.am, tests/test-mem-nr/Makefile.am, - tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-noansi-nr/Makefile.am, tests/test-noansi-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-quotes/Makefile.am, - tests/test-reject/Makefile.am, tests/test-rescan-nr/Makefile.am, - tests/test-rescan-r/Makefile.am, tests/test-string-nr/Makefile.am, - tests/test-string-r/Makefile.am, tests/test-top/Makefile.am, - tests/test-yyextra/Makefile.am: change CLEANFILES to include - instead of just the testname for the executable - -2006-11-09 Will Estes - - * doc/flex.texi: fix typos in manual; resolves bug #1592857 - -2006-11-09 Will Estes - - * tests/TEMPLATE/Makefile.am: change test template to remove test - executable when that executable has an extension, e.g. under Cygwin - -2006-11-08 Will Estes - - * tests/Makefile.am: test names weren't displaying in test - success/failure messages (from #1591672 - -2006-10-30 Will Estes - - * doc/.cvsignore: add flex.html to .cvsignore in doc directory - -2006-10-22 Will Estes - - * NEWS: update NEWS file for the work that millaway did - -2006-10-22 Will Estes - - * FlexLexer.h, NEWS, main.c, - tests/test-c++-multiple-scanners/scanner-2.l: make yywrap work with - c++ scanners as per sf bug report - -2006-10-20 Will Estes - - * NEWS, flex.skl, tests/test-c++-multiple-scanners/main.cpp, - tests/test-c-cpp-nr/scanner.l: memory leak issues in c++ scanner - -2006-10-20 Will Estes - - * NEWS, configure.in, tests/Makefile.am, tests/descriptions, - tests/test-c++-yywrap/.cvsignore, - tests/test-c++-yywrap/Makefile.am, tests/test-c++-yywrap/scanner.l, - tests/test-c++-yywrap/test.input: add unit test for c++ with yywrap - -2006-10-20 Will Estes - - * NEWS, tests/test-c++-basic/Makefile.am, - tests/test-linedir-r/Makefile.am: use configure-provided awk - variable for portability; add loadlibes variable to c++ test - -2006-10-17 Will Estes - - * doc/flex.texi: add noyywrap option to example; use whitespace to - clarify example - -2006-08-02 Will Estes - - * NEWS, po/ca.po, po/vi.po: new translations - -2006-04-11 John Millaway - - * tables.c: Casted away signedness to appease -Werror freaks. - -2006-03-28 John Millaway - - * ccl.c, doc/flex.texi, flexdef.h, parse.y, scan.l, sym.c, - tests/test-ccl/scanner.l, tests/test-ccl/test.input: Added ccl union - operator. Added test in test suite for ccl union operator. - Documented ccl union operator. Removed crufty ccl cache to prevent - parser problems. - -2006-03-28 John Millaway - - * doc/flex.texi, scan.l, tests/test-extended/scanner.l, - tests/test-extended/test.input: Extended syntax excluded for - lex/posix compat mode. Comments discarded inside (?x:) patterns. - Added test in test suite for comments in extended patterns. - Documented syntax additions. - -2006-03-27 John Millaway - - * scan.l, tests/test-ccl/scanner.l, tests/test-ccl/test.input: - Implemented (?x:) syntax to allow whitespace in patterns. Added - test for (?x:) syntax in test suite. - -2006-03-27 John Millaway - - * parse.y, tests/test-ccl/scanner.l, tests/test-ccl/test.input: - Implemented dot-all syntax. Added test for dot-all syntax in test - suite. - -2006-03-27 John Millaway - - * dfa.c, doc/flex.texi, flexdef.h, gen.c, main.c, parse.y, scan.l, - scanflags.c, tests/test-ccl/scanner.l, tests/test-ccl/test.input: - Removed global variable caseins. Added scanner stack flags for - case-insensitivity. Moved case-folding code from DFA-generation to - parse time read-macros. Added localized case-sensitivity syntax - from Perl. Added test for new syntax in test suite. Documented new - syntax. - -2006-03-27 John Millaway - - * Makefile.am, configure.in, flexdef.h, scanflags.c: Added configure - check for assert.h. Added scanner flags stack. - -2006-03-25 John Millaway - - * configure.in, doc/flex.texi, scan.l, tests/Makefile.am, - tests/descriptions, tests/test-extended/.cvsignore, - tests/test-extended/Makefile.am, tests/test-extended/scanner.l, - tests/test-extended/test.input: Added extended, perl-compatible - comment syntax. Added test for extended comment syntax. Documented - extended comment syntax. - -2006-03-25 John Millaway - - * doc/flex.texi, parse.y: Changed explicit 'A'-'Z' to isupper(), - where correct to do so. Documentation. - -2006-03-24 John Millaway - - * doc/flex.texi: Documentation. - -2006-03-24 John Millaway - - * doc/flex.texi: Added appendix of patterns to manual. - -2006-03-23 John Millaway - - * doc/flex.texi: . - -2006-03-22 John Millaway - - * doc/flex.texi: Documentation. - -2006-03-22 John Millaway - - * doc/flex.texi: Documented set difference operator {-}. - -2006-03-22 John Millaway - - * ccl.c, flexdef.h, parse.y, scan.l, tests/test-ccl/scanner.l, - tests/test-ccl/test.input: Added set difference operator {-} for - character classes. - -2006-03-22 John Millaway - - * configure.in, doc/flex.texi, parse.y, scan.l, tests/Makefile.am, - tests/descriptions, tests/test-ccl/.cvsignore, - tests/test-ccl/Makefile.am, tests/test-ccl/scanner.l, - tests/test-ccl/test.input: Added negated character class - expressions. Documented negated character class expressions. Added - regression test for negated character class expressions. - -2006-03-22 John Millaway - - * buf.c, filter.c, gen.c, main.c, misc.c, nfa.c, parse.y, regex.c: - Replaced sprintf with snprintf everywhere. - -2006-03-22 John Millaway - - * Makefile.am: Removed includedir from AM_CPPFLAGS #1439351. - -2006-03-21 John Millaway - - * configure.in, tests/Makefile.am, tests/descriptions, - tests/test-quotes/.cvsignore, tests/test-quotes/Makefile.am, - tests/test-quotes/scanner.l, tests/test-quotes/test.input: Added - test to verify user code is unmangled. - -2006-03-21 John Millaway - - * flexdef.h, misc.c, scan.l: Fixed escape in actions. - -2006-03-21 John Millaway - - * filter.c, flexdef.h, main.c, scan.l: Reverted previous input - filter changes. Added noop macro to scanner output. Modified - scan.l to escape m4 quotes found in user code. - -2006-03-21 John Millaway - - * tests/test-table-opts/Makefile.am, - tests/test-table-opts/scanner.l: Removed m4 from test-table-opts - -2006-03-21 John Millaway - - * tests/test-reject/Makefile.am, tests/test-reject/scanner.l: - Removed m4 from test-reject - -2006-03-21 John Millaway - - * filter.c, flexdef.h, main.c, scan.l: Moved set_input_file to - different file. - -2006-03-21 John Millaway - - * flex.skl, flexdef.h, flexint.h, misc.c: Relaxed tests for __STDC__ - and __STDC_VERSION__ to cope with bugs in GCC and Sun cc. - -2006-03-20 John Millaway - - * filter.c: Documented filter chain. Removed fdopen. Added no-op - fseek. - -2006-03-13 John Millaway - - * gen.c: Fixed another -Wall report. - -2006-03-10 Will Estes - - * NEWS, po/vi.po: new vi translation - -2006-03-09 Will Estes - - * NEWS, po/ga.po, po/nl.po: new nl, ga translations - -2006-02-21 Will Estes - - * m4/Makefile.am: add po.m4 to extra_dist in m4/ so it gets picked - up by distributions - -2006-02-21 Will Estes - - * m4/Makefile.am: add nls.m4 to extra_dist in m4/ so it will get - picked up in distribution tarballs - -2006-02-21 Will Estes - - * configure.in: remove website directory from configure.in - -2006-02-20 Will Estes - - * NEWS, configure.in: version 2.5.33 marks in NEWS and configure.in - -2006-02-20 Will Estes - - * configure.in: change email address in configure.in to point to - flex-help@sourceforge.net - -2006-02-20 John Millaway - - * doc/flex.texi: Documentation. - -2006-02-20 John Millaway - - * BUGS: Appended to BUGS file. - -2006-02-18 Will Estes - - * Makefile.am: remove website directory (since it now has its own - module in the flex project - -2006-02-16 John Millaway - - * doc/flex.texi, flex.skl: Fixed buffer overflow in reject state - buffer. Corrected documentation on the state buffer. - -2006-02-16 John Millaway - - * flex.skl: Reverted num_read from size_t back to int. - -2006-02-15 John Millaway - - * Makefile.am, configure.in: Removed reference to RoadMap in - Makefile.am. Added website directory. - -2006-02-15 Will Estes - - * README, RoadMap: remove RoadMap and reference to it in README - -2006-02-15 John Millaway - - * BUGS, README, doc/flex.texi, doc/flex.xml: Eliminated references - to lex.sf.net. - -2006-02-15 John Millaway - - * BUGS, flex.skl: Transfered bugs list from lex.sf.net to BUGS file. - -2006-02-15 John Millaway - - * tests/test-rescan-nr/.cvsignore, - tests/test-rescan-nr/Makefile.am, tests/test-rescan-nr/scanner.l, - tests/test-rescan-nr/test.input, tests/test-rescan-r/.cvsignore, - tests/test-rescan-r/Makefile.am, tests/test-rescan-r/scanner.l, - tests/test-rescan-r/test.input: Recommit of last commit -- broken - pipe. - -2006-02-15 John Millaway - - * configure.in, flex.skl, tests/Makefile.am, tests/descriptions: - yy_lex_destroy calls yy_init_globals to reset everything for next - call to yylex. Added two new tests for reusing scanners. - -2006-02-14 John Millaway - - * flex.spec.in: Patched rpm spec file. - -2006-02-14 John Millaway - - * configure.in, flexint.h: Added C99 macro for inttypes, just to be - conformant. - -2006-02-14 John Millaway - - * flexdef.h, nfa.c, parse.y: Changed symbol INFINITE to fix conflict - with C math symbol. - -2006-02-14 John Millaway - - * scan.l: Omitting parens for named rules in trailing context. - -2006-02-14 John Millaway - - * configure.in, main.c, po/ca.po, po/da.po, po/de.po, po/es.po, - po/fr.po, po/ga.po, po/ko.po, po/nl.po, po/pl.po, po/pt_BR.po, - po/ro.po, po/ru.po, po/sv.po, po/tr.po, po/vi.po, po/zh_CN.po, - tests/test-mem-nr/scanner.l, tests/test-mem-r/scanner.l: Added check - for locale.h and libintl.h in configure script. - -2006-02-14 John Millaway - - * flex.skl: Removed unused local vars. - -2006-02-14 John Millaway - - * flex.skl: Removed certain offending #undefs. - -2006-02-14 John Millaway - - * flexint.h: Removed logical and from preprocessor statement. - -2006-02-14 Will Estes - - * po/nl.po, po/nl.po.1: remove eroneously named nl.po.1; update - nl.po - -2006-02-14 John Millaway - - * dfa.c: . - -2006-02-14 John Millaway - - * flex.skl: Included for serialized tables. - -2006-02-14 John Millaway - - * configure.in: Minor patch to call to head in configure script. - -2006-02-14 John Millaway - - * doc/flex.texi: Documentation patch. - -2006-02-14 John Millaway - - * filter.c, gen.c, libyywrap.c, main.c: Patch for full file system - failure. - -2006-02-13 John Millaway - - * doc/flex.texi: Documentation. - -2006-02-13 John Millaway - - * main.c: Fixed double-fclose when input file is empty. - -2006-02-10 Will Estes - - * po/ca.po, po/da.po, po/de.po, po/es.po, po/fr.po, po/ga.po, - po/ko.po, po/nl.po.1, po/pl.po, po/pt_BR.po, po/ro.po, po/ru.po, - po/sv.po, po/tr.po, po/vi.po, po/zh_CN.po: newtranslations - -2005-12-22 John Millaway - - * buf.c, main.c: Improvement request 1069716 log vs. log10 - -2005-12-22 John Millaway - - * flex.skl: Fixed bug 1257093 yy_init_globals in header file - -2005-04-14 Will Estes - - * po/nl.po: new nl translation - -2005-04-07 Will Estes - - * NEWS, po/LINGUAS, po/nl.po, po/vi.po: new nl and vi translations - -2004-07-20 Will Estes - - * filter.c: correct improper stdin assignment - -2004-05-22 Will Estes - - * NEWS, po/tr.po: new tr translation - -2004-05-12 Will Estes - - * .cvsignore, .indent.pro: .cvsignore and .indent.pro got missed in - the import to sourceforge; replace them - -2004-05-11 Will Estes - - * po/fr.po: new fr translation - -2004-05-03 Will Estes - - * po/LINGUAS: polish is pl, not po - -2004-03-22 Will Estes - - * po/sv.po: yet another sweedish update - -2004-03-19 Will Estes - - * NEWS, po/sv.po: new sv translation - -2003-12-11 John Millaway - - * configure.in, filter.c, main.c: Configure checks for GNU m4. - Environment variable M4 overrides built-in m4 path. Generated m4 - does a late check for GNU m4. - -2003-12-09 John Millaway - - * doc/flex.texi: added 3 faqs - -2003-11-24 Will Estes - - * po/ro.po: new ro translation - -2003-11-07 Will Estes - - * NEWS, po/fr.po: new french translation - -2003-11-07 Will Estes - - * NEWS, po/ca.po: new catalan translation from the translation - project - -2003-11-07 Will Estes - - * NEWS, po/LINGUAS, po/ga.po, po/pl.po: new polish translation; - updated irish translation from translation project - -2003-10-10 Will Estes - - * NEWS, po/LINGUAS, po/ga.po: new Irish translation - -2003-08-25 Will Estes - - * NEWS, po/LINGUAS, po/ro.po: add romanian translation - -2003-07-16 Will Estes - - * flex.skl: flex_*int* type fixes - -2003-07-16 Will Estes - - * tools/cvsauthors: change wlestes email address - -2003-07-16 Will Estes - - * flex.skl: undef yytext_ptr has some bad side effects - -2003-07-07 John Millaway - - * doc/flex.texi: Documented m4 incompatibility with lex. - -2003-05-21 Will Estes - - * NEWS: upgrade to gettext 0.12 - -2003-05-20 Will Estes - - * flex.skl, gen.c: patches from manoj via sourceforge - -2003-05-20 Will Estes - - * configure.in, po/.cvsignore, po/Makevars: upgrade gettext to 0.12; - this allows running make pdf and make ps to be successful - -2003-05-20 Will Estes - - * doc/.cvsignore: cvs should ignore flex.pdf and flex.ps - -2003-04-25 John Millaway - - * TODO: Added yylineno bugs to TODO list. - -2003-04-03 John Millaway - - * doc/flex.xml: Docbook. - -2003-04-03 John Millaway - - * doc/flex.xml: xml now validates. - -2003-04-02 John Millaway - - * doc/flex.xml: Began conversion to DocBook. - -2003-04-01 Will Estes - - * NEWS, configure.in: version 2.5.31 - -2003-04-01 Will Estes - - * NEWS: remove --enable-maintainer-mode configure option - -2003-04-01 Will Estes - - * configure.in: remove AM_MAINTAINER_MODE - -2003-04-01 John Millaway - - * flex.skl, flexdef.h, main.c, misc.c, scan.l: Renamed some internal - variables. - -2003-03-31 Will Estes - - * NEWS: yylineno is now per-buffer in reentrant scanners - -2003-03-31 John Millaway - - * TODO: Added TODO item. - -2003-03-30 John Millaway - - * flex.skl, gen.c: yylineno is per-buffer in the reentrant scanner. - support for yycolumn exists, but is not yet developed. - -2003-03-28 John Millaway - - * flex.skl: Minor documentation. - -2003-03-28 Will Estes - - * NEWS: added %top directive - -2003-03-27 John Millaway - - * buf.c, configure.in, doc/flex.texi, flexdef.h, main.c, scan.l, - tests/Makefile.am, tests/descriptions, tests/test-top/.cvsignore, - tests/test-top/Makefile.am, tests/test-top/main.c, - tests/test-top/scanner.l, tests/test-top/test.input: Added %top - block syntax. Added test for %top block. Documented %top block. - -2003-03-27 John Millaway - - * TODO, doc/flex.texi: Documented the m4 dependency. - -2003-03-26 Will Estes - - * configure.in, flexdef.h: check for sys/wait.h since we use wait(2) - -2003-03-26 Will Estes - - * flexdef.h: reorder include directives so as to catch system - integer types before flex defined values for same - -2003-03-26 Will Estes - - * TODO: assign tasks due before major release can happen; remove - --enable-maintainer-mode entry - -2003-03-26 Will Estes - - * Makefile.am: only rebuild the ChangeLog if we're inside a cvs - working directory - -2003-03-26 Will Estes - - * configure.in, tools/.cvsignore, tools/Makefile.am: add tools/ - subdirectory to distribution - -2003-03-26 Will Estes - - * Makefile.am: remove maintainer_mode conditional; add filter.c and - regex.c to indentfiles; reformat and sort indentfiles so it's easier - to add files in the future - -2003-03-26 Will Estes - - * doc/Makefile.am: clean up flex.texi processing leftovers with - cleanfiles - -2003-03-26 Will Estes - - * tests/test-linedir-r/Makefile.am: an awk script wasn't included in - the distribution - -2003-03-26 John Millaway - - * TODO, configure.in, tests/Makefile.am, tests/descriptions, - tests/test-include-by-push/.cvsignore, - tests/test-include-by-push/Makefile.am, - tests/test-include-by-push/scanner.l, - tests/test-include-by-push/test-1.input, - tests/test-include-by-push/test-2.input, - tests/test-include-by-push/test-3.input: Added test for - yypush_buffer_state and yypop_buffer_state. - -2003-03-26 John Millaway - - * TODO: Removed items from TODO list. - -2003-03-26 John Millaway - - * configure.in, tests/Makefile.am, tests/descriptions, - tests/test-linedir-r/.cvsignore, tests/test-linedir-r/Makefile.am, - tests/test-linedir-r/check-lines.awk, tests/test-linedir-r/main.c, - tests/test-linedir-r/scanner.l, tests/test-linedir-r/test.input: - Added test for #line directives. - -2003-03-26 John Millaway - - * configure.in, tests/Makefile.am, tests/test-noansi-nr/.cvsignore, - tests/test-noansi-nr/Makefile.am, tests/test-noansi-nr/scanner.l, - tests/test-noansi-nr/test.input, tests/test-noansi-r/.cvsignore, - tests/test-noansi-r/Makefile.am, tests/test-noansi-r/scanner.l, - tests/test-noansi-r/test.input: Added test for noansi (traditional) - options. Reordered the tests so the basic ones are first. - -2003-03-25 Will Estes - - * TODO, doc/Makefile.am: remove maintainer-mode conditional around - rebuilding of manpage - -2003-03-25 Will Estes - - * README: mention doc/ for user documentation - -2003-03-25 Will Estes - - * TODO: rework distribution items - -2003-03-25 Will Estes - - * NEWS: mention m4 processing - -2003-03-25 Will Estes - - * tests/README: update instructions for running test suite - -2003-03-25 Will Estes - - * FlexLexer.h, Makefile.am, TODO, buf.c, configure.in, - doc/flex.texi, filter.c, flex.skl, flexdef.h, gen.c, main.c, - misc.c, options.c, options.h, regex.c, scan.l, sym.c, - tests/test-bison-nr/scanner.l, tests/test-bison-yylloc/scanner.l, - tests/test-reject/scanner.l, tests/test-table-opts/scanner.l: merge - millaway's m4 branch work - -2003-03-24 John Millaway - - * doc/flex.texi, flex.skl, flexdef.h, gen.c, main.c, options.c, - options.h, scan.l: Option ansi-definitions. Option ansi-prototypes. - Cleaned up some of header. Documented bison-locations. - -2003-03-24 John Millaway - - * scan.l: Escaped m4 macros in scan.l which would cause - bootstrapping issues. - -2003-03-21 John Millaway - - * doc/flex.texi, flex.skl, main.c: Cleaning up the skel. - -2003-03-20 Will Estes - - * TODO: we want to move the contents of to.do/Wishlist to top level - TODO - -2003-03-20 John Millaway - - * to.do/Wish-List: Assessment of every item in Wish-List. - -2003-03-19 John Millaway - - * main.c: Fixed allocation of slightly more memory than needed. - -2003-03-19 John Millaway - - * TODO, buf.c, configure.in, flex.skl, flexdef.h, main.c, sym.c: - Start conditions now generated in a single place. - -2003-03-19 Will Estes - - * TODO: cosmetic changes to TODO list - -2003-03-19 John Millaway - - * flex.skl: Cleaned up warnings so multiple headers could coincide. - -2003-03-19 John Millaway - - * TODO, flex.skl, main.c: Moved prefixes to m4. - -2003-03-19 John Millaway - - * FlexLexer.h, filter.c, flex.skl, flexdef.h, main.c, misc.c, - regex.c: Removed Paxson/Berkeley copyright restriction from filter.c - and regex.c. Inline documentation of much of the generated API. - Line directives now fixed for header and stdin/stdout. Blank lines - squeezed from generated scanner. - -2003-03-18 John Millaway - - * filter.c, flexdef.h, main.c, regex.c: Fixed #line directives. - -2003-03-17 John Millaway - - * Makefile.am, filter.c, flexdef.h, regex.c: Added regex.c for - regex-related code. Worked on fixing line directives;incomplete. - -2003-03-14 John Millaway - - * TODO: Added some TODOs. - -2003-03-14 John Millaway - - * flexdef.h, main.c, options.c, options.h, scan.l, - tests/test-bison-nr/scanner.l, tests/test-bison-yylloc/scanner.l: - Bison bridge was simplified to rely less on bison output. New - option bison-locations. - -2003-03-14 John Millaway - - * filter.c, flex.skl, flexdef.h, gen.c, main.c, scan.l, - tests/test-reject/scanner.l: Filters are now direct children of main - process. Header file now generated through m4. - -2003-03-14 John Millaway - - * buf.c, filter.c, flexdef.h, main.c, misc.c: Added internal filter - ability. Deleted various unused variables. - -2003-03-14 John Millaway - - * main.c, tests/test-table-opts/scanner.l: Keeping tests up to date - with m4 changes. Proper wait for all children. - -2003-03-14 John Millaway - - * flex.skl, tests/test-table-opts/scanner.l: Moved test-tables to - m4. - -2003-03-14 John Millaway - - * flex.skl, main.c, options.c: Moved bison bridge code to m4. - -2003-03-13 John Millaway - - * flex.skl, gen.c, main.c, scan.l: Moved YY_USE_LINENO to m4. - -2003-03-13 John Millaway - - * buf.c, flexdef.h, scan.l: Added function buf_m4_undefine. - -2003-03-13 John Millaway - - * flex.skl, main.c, scan.l: Replaced YY_ALWAYS_INTERACTIVE with m4. - Replaced YY_NEVER_INTERACTIVE with m4. - -2003-03-13 John Millaway - - * flex.skl, main.c: Moved YY_TEXT_IS_ARRAY to m4. - -2003-03-12 John Millaway - - * flex.skl, gen.c, main.c, tests/test-reject/scanner.l: Renaming - macros from YY_* to M4_YY_* where appropriate. - -2003-03-12 John Millaway - - * flex.skl, tests/test-reject/scanner.l, - tests/test-table-opts/scanner.l: Now using local variable "yyg" - instead of lengthly YY_G expansion. - -2003-03-12 John Millaway - - * buf.c, filter.c, flex.skl, flexdef.h, main.c, misc.c, options.c, - options.h, scan.l, tests/test-reject/scanner.l: More m4 macro - conversions. Added debugging option --preproc-level=NUM. - -2003-03-11 John Millaway - - * Makefile.am, buf.c, flex.skl, flexdef.h, gen.c, main.c, misc.c, - scan.l: Replaced many CPP macros with m4 equivalents. - -2003-03-10 John Millaway - - * Makefile.am, filter.c, flex.skl, flexdef.h, main.c, misc.c: Added - filter.c Added filter.c rules to Makefile.am Added filter prototypes - to flexdef.h Flex now filters output through m4. - -2003-03-05 Will Estes - - * doc/.cvsignore, texinfo.tex: move texinfo.tex to doc/ - -2003-03-05 Will Estes - - * TODO: update TODO - -2003-03-05 Will Estes - - * NEWS, configure.in: version 2.5.29 - -2003-03-04 John Millaway - - * FlexLexer.h, flex.skl: Added growable buffer stack to C++ scanner - as well. yyensure_buffer_stack is now static. - -2003-03-02 John Millaway - - * flex.skl, misc.c: Removed awkward %push %pop syntax from skeleton. - -2003-03-02 John Millaway - - * flex.skl: Renamed YY_CURRENT_BUFFER_FAST to - YY_CURRENT_BUFFER_LVALUE to better reflect its purpose. - -2003-02-28 John Millaway - - * NEWS: made entry on input buffer stacks. - -2003-02-28 Will Estes - - * Makefile.am, doc/Makefile.am: build on . in top level first; this - will simplify calling help2man - -2003-02-28 John Millaway - - * TODO, doc/flex.texi, flex.skl, gen.c, main.c: Removed - yy_current_buffer from the planet. Input buffer states are now in - an internal unbounded stack. Added new internal function, - yyensure_buffer_stack. Added new API function, yypush_buffer_state. - Added new API function, yypop_buffer_state. Documented the new API - calls in the manual. Macro YY_BUFFER_STATE now refers to top of - stack. This revision breaks the C++ scanner (again.) - -2003-02-28 John Millaway - - * main.c: Removed some symbols from the undef list. They are needed - for multiple headers to coexist. - -2003-02-27 Will Estes - - * Makefile.am, NEWS, configure.in, doc/.cvsignore, doc/Makefile.am, - doc/flex.texi, flex.texi: move flex.texi and flex.1 to new doc/ - subdirectory - -2003-02-27 Will Estes - - * NEWS: namespace cleanups - -2003-02-26 John Millaway - - * main.c: Added a few macros to the undef list. - -2003-02-26 John Millaway - - * main.c: Put the undef macros in an array. - -2003-02-12 Will Estes - - * NEWS, configure.in: version 2.5.28 - -2003-02-10 Will Estes - - * README, TODO, configure.in, flex.texi: update documentation to - reflect the sourceforge move - -2003-02-06 Will Estes - - * TODO: update according to current thinking - -2003-02-06 Will Estes - - * TODO: mcvs reviewed - -2003-02-06 Will Estes - - * TODO: sourceforge migration tasks - -2003-02-04 Will Estes - - * NEWS: Flex now warns if always-interactive is specified with fast - or full; Fixed trailing slash bug in YY_INPUT macro def - -2003-01-31 John Millaway - - * scan.l: Flex now warns if always-interactive is specified with - fast or full. - -2003-01-31 Will Estes - - * Makefile.am: switch to using cvs2cl.pl to generate the ChangeLog - -2003-01-31 Will Estes - - * tools/cvs2cl.pl, tools/cvsauthors: we're going to be switching how - we handle our ChangeLog - -2003-01-29 John Millaway - - * gen.c, misc.c: Fixed trailing slash bug in YY_INPUT macro def. - -2003-01-29 Will Estes - - * README.cvs-snapshot: upgrade texinfo to 4.3d - -2003-01-29 Will Estes - - * flex.texi: the @copying construct works now; thanks to the texinfo - maintainers for finding the problem - -2003-01-21 Will Estes - - * NEWS, configure.in: version 2.5.27 - -2003-01-21 Will Estes - - * NEWS: flex now works with recent bison versions - -2003-01-18 John Millaway - - * flex.skl: Check for YYLTYPE_IS_DECLARED. This fixes bison-bridge - with latest bison. - -2003-01-15 Will Estes - - * NEWS, po/pt_BR.po: new pt_br translation - -2003-01-14 Will Estes - - * NEWS, configure.in: version 2.5.26 - -2003-01-14 Will Estes - - * NEWS: Fixed table deserialization bug on big-endian archs. Patch - sent from Bryce Nichols - -2003-01-12 John Millaway - - * tables_shared.h: Fixed table deserialization bug on big-endian - archs. Patch sent from Bryce Nichols . - -2003-01-10 Will Estes - - * README.cvs-snapshot: add version numbers for some tools and - explain about version.texi and --enable-maintainer-mode - -2003-01-10 Will Estes - - * NEWS: catch news up - -2003-01-09 John Millaway - - * tests/test-mem-nr/scanner.l, tests/test-mem-r/scanner.l: Changed - size_t to yy_size_t in yyalloc() and yyrealloc(). Is this really - what we want? - -2003-01-09 John Millaway - - * flex.skl: Changed type of yyleng from size_t to int. This fixes - bug in PostgreSQL compilation. - -2003-01-09 Will Estes - - * NEWS: catch news up - -2003-01-09 Will Estes - - * flex.skl: more c++ fixes - -2003-01-09 Will Estes - - * Makefile.am, configure.in, flex.spec.in: add a spec file - -2003-01-09 Will Estes - - * flex.skl: type cast to pacify c++ compilers; patch from Bruce - Lilly - -2003-01-08 Will Estes - - * NEWS: new es translation - -2003-01-08 Will Estes - - * po/es.po: new spanish translation - -2002-12-19 John Millaway - - * gen.c: Fixed bug where YY_G(0) sometimes occurs (created by my - previous commit.) - -2002-12-17 John Millaway - - * gen.c: Fixed bug submitted by Bojan Smojver - where the use of yylineno, reentrant, and yymore together caused a - compile-time error. - -2002-12-17 Will Estes - - * NEWS: update NEWS - -2002-12-17 John Millaway - - * flex.texi: Documented new behavior with character ranges. - -2002-12-16 John Millaway - - * parse.y: Fixed bug submitted by Bruce Lilly - where character ranges would yield unexpected behavior in a caseless - scanner. Also, flex now emits a warning if the range looks like - trouble. - -2002-12-16 John Millaway - - * ccl.c, flexdef.h: Added utility functions to deal with character - case. - -2002-12-09 Will Estes - - * flexint.h: we don't really need int64 anyway - -2002-12-09 Will Estes - - * flex.skl: apparently some lints are happier with fllthrough - without a space - -2002-12-02 Will Estes - - * NEWS, configure.in: version 2.5.25 - -2002-12-02 Will Estes - - * Makefile.am: enclose flex.1 target in MAINTERNER_MODE - -2002-12-02 Will Estes - - * po/pt_BR.po: new pt_br translation - -2002-12-01 John Millaway - - * flex.texi: Indexed some more faqs. - -2002-11-29 John Millaway - - * flex.skl: Fixed bug in SECOND yyless definition where argument was - not enclosed in parentheses. - -2002-11-29 John Millaway - - * flex.skl: Fixed bug in yyless definition where argument was not - enclosed in parentheses. - -2002-11-27 Will Estes - - * NEWS: flex uses flex_int*_t types - -2002-11-27 Will Estes - - * flexint.h: integer types for non-C99 systems flexint.h - -2002-11-27 John Millaway - - * dfa.c, flexint.h, gen.c, tables.c, tables.h, tables_shared.c, - tables_shared.h: Changed int types to flex_intX_t. The build is now - broken until typedef's are established. - -2002-11-27 Will Estes - - * Makefile.am: MAINTAINERCLEANFILES: new variable: try to make it so - that make maintainer-clean erases everything not under version - control - -2002-11-27 Will Estes - - * config.rpath: remove config.rpath - -2002-11-27 Will Estes - - * README-alpha: just list location of betas - -2002-11-26 Will Estes - - * flexint.h: __STDC_VERSION__ needs an L suffix - -2002-11-26 Will Estes - - * NEWS, po/LINGUAS, po/pt_BR.po: new pt_br translation from the - translation project - -2002-11-25 Will Estes - - * flexint.h: include inttypes.h for folks who really are C99 - -2002-11-25 Will Estes - - * TODO: fix a typo - -2002-11-25 Will Estes - - * NEWS, configure.in: version 2.5.24 - -2002-11-23 Will Estes - - * configure.in: try to make sure we have GNU m4 - -2002-11-23 Will Estes - - * tests/test-c++-multiple-scanners/Makefile.am: include - tests/test-c++-multipl-scanners/test.input - -2002-11-23 Will Estes - - * NEWS: more portability fixes - -2002-11-23 Will Estes - - * configure.in, flexdef.h: apparently on some BSD systems, we need - sys/params.h; reported by millaway - -2002-11-22 Will Estes - - * NEWS: update NEWS - -2002-11-22 John Millaway - - * flex.skl, main.c, tests/test-c++-multiple-scanners/Makefile.am: - Fixed prefix of yyalloc,yyfree,yyrealloc in C++ scanner. Removed - yylex_destroy from C++ scanner. - -2002-11-22 John Millaway - - * flex.texi: renamed some faqs. - -2002-11-22 Will Estes - - * AUTHORS: update wording about authorship - -2002-11-17 John Millaway - - * parse.y: Removed space before line num in error messages to look - more like gcc's errors. - -2002-11-06 Will Estes - - * NEWS, po/tr.po: new turkish translation from the translation - project - -2002-10-28 Will Estes - - * gen.c: applied c++ from lilypond folks for std:: reasons - -2002-10-25 Will Estes - - * flex.texi: proofreading - -2002-10-24 Will Estes - - * flex.texi: proofreading - -2002-10-22 Will Estes - - * flex.skl: use c-style header names in c++ for now; at some point - we'll have a separate c++ skeleton and we can go whole-hog pure c++ - -2002-10-22 Will Estes - - * TODO: c++ rants - -2002-10-22 Will Estes - - * flex.texi: more proofreading - -2002-10-22 Will Estes - - * Makefile.am: include intent.pro; indent target is MAINTAINER_MODE - conditional - -2002-10-22 Will Estes - - * configure.in: When we use AC_PATH_PROG, value-if-not-found is the - name of the program we wanted to find; this will generate more - helpful error messages - -2002-10-21 John Millaway - - * tables.c: Added a missing function prototype. - -2002-10-21 Will Estes - - * NEWS, configure.in: version 2.5.23 - -2002-10-21 Will Estes - - * NEWS: update NEWS on recent changes - -2002-10-21 Will Estes - - * flexint.h: use sys/types.h and not inttypes.h - -2002-10-21 Will Estes - - * configure.in: check for limits.h - -2002-10-21 Will Estes - - * TODO: update TODO on recent suggestions - -2002-10-21 Will Estes - - * flex.texi: titlepage and contents - -2002-10-21 Will Estes - - * Makefile.am: typo - -2002-10-21 Will Estes - - * Makefile.am, README.cvs-snapshot: include README.cvs-snapshot in - the distribution; in README-cvs-snapshot, mention the need for - enable-maintainer-mode - -2002-10-21 John Millaway - - * flex.texi: typo. - -2002-10-18 Will Estes - - * flex.texi: report the current version info that flex provides; - reformat a list of non-posix features - -2002-10-18 Will Estes - - * NEWS: report the current version info that flex provides - -2002-10-18 Will Estes - - * flex.skl: FLEX_BETA defined if flex is beta - -2002-10-16 Will Estes - - * flexint.h: if we're doing c++, then we can't use long long - -2002-10-14 Will Estes - - * TODO: update TODO on several things - -2002-10-11 Will Estes - - * flex.texi: more proofreading - -2002-10-11 Will Estes - - * tests/TEMPLATE/Makefile.am, tests/test-array-nr/Makefile.am, - tests/test-array-r/Makefile.am, tests/test-basic-nr/Makefile.am, - tests/test-basic-r/Makefile.am, tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c++-basic/Makefile.am, - tests/test-c++-multiple-scanners/Makefile.am, - tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-r/Makefile.am, - tests/test-debug-nr/Makefile.am, tests/test-debug-r/Makefile.am, - tests/test-header-nr/Makefile.am, tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-mem-nr/Makefile.am, tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-reject/Makefile.am, - tests/test-string-nr/Makefile.am, tests/test-string-r/Makefile.am, - tests/test-table-opts/Makefile.am, tests/test-yyextra/Makefile.am: - remove BISON assignment as per suggestion from Akim Demaille - -2002-10-11 Will Estes - - * Makefile.am, configure.in: remove intl from dist - -2002-10-11 Will Estes - - * configure.in: we use maintainer mode now - -2002-10-11 Will Estes - - * NEWS: include create-test - -2002-10-11 Will Estes - - * tests/Makefile.am: rename test to check-local as per Akim - Demaille; test for failed tests so that make check fails if any - tests do - -2002-10-11 Will Estes - - * tests/Makefile.am: use dist_noinst_scripts as per email from Akim - Demaille - -2002-10-10 John Millaway - - * flex.texi: Documentation. - -2002-10-10 Will Estes - - * NEWS, configure.in: version 2.5.22; portability fixes and attn to - the test suite - -2002-10-10 Will Estes - - * flexint.h: ok, this seems to work - -2002-10-10 Will Estes - - * tests/TEMPLATE/Makefile.am, tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-header-nr/Makefile.am, tests/test-header-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am: use builddir in tests - that need it in their include path - -2002-10-10 Will Estes - - * tests/TEMPLATE/Makefile.am: sometimes we put header files in the - builddir and so we should account for that - -2002-10-10 Will Estes - - * tests/TEMPLATE/Makefile.am: replace the last instance - -2002-10-10 Will Estes - - * flex.skl: include unistd.h and not cunistd as cunistd only seems - to be present on very recent systems - -2002-10-10 Will Estes - - * Makefile.am, configure.in, flex.skl, flexdef.h, flexint.h: redo - integral types again; add flexint.h; change dependencies caused by - adding flexint.h; remove autoconf wrapper around cunistd; restore - netinet/in.h includes; remove unneded feature checks in configure.in - -2002-10-08 Will Estes - - * configure.in, flex.skl, flexdef.h: current swipe at header magic; - int types be damned - -2002-10-08 Will Estes - - * NEWS: change version constant info to reflect change to flex.skl - -2002-10-08 Will Estes - - * Makefile.am: remove README-alpha option; add definitions for - FLEX_{MAJOR,MINOR,SUBMINOR}_VERSION - -2002-10-07 Will Estes - - * flex.skl, flexdef.h: ok, here goes; try to handle integral - typedefs in one swell foop - -2002-10-07 Will Estes - - * configure.in: we check for {u,}int*_t types; maybe this will - simplify things - -2002-10-07 Will Estes - - * configure.in: we create the tests/TEMPLATE/Makefile so that we can - build the dist archives - -2002-10-07 Will Estes - - * NEWS: more test suite cleanups - -2002-10-07 Will Estes - - * tests/test-c++-multiple-scanners/Makefile.am: we don't use header - files... - -2002-10-07 Will Estes - - * flexdef.h: remove include of malloc.h - -2002-10-04 Will Estes - - * flex.texi: more editing; remove examples index; merge examples - into concept index - -2002-10-04 Will Estes - - * flex.texi: edited one more faq; used C-u C-c C-u C-a to update - menus and nodes since the other updating commands are somewhat - broken; unfortunately this means that all nodes have all pointers - filled in - -2002-10-04 Will Estes - - * flex.texi: yesterday's proofreading - -2002-10-02 Will Estes - - * flex.texi: proofread some more - -2002-10-02 Will Estes - - * flex.texi: proofread edit begins - -2002-10-01 Will Estes - - * configure.in, tests/Makefile.am, - tests/test-c++-multiple-scanners/.cvsignore, - tests/test-c++-multiple-scanners/Makefile.am, - tests/test-c++-multiple-scanners/main.cpp, - tests/test-c++-multiple-scanners/scanner-1.l, - tests/test-c++-multiple-scanners/scanner-2.l, - tests/test-c++-multiple-scanners/test.input: test c++ with multiple - scanners - -2002-09-27 Will Estes - - * tests/test-array-nr/Makefile.am, tests/test-array-r/Makefile.am, - tests/test-basic-nr/Makefile.am, tests/test-basic-r/Makefile.am, - tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c++-basic/Makefile.am, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-r/Makefile.am, tests/test-debug-nr/Makefile.am, - tests/test-debug-r/Makefile.am, tests/test-header-nr/Makefile.am, - tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-mem-nr/Makefile.am, tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-reject/Makefile.am, - tests/test-string-nr/Makefile.am, tests/test-string-r/Makefile.am, - tests/test-table-opts/Makefile.am, tests/test-yyextra/Makefile.am: - we used INCLUDES in another place in the Makefile.am files in the - test suite - -2002-09-27 Will Estes - - * tests/test-array-nr/Makefile.am, tests/test-array-r/Makefile.am, - tests/test-basic-nr/Makefile.am, tests/test-basic-r/Makefile.am, - tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c++-basic/Makefile.am, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-r/Makefile.am, tests/test-debug-nr/Makefile.am, - tests/test-debug-r/Makefile.am, tests/test-header-nr/Makefile.am, - tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-mem-nr/Makefile.am, tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-reject/Makefile.am, - tests/test-string-nr/Makefile.am, tests/test-string-r/Makefile.am, - tests/test-table-opts/Makefile.am, tests/test-yyextra/Makefile.am: - oops, I typed that last s/// command to perl way wrong - -2002-09-27 Will Estes - - * tests/TEMPLATE/Makefile.am, tests/test-array-nr/Makefile.am, - tests/test-array-r/Makefile.am, tests/test-basic-nr/Makefile.am, - tests/test-basic-r/Makefile.am, tests/test-bison-nr/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c++-basic/Makefile.am, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-r/Makefile.am, tests/test-debug-nr/Makefile.am, - tests/test-debug-r/Makefile.am, tests/test-header-nr/Makefile.am, - tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-mem-nr/Makefile.am, tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-reject/Makefile.am, - tests/test-string-nr/Makefile.am, tests/test-string-r/Makefile.am, - tests/test-table-opts/Makefile.am, tests/test-yyextra/Makefile.am: - use AM_CPPFLAGS instead of INCLUDES; write -I with no space after it - for broken compilers - -2002-09-27 Will Estes - - * Makefile.am: INCLUDES is obsolete; use AM_CPPFLAGS instead - -2002-09-27 Will Estes - - * configure.in: apparently, AM_CONFIG_HEADER is obsolete - -2002-09-27 Will Estes - - * TODO: integrate test suite into automake - -2002-09-27 Will Estes - - * configure.in: since we dont run the template test, we dont need to - generate its Makefile either - -2002-09-27 Will Estes - - * autogen.sh: use autoreconf instead of calling individual utilities - separately - -2002-09-27 Will Estes - - * configure.in: check for c++ compiler - -2002-09-27 Will Estes - - * configure.in: re-organize according to suggested layout in - autoconf manual - -2002-09-26 Will Estes - - * Makefile.am, NEWS, configure.in: update automake to 1.7 and - autoconf to 2.54 - -2002-09-26 Will Estes - - * Makefile.am: use AM_YFLAGS since YFLAGS is a user variable - -2002-09-25 Will Estes - - * NEWS: catch NEWS up on things, some of which happened a long time - ago; correct punctuation; try to remove some editorializing - -2002-09-25 Will Estes - - * Makefile.am, flex.skl, flex.texi: include a single, automatically - generated version number in flex scanners - -2002-09-23 Will Estes - - * tests/create-test: complain audibly when argument not supplied; - echo on stderr when writing error messages - -2002-09-23 Will Estes - - * tests/Makefile.am, tests/create-test: DIST_SUBDIRS so we don't - have to run the TEMPLATE test; so we add new tests to SUBDIRS and - DIST_SUBDIRS - -2002-09-23 Will Estes - - * tests/TEMPLATE/Makefile.am: not all compilers support '-I dir' so - we write '-Idir' instead - -2002-09-23 Will Estes - - * TODO: reorganize faq entries; proofread the manual - -2002-09-23 Will Estes - - * flex.texi: move c++ experimental warning to top of cxx node - -2002-09-20 Will Estes - - * flex.skl: move stdint.h include to table-serialization section; - we'll still need to think about stdint.h more though - -2002-09-20 Will Estes - - * NEWS: new smarter skeleton/scanner generation - -2002-09-20 John Millaway - - * flex.skl, misc.c: bison-bridge skel handled via %if/%endif pairs. - -2002-09-19 John Millaway - - * flex.skl, misc.c: reentrant skel handled via %if/%endif pairs. - -2002-09-19 John Millaway - - * flex.skl, misc.c: skeleton uses %push/%pop to keep skelout() scope - sane. skel commands are omitted unless --debug enabled. - -2002-09-19 John Millaway - - * flex.skl, main.c, misc.c, tables.h: Added %push and %pop - operations to skel processing. - -2002-09-17 Will Estes - - * NEWS, configure.in: flex 2.5.21 - -2002-09-17 John Millaway - - * tests/test-reject/Makefile.am: minor fixup for dist. - -2002-09-16 Will Estes - - * NEWS, configure.in: version 2.5.20 - -2002-09-16 Will Estes - - * flex.texi: correct typo - -2002-09-16 Will Estes - - * NEWS: note the new tables functionality - -2002-09-16 John Millaway - - * tests/test-multiple-scanners-r/.cvsignore, - tests/test-multiple-scanners-r/Makefile.am: Fixed `clean' target and - .cvsignore. - -2002-09-16 John Millaway - - * TODO, flex.skl, flex.texi, main.c, tables_shared.h, - tests/test-multiple-scanners-r/main.c, - tests/test-multiple-scanners-r/scanner-1.l, - tests/test-multiple-scanners-r/scanner-2.l: Serialization works in - headers (%option headers). Serialization code (Tables API) is - complete. - -2002-09-16 Will Estes - - * tests/test-reject/scanner.l: replace yytables_load with - yytables_fload as per millaway's other changes - -2002-09-15 John Millaway - - * TODO, flex.texi: Created user API for tables deserialization. - Documented API and --tables-* options in manual. - -2002-09-15 John Millaway - - * flex.skl, tests/test-table-opts/scanner.l: Tables deserialization - uses yyalloc/yyfree. Changed yytables_load to yytables_fload. - -2002-09-15 John Millaway - - * tests/test-bison-nr/.cvsignore: minor upkeep. - -2002-09-15 John Millaway - - * flex.texi: Categorized and indexed scanner options in manual. - -2002-09-15 John Millaway - - * flex.skl: Initialization of reject vars and %array vars in - reentrant scanner. - -2002-09-13 John Millaway - - * TODO, configure.in, devel/tables.pl, dfa.c, flex.skl, flex.texi, - gen.c, tables.c, tables_shared.c, tables_shared.h, - tests/Makefile.am, tests/test-reject/.cvsignore, - tests/test-reject/Makefile.am, tests/test-reject/scanner.l, - tests/test-reject/test.input, tests/test-table-opts/Makefile.am: - Created test for reject. Handled reject-triggered tables in - serialization. - -2002-09-13 Will Estes - - * NEWS: millaway has been very busy - -2002-09-13 John Millaway - - * flex.skl, tests/test-table-opts/Makefile.am, - tests/test-table-opts/scanner.l: Added test for multiple tables in - one file. - -2002-09-13 John Millaway - - * tests/test-bison-nr/.cvsignore: forgot to add .cvsignore on last - commit. - -2002-09-13 John Millaway - - * tests/test-bison-nr/Makefile.am, tests/test-bison-nr/main.c, - tests/test-bison-nr/parser.y, tests/test-bison-nr/scanner.l, - tests/test-bison-nr/test.input: Added test-bison-bridge. - -2002-09-13 John Millaway - - * configure.in, flex.skl, flex.texi, flexdef.h, gen.c, main.c, - misc.c, options.c, options.h, scan.l, tables.h, tests/Makefile.am, - tests/descriptions, tests/test-bison-yylloc/scanner.l, - tests/test-bison-yylval/scanner.l, tests/test-table-opts/scanner.l: - Bison bridge code now works for all C scanners and pure/non-pure - bison parsers. Added %option bison-bridge (--bison-bridge). - Removed %option reentrant-bison/--reentrant-bison/-Rb. Scanner - knows the name of its tables. Tables serialization is OK on EOF. - yylineno is present in all scanners. Modified nasty performance - penalty warning w/ yylineno. test-table-opts is now run last - because it's so fat. Updated manual. - -2002-09-12 John Millaway - - * flex.texi: documentation of tabels api in manual - -2002-09-12 John Millaway - - * TODO, tables.c: Renamed *_fwrite to *_write to reflect writer - abstraction. - -2002-09-11 John Millaway - - * devel/tables.pl: Added perl script to read/dump serialized tables - in devel/ - -2002-09-11 Will Estes - - * scan.l: the debian patch used strlen(yytext) and similar - constructs--as millaway points out, this is better known as yyleng - -2002-09-11 Will Estes - - * NEWS, po/de.po: new de translation from the translation project - -2002-09-11 John Millaway - - * flex.skl: yytbl_load now checks tables set by name. Localized var - scaope in yytbl_load. - -2002-09-10 Will Estes - - * tests/Makefile.am: make clean before make test - -2002-09-09 John Millaway - - * TODO, flex.skl: Fixed deserialization of --fast tables. - -2002-09-09 Will Estes - - * TODO: fix typo; remove the yylineo entry - -2002-09-09 John Millaway - - * TODO, buf.c, devel/dump-tables.pl, dfa.c, flex.skl, flexdef.h, - gen.c, main.c, misc.c, options.c, options.h, scan.l, tables.c, - tables.h, tables_shared.h, tests/test-table-opts/.cvsignore, - tests/test-table-opts/Makefile.am, tests/test-table-opts/scanner.l: - Table deserialization works for everything except --fast scanners. - Scanners can auto-verify serialized table integrity via - --tables-verify. Added tables API items to TODO list. - test-table-opts is becoming exhaustive (a good thing). - -2002-09-09 Will Estes - - * NEWS: flex has better internal diagnostics - -2002-09-09 Will Estes - - * configure.in, flexdef.h: test for presence of __func__ and - compensate if absent - -2002-09-09 Will Estes - - * Makefile.am: include the intl/ subdirectory when searching for - include files - -2002-09-09 Will Estes - - * NEWS, po/ru.po, po/sv.po: new sv, ru translations from the - translation project - -2002-09-07 John Millaway - - * flex.skl, misc.c: Changed cryptic skeleton markers to readable - form. - -2002-09-07 John Millaway - - * Makefile.am, dfa.c, flex.skl, flex.texi, flexdef.h, gen.c, - main.c, misc.c, parse.y, tables.c, tables.h, tables_shared.c, - tables_shared.h: Members of struct yy_trans_info are now forced to - be the same size. Added shared file tables_shared.c. Separated - tables.h from flexdef.h Bulk of table deserialization code is done. - -2002-09-06 Will Estes - - * NEWS, po/ca.po: new ca translation - -2002-09-06 Will Estes - - * NEWS: new fr translation - -2002-09-06 Will Estes - - * po/fr.po: new french translation from the translation project - -2002-09-05 Will Estes - - * NEWS: c99 function defs by default - -2002-09-05 John Millaway - - * flexdef.h, tables.c: Added flex_die macro. May need some autoconf - massaging. Added thorough error checking in tables code. - -2002-09-05 John Millaway - - * flex.skl, flex.texi: Flex generates C99 defs now. Documented the - above change in manual. - -2002-09-05 John Millaway - - * tests/test-table-opts/.cvsignore, - tests/test-table-opts/Makefile.am: Added serialization test to - table-opts test. - -2002-09-05 Will Estes - - * configure.in: oops, i made a typo - -2002-09-05 Will Estes - - * NEWS, configure.in: version 2.5.19 - -2002-09-05 Will Estes - - * scan.l: use FLEX_EXIT(), not exit() - -2002-09-05 John Millaway - - * devel/00EXTRACT-ALL-SYMS.sh, devel/README, devel/dump-tables.pl: - Added devel/ directory for junk that we don't want in the - distribution, but that we want in CVS. - -2002-09-05 Will Estes - - * scan.l: s/exit(1)/exit(EXIT_FAILURE) - -2002-09-05 John Millaway - - * dfa.c, gen.c: Tables are now generated with %option - tables-file=FILE. - -2002-09-05 Will Estes - - * NEWS: catch up on a few things - -2002-09-05 Will Estes - - * scan.l: prevent segfault on input lines which are longer than the - allocated space (problem report from Manoj Srivastava - ) - -2002-09-05 John Millaway - - * flex.texi, main.c, options.c, options.h: Changed option 'header' - to 'header-file'. 'header' still works, though. - -2002-09-05 John Millaway - - * flex.texi, flexdef.h, gen.c, main.c, options.c, options.h, - scan.l, tables.c: Tons more work on tables. - -2002-09-05 John Millaway - - * flexdef.h, gen.c, tables.c, tables_shared.h: Lots of work on - tables serialization code. - -2002-09-04 Will Estes - - * README.cvs-snapshot: mention GNU indent - -2002-09-04 Will Estes - - * NEWS: remove the word after from the version line - -2002-09-03 Will Estes - - * NEWS, configure.in: version 2.5.18 - -2002-09-03 Will Estes - - * NEWS: catch up on the NEWS - -2002-09-03 Will Estes - - * tests/Makefile.am: target test: quote the results echoing so that - the ECHO_C will work on systems where it is used - -2002-09-03 Will Estes - - * configure.in: when we don't have GNU indent, the test will - generate output on stderr, so we send that to /dev/null - -2002-09-03 Will Estes - - * configure.in: fixed bug whereby bison was reported missing even - when it was found - -2002-09-02 John Millaway - - * tables.c: In-code documentation. - -2002-09-02 John Millaway - - * flexdef.h: Forgot to indent before previous commit. - -2002-09-02 John Millaway - - * flexdef.h: Added known integer limits if undefined. - -2002-08-29 Will Estes - - * configure.in: version 2.5.17 - -2002-08-29 Will Estes - - * NEWS: more portability fixes; new version number - -2002-08-29 Will Estes - - * flexdef.h, main.c, misc.c, scanopt.c: #include fixes; we've - factored out all the system include files and put them in flexdef.h - -2002-08-29 Will Estes - - * dfa.c: eat a blank line - -2002-08-29 Will Estes - - * NEWS: new config.{sub,guess} files; mention that we use indent on - flex - -2002-08-28 Will Estes - - * configure.in: warn if no indent found; version 2.5.16 - -2002-08-28 Will Estes - - * NEWS: catch up on recent changes; version 2.5.16 - -2002-08-27 Will Estes - - * buf.c, ccl.c, dfa.c, ecs.c, flexdef.h, gen.c, libmain.c, - libyywrap.c, main.c, misc.c, nfa.c, options.c, options.h, - scanopt.c, scanopt.h, sym.c, tables.c, tables_shared.h, tblcmp.c, - yylex.c: ran the indent target; commit the results - -2002-08-27 Will Estes - - * Makefile.am: touch up the indent targeet; it's ready for - production use now - -2002-08-27 Will Estes - - * configure.in: test for GNU indent; reorder the tests somewhat - -2002-08-23 Will Estes - - * configure.in: automake is smarter about autoconf's versioning - scheme - -2002-08-23 Will Estes - - * NEWS: catch NEWS up on what we've been doing - -2002-08-22 Will Estes - - * flexdef.h: do some more conditional including for folks without - standard systems - -2002-08-22 Will Estes - - * tests/test-c++-basic/Makefile.am: use CXX to link the test scanner - here - -2002-08-22 John Millaway - - * flex.texi: Documentation. - -2002-08-22 John Millaway - - * Makefile.am: Created 'indent' target and added .indent.pro. - -2002-08-22 John Millaway - - * tests/test-array-nr/Makefile.am, tests/test-array-r/Makefile.am, - tests/test-basic-nr/Makefile.am, tests/test-basic-r/Makefile.am, - tests/test-c-cpp-nr/Makefile.am: Fixed missing 'make clean' files. - -2002-08-22 John Millaway - - * tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am: fixed missing 'clean' file. - -2002-08-22 John Millaway - - * flex.skl, tests/test-c++-basic/Makefile.am, - tests/test-c++-basic/scanner.l: Removed core of yylex_destroy from - c++ scanner -- hack! Added -lstdc++ to LDFLAGS (should we have to do - this??) - -2002-08-21 Will Estes - - * README: official releases are being hosted by Vern - -2002-08-21 Will Estes - - * NEWS, configure.in: new beta version; more entries in NEWS from - millaway; the top level entry for test-c++-basic - -2002-08-21 Will Estes - - * tests/Makefile.am, tests/test-c++-basic/.cvsignore, - tests/test-c++-basic/Makefile.am, tests/test-c++-basic/scanner.l, - tests/test-c++-basic/test.input: add test-c++-basic - -2002-08-21 John Millaway - - * gen.c, nfa.c: More tabels work. - -2002-08-21 John Millaway - - * flexdef.h, gen.c, tables.c, tables_shared.h: More work on tables. - -2002-08-20 John Millaway - - * dfa.c: Cleaned up macros that took no ';'. - -2002-08-20 John Millaway - - * scanopt.c: Fixed oddball '=-'. - -2002-08-20 John Millaway - - * flex.skl, flex.texi, gen.c: Dynamically allocate REJECT state - buffer. Mentioned memory usage in docs. Made REJECT buffer - variables reentrant-safe. - -2002-08-20 John Millaway - - * tables.c: More work on tables code. - -2002-08-20 Will Estes - - * Makefile.am, NEWS, configure.in: we're using m4 so have configure - test for it - -2002-08-20 John Millaway - - * Makefile.am, tables.c: Added tables.c and rebuilt dependencies. - -2002-08-20 John Millaway - - * TODO, flex.texi: Dicussed prototypes and header in manual. - -2002-08-19 John Millaway - - * Makefile.am, configure.in, flex.skl, flexdef.h, tables_shared.h: - More work on tables serialization. - -2002-08-19 John Millaway - - * Makefile.am, mkskel.sh: Skeleton is now passed through m4 (before - dist is built). - -2002-08-19 Will Estes - - * po/LINGUAS, po/zh_CN.po: add zh_cn translation from the - translation project - -2002-08-19 Will Estes - - * NEWS: millaway's done a lot of things which need to be mentioned - in NEWS - -2002-08-18 John Millaway - - * main.c: Removed #undef of start conditions. - -2002-08-17 John Millaway - - * TODO: todo list - -2002-08-17 John Millaway - - * flexdef.h, main.c, misc.c: Start conditions now optional in - header. undef's now optional in header. Start conditions are NOT - prefixed. - -2002-08-17 John Millaway - - * flex.skl, flex.texi: Working on tables API. - -2002-08-16 John Millaway - - * flexdef.h, main.c, misc.c, options.c, options.h, parse.y, scan.l: - Added --tables option. Omitted tables code from generated scanner - when unused. - -2002-08-16 John Millaway - - * flex.skl, flex.texi, misc.c: Prelimary work on tables API. - -2002-08-16 John Millaway - - * tests/TEMPLATE/Makefile.am, tests/test-array-nr/Makefile.am, - tests/test-array-r/Makefile.am, tests/test-basic-nr/Makefile.am, - tests/test-basic-r/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-r/Makefile.am, - tests/test-debug-nr/Makefile.am, tests/test-debug-r/Makefile.am, - tests/test-header-nr/Makefile.am, tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-mem-nr/Makefile.am, tests/test-mem-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-posix/Makefile.am, - tests/test-posixly-correct/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-string-nr/Makefile.am, - tests/test-string-r/Makefile.am, tests/test-table-opts/Makefile.am, - tests/test-yyextra/Makefile.am: Tests now respect CFLAGS, CPPFLAGS, - etc.. - -2002-08-16 John Millaway - - * tests/test-basic-nr/scanner.l, tests/test-basic-r/scanner.l, - tests/test-lineno-nr/scanner.l, tests/test-lineno-r/scanner.l: Got - rid of flex -s warnings in tests. - -2002-08-16 John Millaway - - * Makefile.am: Updated dependencies list. - -2002-08-15 John Millaway - - * main.c: Fixed seg fault bug in ecs. - -2002-08-15 Will Estes - - * tests/test-c-cpp-nr/.cvsignore, tests/test-c-cpp-r/.cvsignore: - ignore .cpp files since we generate them instead of .c - -2002-08-15 Will Estes - - * configure.in: version 2.5.14 - -2002-08-15 Will Estes - - * NEWS: c-as-c++ tests reworked - -2002-08-15 John Millaway - - * tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-nr/scanner.l, - tests/test-c-cpp-r/Makefile.am, tests/test-c-cpp-r/scanner.l: The - c++ tests use .cpp instead of .c extensions just to be on the safe - side. - -2002-08-15 Will Estes - - * main.c: conditionally include ; include config.h as well - -2002-08-15 Will Estes - - * configure.in, flex.skl: only include if we have it - -2002-08-15 Will Estes - - * NEWS: portability fixes; added missing punctuation; de translation - now included - -2002-08-15 Will Estes - - * po/LINGUAS: we also translate to german - -2002-08-15 Will Estes - - * Makefile.am: require automake at least 1.6 - -2002-08-15 Will Estes - - * NEWS, configure.in: version 2.5.13 - -2002-08-14 Will Estes - - * flex.texi: reverted away from the @copying as it breaks the info - reader - -2002-08-14 John Millaway - - * flex.texi, flexdef.h, main.c, misc.c: Start condition prefixes - attempts to adjust to user preferences. - -2002-08-13 John Millaway - - * main.c: Include start condition symbols in header. - -2002-08-13 John Millaway - - * flexdef.h, main.c: Omit user code and tables from generated header - file. - -2002-08-13 Will Estes - - * flex.texi: use @copying construct to display the flex license; - move copying and bug reporting to the front of the manual - -2002-08-13 Will Estes - - * NEWS: printf fix and yylex_init reports errors - -2002-08-12 John Millaway - - * flex.texi: Updated manual for %option header. - -2002-08-12 John Millaway - - * flex.skl, flex.texi, gen.c: Fixed type mismatch in printf. - yylex_init now reports errors. - -2002-08-10 John Millaway - - * dfa.c, main.c: Added alignment flag for future use. - -2002-08-10 John Millaway - - * tests/test-table-opts/.cvsignore, - tests/test-table-opts/Makefile.am: Added options to test-table-opts - -2002-08-10 John Millaway - - * configure.in, tests/Makefile.am, tests/descriptions, - tests/test-c-cpp-nr/Makefile.am, tests/test-table-opts/.cvsignore, - tests/test-table-opts/Makefile.am, tests/test-table-opts/scanner.l, - tests/test-table-opts/test.input: Added a test for various DFA table - options. - -2002-08-09 Will Estes - - * flex.texi: more faq editing; corrected mistyped nodenames - -2002-08-09 Will Estes - - * flex.skl: fix typo which propogates out to generated scanners - -2002-08-09 Will Estes - - * flex.texi: edited a few more faqs - -2002-08-09 Will Estes - - * Makefile.am, faq.texi: remove faq.texi as it's included in - flex.texi - -2002-08-08 Will Estes - - * flex.texi: a few more faq edits; remove faq-89 - -2002-08-08 Will Estes - - * flex.texi: cite, not site - -2002-08-08 Will Estes - - * flex.texi: and get the faq included - -2002-08-08 Will Estes - - * flex.texi: fix some grammer/typography in the top node and add a - detailed menu - -2002-08-08 Will Estes - - * TODO: we've updated gettext - -2002-08-08 Will Estes - - * po/.cvsignore: we need to ignore a few more gettext files - -2002-08-08 Will Estes - - * NEWS, configure.in: version 2.5.12 - -2002-08-08 Will Estes - - * NEWS: mention gettext; document the non-need for bison/flex in the - build process - -2002-08-08 Will Estes - - * Makefile.am, configure.in: include intl in the distribution and in - the build process - -2002-08-08 Will Estes - - * Makefile.am: builddir in help2man call needed @-signs around it - -2002-08-08 Will Estes - - * po/.cvsignore: we can ignore Makefile.in.in - -2002-08-08 Will Estes - - * m4/.cvsignore, m4/Makefile.am: oops, too hasty on deleting this - directory, sigh - -2002-08-08 Will Estes - - * autogen.sh: if autopoint is going to run automatically, it's going - to need to be able to update existing files - -2002-08-08 Will Estes - - * ABOUT-NLS, autogen.sh, configure.in, m4/.cvsignore, - m4/Makefile.am, m4/codeset.m4, m4/gettext.m4, m4/glibc21.m4, - m4/iconv.m4, m4/isc-posix.m4, m4/lcmessage.m4, m4/lib-ld.m4, - m4/lib-link.m4, m4/lib-prefix.m4, m4/progtest.m4: autopoint now - works so let's let it run the gettext show - -2002-08-07 Will Estes - - * TODO: we need to index the faq entries - -2002-08-07 Will Estes - - * faq.texi: proofed "Why do flex scanners call fileno if it is not - ANSI compatible?" - -2002-08-07 Will Estes - - * faq.texi: proofed "How do I expand \ escape sequences in C-style - quoted strings?" - -2002-08-07 Will Estes - - * README: changes to README to align with GNU coding standards - -2002-08-06 Will Estes - - * Makefile.am: help2man should look in builddir for the flex binary - -2002-08-02 John Millaway - - * flex.skl: Fixed yyunput prototype. - -2002-08-01 Will Estes - - * NEWS: new fr translation from the translation project - -2002-08-01 Will Estes - - * po/fr.po: new fr.po translation from the translation project - -2002-08-01 Will Estes - - * NEWS: yylineno performance hit is fixed - -2002-07-31 John Millaway - - * TODO, flex.texi: Updated docs on yylineno. - -2002-07-31 Will Estes - - * TODO: discuss yylineno performance - -2002-07-31 Will Estes - - * NEWS: forgot to say what the date was that we made the release - -2002-07-31 Will Estes - - * NEWS, configure.in: version 2.5.11 - -2002-07-31 Will Estes - - * faq.texi: fixed a menu entry and related problems - -2002-07-31 Will Estes - - * configure.in: someday, maybe we can use autopoint - -2002-07-31 Will Estes - - * Makefile.am: we need to include texinfo.tex now - -2002-07-31 Will Estes - - * texinfo.tex: add texinfo.tex - -2002-07-30 Will Estes - - * faq.texi: fix up some fatal bugs in the texinfo of the faq; begin - the clean up; remove trailing and leading white space - -2002-07-30 Will Estes - - * TODO: faqs need work - -2002-07-30 Will Estes - - * NEWS, TODO: prototypes get airtime these days - -2002-07-28 John Millaway - - * flex.skl: Added some comments. - -2002-07-28 John Millaway - - * flex.skl: Fixed bug where yyless did not consider yylineno. - -2002-07-28 John Millaway - - * scan.l: Fixed bug I created in previous commit. - -2002-07-28 John Millaway - - * scan.l: Don't wrap ()s around {NAMEDEFS} at the end of a rule. - -2002-07-27 John Millaway - - * flex.skl, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-r/Makefile.am: Fixed test-c-cpp to actually use the - C++ compiler for the test. Fixed the bug that this exposed. - -2002-07-27 John Millaway - - * ccl.c, flex.skl, flexdef.h, gen.c, main.c, nfa.c, parse.y, scan.l: - yylineno check is only performed on rules whose regexs can match a - newline. - -2002-07-25 John Millaway - - * flex.skl, tests/TEMPLATE/scanner.l, - tests/test-array-nr/scanner.l, tests/test-array-r/scanner.l, - tests/test-basic-nr/scanner.l, tests/test-basic-r/scanner.l, - tests/test-bison-yylloc/parser.y, tests/test-c-cpp-nr/scanner.l, - tests/test-c-cpp-r/scanner.l, tests/test-debug-nr/scanner.l, - tests/test-debug-r/scanner.l, - tests/test-include-by-buffer/scanner.l, - tests/test-include-by-reentrant/scanner.l, - tests/test-lineno-nr/scanner.l, tests/test-lineno-r/scanner.l, - tests/test-mem-nr/scanner.l, tests/test-mem-r/scanner.l, - tests/test-posix/scanner.l, tests/test-posixly-correct/scanner.l, - tests/test-prefix-nr/scanner.l, tests/test-prefix-r/scanner.l, - tests/test-pthread/scanner.l, tests/test-string-nr/scanner.l, - tests/test-string-r/scanner.l, tests/test-yyextra/scanner.l: All - prototypes were rewritten to depend upon the macro - YY_TRADITIONAL_FUNC_DEFS, which is defined by default. The - generated scanners build cleanly under gcc's traditional strictness - and under C++ compilers. - -2002-07-24 Will Estes - - * NEWS: dist-bzip2 and rename yy_globals and yy_globals_t - -2002-07-24 Will Estes - - * configure.in: version 2.5.10 - -2002-07-24 Will Estes - - * Makefile.am: add dist-bzip2 to automake_options so we'll start - getting tar.bz2 archives - -2002-07-23 John Millaway - - * flex.skl, flex.texi, tests/test-bison-yylval/scanner.l, - tests/test-mem-r/scanner.l, - tests/test-multiple-scanners-r/scanner-1.l, - tests/test-multiple-scanners-r/scanner-2.l, - tests/test-prefix-r/scanner.l, tests/test-pthread/scanner.l, - tests/test-yyextra/scanner.l: s/yy_globals_t/yyguts_t/g - s/yy_globals/yyscanner/g - -2002-07-23 John Millaway - - * Makefile.am: typo in tags target - -2002-07-22 John Millaway - - * Makefile.am: Removed erroneous $(srcdir) from help2man target. - -2002-07-22 Will Estes - - * NEWS, configure.in: it's version 2.5.9 now - -2002-07-22 Will Estes - - * po/.cvsignore: updated gettext to 0.11.3 - -2002-07-22 Will Estes - - * ABOUT-NLS, config.rpath, m4/gettext.m4, m4/iconv.m4, - m4/isc-posix.m4, m4/lcmessage.m4, m4/lib-link.m4: updated gettext to - version 0.11.3 - -2002-07-22 Will Estes - - * autogen.sh, configure.in: rollback on configure.in and autogen.sh - because autpoint is broken - -2002-07-22 Will Estes - - * po/ru.po: new russian translation from translation project - -2002-07-19 Will Estes - - * autogen.sh: ok, we're going to start using autopoint, but the tree - is going to undergo some changes after this - -2002-07-19 Will Estes - - * configure.in: we're preparing for autopoint - -2002-07-17 John Millaway - - * flex.texi: Updated manual. - -2002-07-17 Will Estes - - * NEWS: update the NEWS file for lots of things millaway has done - -2002-07-17 John Millaway - - * flex.skl, main.c, misc.c, scan.l, scanopt.c, sym.c, - tests/test-mem-nr/scanner.l, tests/test-mem-r/scanner.l: Fixed - prototype/definition conflicts with "traditional" C in skeleton at - request of gcc developer. Removed duplicate prototypes in gen.c, - sym.c, main.c. Added missing prototypes where needed. All - functions in skeleton follow ISO C style protos and defs, instead of - BOTH ISO and new-style. Skeleton now compiles cleanly under - super-strict gcc flags. Flex itself almost compiles cleanly under - strict flags. - -2002-07-15 John Millaway - - * faq.texi, flex.texi: Worked on mem mgmt sect of manual. - -2002-07-15 Will Estes - - * scan.l: allow blank lines and continuations in more places - -2002-07-12 Will Estes - - * TODO: millaway finished the faqs directory - -2002-07-12 Will Estes - - * TODO: removed items as per email from millaway - -2002-07-12 John Millaway - - * configure.in, tests/Makefile.am, tests/descriptions, - tests/test-posix/.cvsignore, tests/test-posix/Makefile.am, - tests/test-posix/scanner.l, tests/test-posixly-correct/.cvsignore, - tests/test-posixly-correct/Makefile.am, - tests/test-posixly-correct/scanner.l: Added test for %option - posix-compat and repeat operator. Added test for POSIXLY_CORRECT - environment variable and repeat operator. - -2002-07-12 John Millaway - - * main.c, scan.l: Fixed POSIXLY_CORRECT detection in scanner. - -2002-07-11 John Millaway - - * faq.texi: More work on faq. - -2002-07-11 John Millaway - - * faq.texi: Moved all faqs into manual -- but did not evaluate them - yet. Removed the old faq files. - -2002-07-10 John Millaway - - * main.c: Removed duplicate definition of FLEX_DEBUG. gcc doesn't - care, but other compilers might. - -2002-07-10 John Millaway - - * flex.texi: Wrote some more about memory mgmt in the manual. - -2002-07-10 John Millaway - - * flex.texi: flex.texi now works with install-info. - -2002-07-10 Will Estes - - * TODO: added items as per email from millaway - -2002-07-10 Will Estes - - * NEWS: after we release a version, we have to keep the version - number in NEWS current - -2002-07-10 John Millaway - - * flex.skl, flex.texi, main.c, scan.l, tests/test-mem-nr/scanner.l, - tests/test-mem-r/scanner.l: Fixed prefix issue with get/set debug - functions. Fixed prefix issues with memory functions. - -2002-07-09 John Millaway - - * flex.skl: Memory functions are no longer static. - -2002-07-09 John Millaway - - * tests/test-mem-nr/test.input: Added a missing input file for - test-mem-nr/ - -2002-07-09 John Millaway - - * tests/test-mem-nr/.cvsignore, tests/test-mem-nr/Makefile.am, - tests/test-mem-nr/scanner.l, tests/test-mem-r/.cvsignore, - tests/test-mem-r/Makefile.am, tests/test-mem-r/scanner.l, - tests/test-mem-r/test.input: Added tests for overriding memory. - -2002-07-09 John Millaway - - * flex.texi: Added sections in manual for memory management. - -2002-07-09 Will Estes - - * NEWS: noted more user visible changes - -2002-07-09 John Millaway - - * configure.in, flex.skl, scan.l, tests/Makefile.am: Added - yylex_destroy() to non-reentrant scanner. Added ability to override - memory functions. Added tests for overriding memory functions. - -2002-07-09 Will Estes - - * NEWS: new POSIXLY_CORRECT and new ru translation - -2002-07-09 Will Estes - - * po/ru.po: new ru translation from the translation project - -2002-07-09 John Millaway - - * flex.texi: Made note of set/get debug in docs. - -2002-07-09 John Millaway - - * configure.in, flexdef.h, tests/create-test: Replaced obsolete - macros in configure.in. Modified create-test to handle the above - changes in configure.in. Added support for . - -2002-07-09 John Millaway - - * main.c: Check POSIXLY_CORRECT env variable. - -2002-07-09 John Millaway - - * flex.skl: Added prototypes for the get/set debug functions. - -2002-07-09 John Millaway - - * configure.in, flex.skl, gen.c, main.c, scan.l, tests/Makefile.am, - tests/test-debug-nr/.cvsignore, tests/test-debug-nr/Makefile.am, - tests/test-debug-nr/scanner.l, tests/test-debug-nr/test.input, - tests/test-debug-r/.cvsignore, tests/test-debug-r/Makefile.am, - tests/test-debug-r/scanner.l, tests/test-debug-r/test.input: Made - yy_flex_debug non-global in reentrant scanner. Created get/set - functions for yy_flex_debug. Defined prefixes for new yy_flex_debug - symbols. Added tests/ for yy_flex_debug. - -2002-07-09 John Millaway - - * tests/create-test: create-test script now modifies .cvsignore - -2002-07-09 John Millaway - - * tests/create-test: Improved the error checking. - -2002-07-03 Will Estes - - * main.c: fix bug whereby prefix didn't get passed to everybody; - patch by rse@engelschall.com - -2002-07-03 Will Estes - - * faq.texi: ~ is an active character, so we'll just use the word - 'about' - -2002-07-02 John Millaway - - * Makefile.am: Fixed typo. - -2002-07-02 John Millaway - - * faq.texi: Added a faq. - -2002-06-28 John Millaway - - * Makefile.am: Added 'tags' target -- something I should have done - long ago. - -2002-06-28 Will Estes - - * TODO: add two new items regarding coding; remove tests/ copyright - notice item as it's done - -2002-06-26 Will Estes - - * NEWS: note the copyright messages in tests/ - -2002-06-25 John Millaway - - * tests/TEMPLATE/Makefile.am, tests/TEMPLATE/parser.y, - tests/TEMPLATE/scanner.l, tests/test-array-nr/Makefile.am, - tests/test-array-nr/scanner.l, tests/test-array-r/Makefile.am, - tests/test-array-r/scanner.l, tests/test-basic-nr/Makefile.am, - tests/test-basic-nr/scanner.l, tests/test-basic-r/Makefile.am, - tests/test-basic-r/scanner.l, tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylloc/main.c, tests/test-bison-yylloc/parser.y, - tests/test-bison-yylloc/scanner.l, - tests/test-bison-yylval/Makefile.am, - tests/test-bison-yylval/main.c, tests/test-bison-yylval/parser.y, - tests/test-bison-yylval/scanner.l, tests/test-c-cpp-nr/Makefile.am, - tests/test-c-cpp-nr/scanner.l, tests/test-c-cpp-r/Makefile.am, - tests/test-c-cpp-r/scanner.l, tests/test-header-nr/Makefile.am, - tests/test-header-nr/main.c, tests/test-header-nr/scanner.l, - tests/test-header-r/Makefile.am, tests/test-header-r/main.c, - tests/test-header-r/scanner.l, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-buffer/scanner.l, - tests/test-include-by-reentrant/Makefile.am, - tests/test-include-by-reentrant/scanner.l, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-nr/scanner.l, - tests/test-lineno-r/Makefile.am, tests/test-lineno-r/scanner.l, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-nr/main.c, - tests/test-multiple-scanners-nr/scanner-1.l, - tests/test-multiple-scanners-nr/scanner-2.l, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-multiple-scanners-r/main.c, - tests/test-multiple-scanners-r/scanner-1.l, - tests/test-multiple-scanners-r/scanner-2.l, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-nr/scanner.l, - tests/test-prefix-r/Makefile.am, tests/test-prefix-r/scanner.l, - tests/test-pthread/Makefile.am, tests/test-pthread/scanner.l, - tests/test-string-nr/Makefile.am, tests/test-string-nr/scanner.l, - tests/test-string-r/Makefile.am, tests/test-string-r/scanner.l, - tests/test-yyextra/Makefile.am, tests/test-yyextra/scanner.l: - Prepended explicit license to all test-*/ sources. - -2002-06-25 Will Estes - - * NEWS, po/ca.po, po/de.po, po/fr.po, po/sv.po, po/tr.po: new ca, - de, fr, sv, tr translations - -2002-06-19 Will Estes - - * TODO: add bootstrapper to the todo list - -2002-06-19 Will Estes - - * configure.in: new version number - -2002-06-19 Will Estes - - * TODO: update TODO list - -2002-06-19 Will Estes - - * NEWS, TODO, flex.texi, flexdef.h, main.c, options.c, options.h, - parse.y, scan.l: address typos in NEWS; add --posix option for ERE - parsing the way posix wants it; update the TODO file - -2002-05-31 Will Estes - - * README-alpha: made code quality warning more explicit; gave url - for cvs and beta flex - -2002-05-23 John Millaway - - * gen.c: Fixed bug where omission of user section 3 caused unmatched - #ifdef's in generated code. - -2002-05-20 Will Estes - - * configure.in: configure.in requires at least autoconf 2.50 - -2002-05-13 John Millaway - - * Makefile.am: Updated my email address. - -2002-05-10 John Millaway - - * flexdef.h, misc.c: chomp'd lines when reading external skel file. - -2002-05-07 Will Estes - - * po/sv.po: new sweedish translation from the translation project - -2002-04-29 Will Estes - - * po/ca.po: new catalan translation from the translation project - -2002-04-29 Will Estes - - * po/es.po: new spanish translation from the translation project - -2002-04-25 Will Estes - - * TODO: note that the lex matching of abc{1,3} is the posix behavior - and so we have a problem - -2002-04-25 Will Estes - - * flex.texi: note that the lex matching of abc{1,3} is the posix - behavior - -2002-04-23 Will Estes - - * configure.in: new version 2.5.7; use autoconf versioning info - -2002-04-23 Will Estes - - * NEWS: note changes in 2.5.7 - -2002-04-23 Will Estes - - * main.c: conditional compile gettext initialization - -2002-04-22 Will Estes - - * po/de.po: new german translation from the translation project - -2002-04-19 John Millaway - - * tests/test-include-by-reentrant/Makefile.am: Fixed command line - for test-include-by-reentrant/Makefile.am - -2002-04-19 John Millaway - - * tests/Makefile.am, tests/TEMPLATE/Makefile.am, - tests/test-array-nr/Makefile.am, tests/test-array-r/Makefile.am, - tests/test-basic-nr/Makefile.am, tests/test-basic-r/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-r/Makefile.am, - tests/test-header-nr/Makefile.am, tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-string-nr/Makefile.am, - tests/test-string-r/Makefile.am, tests/test-yyextra/Makefile.am: - Added -I . to compiler search path in tests (so it finds the - generated parser.h). - -2002-04-19 John Millaway - - * flexdef.h, misc.c, parse.y, sym.c: Applied 'const' to a few more - char*, where appropriate. - -2002-04-19 John Millaway - - * tests/TEMPLATE/Makefile.am, tests/test-array-nr/Makefile.am, - tests/test-array-r/Makefile.am, tests/test-basic-nr/Makefile.am, - tests/test-basic-r/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-r/Makefile.am, - tests/test-header-nr/Makefile.am, tests/test-header-r/Makefile.am, - tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-reentrant/Makefile.am, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-prefix-nr/Makefile.am, tests/test-prefix-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-string-nr/Makefile.am, - tests/test-string-r/Makefile.am, tests/test-yyextra/Makefile.am: - Added top_builddir to -I path. Changed $(srcdir)/$(testname) to - ./$(testname) in 'make test' rule. - -2002-04-19 John Millaway - - * flexdef.h, gen.c, misc.c: Changed 'char[]' to 'const char*' - wherever in conflicted with gettext. - -2002-04-19 Will Estes - - * po/fr.po, po/sv.po: new files from translation after 2.5.6 beta - release - -2002-04-18 John Millaway - - * tests/test-lineno-r/Makefile.am: Fixed minor typo/cut and paste - error. - -2002-04-18 John Millaway - - * configure.in: Added yylineno test. - -2002-04-18 John Millaway - - * tests/Makefile.am: Added yylineno tests. - -2002-04-18 John Millaway - - * tests/test-lineno-nr/.cvsignore, - tests/test-lineno-nr/Makefile.am, tests/test-lineno-nr/scanner.l, - tests/test-lineno-nr/test.input, tests/test-lineno-r/.cvsignore, - tests/test-lineno-r/Makefile.am, tests/test-lineno-r/scanner.l, - tests/test-lineno-r/test.input: Created yylineno tests. - -2002-04-15 John Millaway - - * scanopt.c: Applied gettext macros to error messages from scanopt. - -2002-04-15 John Millaway - - * buf.c, faq.texi, options.c, options.h, scanopt.c, scanopt.h: - Changed copyright from Millaway to flex? U.S. Gov't? Regents of U. - Cali.? Paxson? - -2002-04-15 Will Estes - - * tests/test-bison-yylloc/Makefile.am, - tests/test-header-nr/Makefile.am, tests/test-header-r/Makefile.am: - we missed a few main.c files in the distribution - -2002-04-15 Will Estes - - * TODO: a lot more work has happened to flex; note this by removing - a number of TODO entries - -2002-04-15 Will Estes - - * TODO: make sure all gettext modules use gettext translation - facilities - -2002-04-14 John Millaway - - * faq.texi: Converted faqs 34-41 to texinfo. - -2002-04-14 John Millaway - - * Makefile.am, faq.texi, flex.texi: Added faq.texi to archive. - Added faq.texi to flex_TEXINFOS macro in Makefile.am. flex.texi now - includes faq.texi. - -2002-04-13 John Millaway - - * flexdef.h: defined FLEX_EXIT macro to call longjmp on errors. - -2002-04-13 John Millaway - - * main.c, misc.c: Replaced exit(2) calls with longjmps (in the form - of FLEX_EXIT macro). Moved main() to flex_main() to allow flex to - be called from a library. - -2002-04-13 John Millaway - - * scanopt.c: Fixed minor typo in error message - -2002-04-12 Will Estes - - * tests/test-header-nr/Makefile.am, - tests/test-header-r/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-r/Makefile.am, - tests/test-pthread/Makefile.am, tests/test-string-nr/Makefile.am, - tests/test-string-r/Makefile.am, tests/test-yyextra/Makefile.am: - removed eroneous files listed in EXTRA_DIST - -2002-04-12 Will Estes - - * tests/test-yyextra/.cvsignore: ignore Makefile.in - -2002-04-12 Will Estes - - * tests/test-string-r/.cvsignore: it's Makefile.in, not makefile.in - -2002-04-12 Will Estes - - * tests/test-yyextra/Makefile.am, tests/test-yyextra/Makefile.in: - put test-yyextra under automake - -2002-04-12 Will Estes - - * tests/test-string-r/Makefile.am, tests/test-string-r/Makefile.in: - put test-string-r under automake - -2002-04-12 Will Estes - - * tests/test-string-nr/.cvsignore, tests/test-string-r/.cvsignore: - we can ignore Makefile.in - -2002-04-12 Will Estes - - * tests/test-string-nr/Makefile.am, - tests/test-string-nr/Makefile.in: put test-string-nr under automake - -2002-04-12 Will Estes - - * tests/test-pthread/.cvsignore: ignore Makefile.in - -2002-04-12 Will Estes - - * tests/test-pthread/Makefile.am, tests/test-pthread/Makefile.in: - put test-pthread under automake - -2002-04-12 Will Estes - - * tests/test-prefix-r/Makefile.am, tests/test-prefix-r/Makefile.in: - put test-prefix-r under automake - -2002-04-12 Will Estes - - * tests/test-prefix-nr/.cvsignore, tests/test-prefix-r/.cvsignore: - we can ignore Makefile.in - -2002-04-12 Will Estes - - * tests/test-prefix-nr/Makefile.am, - tests/test-prefix-nr/Makefile.in: put test-prefix-nr under automake - -2002-04-12 Will Estes - - * tests/test-multiple-scanners-r/Makefile.am, - tests/test-multiple-scanners-r/Makefile.in: put - test-multiple-scanners-r under automake - -2002-04-12 Will Estes - - * tests/test-multiple-scanners-nr/.cvsignore, - tests/test-multiple-scanners-r/.cvsignore: we can ignore Makefile.in - now - -2002-04-12 Will Estes - - * tests/test-multiple-scanners-nr/Makefile.am, - tests/test-multiple-scanners-nr/Makefile.in: put - test-multiple-scanners-nr under automake - -2002-04-11 Will Estes - - * tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-r/Makefile.am: - we didn't need parser.y - -2002-04-11 Will Estes - - * TODO: work done on the test suite; remove relevant entries from - TODO - -2002-04-10 Will Estes - - * tests/test-include-by-reentrant/.cvsignore, - tests/test-include-by-reentrant/Makefile.am, - tests/test-include-by-reentrant/Makefile.in: put - test-include-by-reentrant under automake - -2002-04-09 Will Estes - - * tests/test-include-by-buffer/.cvsignore: we have a Makefile.in - which we need to ignore - -2002-04-09 Will Estes - - * tests/test-include-by-buffer/Makefile.am, - tests/test-include-by-buffer/Makefile.in: test-include-by-buffer now - under automake control - -2002-04-09 Will Estes - - * tests/TEMPLATE/Makefile.am: and we want LFLAGS in the rule to make - scanner.c as well - -2002-04-09 Will Estes - - * tests/test-header-r/.cvsignore, tests/test-header-r/Makefile.am, - tests/test-header-r/Makefile.in: put test-header-r under automake - -2002-04-09 Will Estes - - * tests/test-header-nr/.cvsignore: we now generate a Makefile.in - from automake; cvs should ignore it - -2002-04-09 Will Estes - - * tests/test-header-nr/Makefile.am: add dependencies for main.o and - scaner.h - -2002-04-09 Will Estes - - * tests/TEMPLATE/Makefile.am: We may want to have LFLAGS readily - available - -2002-04-09 Will Estes - - * tests/test-header-nr/Makefile.am, - tests/test-header-nr/Makefile.in: put test-header-nr under automake - -2002-04-09 Will Estes - - * tests/TEMPLATE/Makefile.am: oops, we need to clean objects too - -2002-04-09 Will Estes - - * tests/TEMPLATE/Makefile.am, tests/test-array-nr/Makefile.am, - tests/test-array-r/Makefile.am, tests/test-basic-nr/Makefile.am, - tests/test-basic-r/Makefile.am, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylval/Makefile.am, - tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-r/Makefile.am: now - that config.h lives in the top-level directory, we need to tell the - testsuite - -2002-04-08 Will Estes - - * tests/test-array-nr/.cvsignore, tests/test-array-r/.cvsignore, - tests/test-basic-nr/.cvsignore, tests/test-basic-r/.cvsignore, - tests/test-bison-yylval/.cvsignore, tests/test-c-cpp-nr/.cvsignore, - tests/test-c-cpp-r/.cvsignore: we can ignore some Makefile.in - -2002-04-08 Will Estes - - * configure.in, tests/TEMPLATE/Makefile.am: only one config file - header apparently; this will have consequences in the test suite - -2002-04-08 Will Estes - - * tests/test-bison-yylval/Makefile.am, - tests/test-bison-yylval/Makefile.in: adding automake support - -2002-04-08 Will Estes - - * tests/test-bison-yylloc/.cvsignore, - tests/test-bison-yylloc/Makefile.am: tuned Makefile.am to build - correctly; ignore Makefile.in now - -2002-04-08 Will Estes - - * tests/configure.in: test suite changes - -2002-04-08 Will Estes - - * autogen.sh, configure.in, tests/.cvsignore, tests/Makefile.am, - tests/Makefile.in, tests/README, tests/TEMPLATE/.cvsignore, - tests/TEMPLATE/Makefile.am, tests/TEMPLATE/Makefile.in, - tests/configure.in, tests/create-test, tests/create-test.pl, - tests/test-array-nr/Makefile.am, tests/test-array-nr/Makefile.in, - tests/test-array-r/Makefile.am, tests/test-array-r/Makefile.in, - tests/test-basic-nr/Makefile.am, tests/test-basic-nr/Makefile.in, - tests/test-basic-r/Makefile.am, tests/test-basic-r/Makefile.in, - tests/test-bison-yylloc/Makefile.am, - tests/test-bison-yylloc/Makefile.in, - tests/test-c-cpp-nr/Makefile.am, tests/test-c-cpp-nr/Makefile.in, - tests/test-c-cpp-r/Makefile.am, tests/test-c-cpp-r/Makefile.in: test - suite changes - -2002-04-05 John Millaway - - * flex.texi: Corrected error in manual regarding return type for - yy_scan_{string,buffer,bytes}. - -2002-04-05 Will Estes - - * po/de.po: new german translations from the translation project - -2002-04-03 Will Estes - - * po/es.po: new spanish translations - -2002-04-01 Will Estes - - * Makefile.am: DIST_SUBDIRS: new variable. we can build flex with - SUBDIRS and then build the distribution using DIST_SUBDIRS - -2002-04-01 Will Estes - - * main.c: fix typo in comment - -2002-03-31 John Millaway - - * main.c: Documented the header file kludge, (in anticipation of - buffering Section 1.) - -2002-03-31 John Millaway - - * flex.texi: Created appendix "Makefiles and Flex" in the manual. - -2002-03-30 John Millaway - - * flex.texi: updating manual. - -2002-03-29 Will Estes - - * po/POTFILES.in: we want parse.y, not parse.c - -2002-03-29 John Millaway - - * flex.texi: Indexing the manual (75% done). - -2002-03-29 Will Estes - - * Makefile.am: unlisted intermediate flex/yacc-created files - -2002-03-29 Will Estes - - * TODO: millaway has done more work - -2002-03-29 Will Estes - - * Makefile.am, configure.in: ok, one last touch up; users most - likely wont have help2man so we need to insure that's ok - -2002-03-29 Will Estes - - * Makefile.am: fine tune flex.1 some more - -2002-03-29 Will Estes - - * Makefile.am, configure.in: generalize the manpage a bit and tell - autofoo about help2man - -2002-03-29 Will Estes - - * po/da.po: new danish from translation project robot - -2002-03-28 John Millaway - - * flex.texi: Indexing the manual -- it's only half done. - -2002-03-28 John Millaway - - * flex.texi: flex manual now uses automake's versioning info. - -2002-03-28 John Millaway - - * README.cvs-snapshot: Mentioned requirements for gettext and - help2man. - -2002-03-28 John Millaway - - * Makefile.am, main.c: Output of `flex --version` now matches GNU - coding standards. Makefile.am now uses `help2man` to generate - flex.1 - -2002-03-27 Will Estes - - * TODO: millaway has done a lot on the TODO list; remove those items - that he has take care of - -2002-03-27 Will Estes - - * README.cvs-snapshot: edited millaway's initial draft - -2002-03-27 John Millaway - - * README.cvs-snapshot: Created file. - -2002-03-27 John Millaway - - * flex.texi: Fixed case of node names in flex.texi. - -2002-03-24 Will Estes - - * TODO: lex- and yacc- generated files - -2002-03-24 Will Estes - - * po/fr.po: new french - -2002-03-18 Will Estes - - * NEWS: ending periods in news items removed; mention nounistd - options - -2002-03-18 Will Estes - - * po/sv.po: updated sweedish translations - -2002-03-18 Will Estes - - * po/de.po: german translation - -2002-03-18 John Millaway - - * flex.skl, flex.texi, main.c, options.c, options.h, scan.l: Removed - CFront 1.2 -specific code from skeleton, because CFront now defines - __cplusplus properly. Removed TurboC-specific code from skeleton. - Skeleton now includes proper C++ standard headers. Relocated - "unistd.h" code after user section 1 to allow user to overrid it. - New option "nounistd" to suppress unistd.h from being included. - -2002-03-15 Will Estes - - * po/tr.po: new turkish translation - -2002-03-15 Will Estes - - * NEWS: mention included translations - -2002-03-15 Will Estes - - * TODO: we've done the gettext thing, but sometime we should get - 0.11.1 - -2002-03-15 Will Estes - - * po/ca.po: new catalan translation - -2002-03-14 John Millaway - - * flex.texi: Added section on format of comments. - -2002-03-14 John Millaway - - * flex.texi: Split format chapter into sections. - -2002-03-14 John Millaway - - * flex.texi: Removed explicit pointers in node definitions. - -2002-03-14 Will Estes - - * configure.in: unistd.h can be problematic - -2002-03-14 Will Estes - - * tests/README: editing changes to README - -2002-03-13 Will Estes - - * po/POTFILES.in: scan.l, not scan.c because gettext gets confused - -2002-03-13 Will Estes - - * scan.l: gettext cruft - -2002-03-13 Will Estes - - * tests/descriptions: separate out test descriptions - -2002-03-13 Will Estes - - * po/LINGUAS: french and korean dont crash now - -2002-03-12 Will Estes - - * po/fr.po, po/ko.po: remove duplicate messages as per advice from - Jordi Mallach - -2002-03-12 Will Estes - - * gettext.h: yes, more gettext cruft - -2002-03-12 Will Estes - - * ABOUT-NLS, config.rpath, m4/codeset.m4, m4/gettext.m4, - m4/glibc21.m4, m4/iconv.m4, m4/isc-posix.m4, m4/lcmessage.m4, - m4/lib-ld.m4, m4/lib-link.m4, m4/lib-prefix.m4, m4/progtest.m4: this - is gettext cruft - -2002-03-12 Will Estes - - * NEWS: gettext and autofoo are now involved - -2002-03-12 Will Estes - - * Makefile.am, autogen.sh, configure.in, flexdef.h, main.c: mostly, - changes for gettext - -2002-03-12 Will Estes - - * po/ca.po, po/da.po, po/es.po, po/ru.po, po/sv.po, po/tr.po: these - sure change a lot - -2002-03-12 Will Estes - - * TODO: note about cvs documentation - -2002-03-12 Will Estes - - * po/LINGUAS: we now have turkish - -2002-03-12 Will Estes - - * po/tr.po: updated translations, i think - -2002-03-12 Will Estes - - * po/ca.po, po/da.po, po/es.po, po/fr.po, po/ko.po, po/ru.po, - po/sv.po, po/tr.po: ok, maybe we do keep these things? - -2002-03-12 Will Estes - - * README-alpha: README-alpha for those bad-hair days - -2002-03-12 Will Estes - - * m4/.cvsignore, m4/Makefile.am: ok,now we kinda have a m4/ subdir - for gettext - -2002-03-12 Will Estes - - * po/.cvsignore, po/LINGUAS, po/Makevars, po/POTFILES.in, po/da.po, - po/es.po, po/fr.po, po/ko.po, po/ru.po, po/sv.po: now, we have a po/ - subdirectory for gettext. i hope you're happy - -2002-03-12 Will Estes - - * po/ca.po: removing po files, maybe - -2002-03-12 Will Estes - - * tests/.cvsignore: ignore autom4te.cache - -2002-03-11 Will Estes - - * po/ca.po, po/da.po, po/es.po, po/fr.po, po/ko.po, po/ru.po, - po/sv.po: po files from debian - -2002-03-08 Will Estes - - * TODO: add several notes about tasks which need doing; create a new - top-level entry for generic coding concerns (this is distinct from - specific API or other such issues) - -2002-03-06 Will Estes - - * README: eliminate to.do and faqs from the README file - -2002-03-06 Will Estes - - * TODO: more notes on tests/ - -2002-03-06 Will Estes - - * Makefile.am: remove subdirectories from EXTRA_DIST; add a SUBDIRS - macro to handle examples/; clean up the dist-hook target - -2002-03-06 Will Estes - - * configure.in: we want to generate Makefiles in some more - subdirectories; automake will like this - -2002-03-06 Will Estes - - * TODO: notes on subdirectories - -2002-03-05 Will Estes - - * examples/.cvsignore, examples/Makefile.am: now examples/ fits into - automake - -2002-03-05 Will Estes - - * examples/fastwc/.cvsignore, examples/fastwc/Makefile.am: - examples/fastwc now fits into automake - -2002-03-05 Will Estes - - * examples/manual/.cvsignore, examples/manual/Makefile.am, - examples/manual/Makefile.examples, examples/manual/README: - examples/manual directory now fits into automake - -2002-03-05 Will Estes - - * examples/manual/Makefile: renamed Makefile to Makefile.examples - for automake's sake - -2002-03-04 Will Estes - - * Makefile.am: add parse.c and scan.c to built_sources - -2002-02-24 John Millaway - - * Makefile.am: Removed CVS-specific code from 'dist-hook' target so - anybody with a copy of the tree can build a dist. - -2002-02-22 John Millaway - - * tests/Makefile.in: Converted test script to portable /bin/sh. - -2002-02-22 John Millaway - - * tests/test-bison-yylloc/Makefile.in: Added some spaces in shell - scripts for portability. - -2002-02-22 John Millaway - - * tests/create-test.pl: Fixed #! line for portability. - -2002-02-22 John Millaway - - * tests/test-bison-yylloc/Makefile.in: Fixed return status code on - bison-lloc test. - -2002-02-21 John Millaway - - * tests/create-test.pl: Added script to auto-create tests. Probably - overkill. - -2002-02-21 John Millaway - - * flex.skl: Fixed C++ #ifdef problem. Removed mistyped __CPLUSPLUS - macro. Removed THROW_NIL. Not sure where it came from in the first - place. - -2002-02-21 John Millaway - - * tests/README, tests/TEMPLATE/Makefile.in, tests/configure.in, - tests/test-c-cpp-nr/.cvsignore, tests/test-c-cpp-nr/Makefile.in, - tests/test-c-cpp-nr/scanner.l, tests/test-c-cpp-nr/test.input, - tests/test-c-cpp-r/.cvsignore, tests/test-c-cpp-r/Makefile.in, - tests/test-c-cpp-r/scanner.l, tests/test-c-cpp-r/test.input: Added - test-c-cpp-nr and test-c-cpp-r. - -2002-02-16 John Millaway - - * flex.skl: Added missing #endif. - -2002-02-07 Will Estes - - * tests/TEMPLATE/.cvsignore, tests/test-array-nr/.cvsignore, - tests/test-array-r/.cvsignore, tests/test-basic-nr/.cvsignore, - tests/test-basic-r/.cvsignore, tests/test-bison-yylloc/.cvsignore, - tests/test-bison-yylval/.cvsignore, - tests/test-header-nr/.cvsignore, tests/test-header-r/.cvsignore, - tests/test-include-by-buffer/.cvsignore, - tests/test-include-by-reentrant/.cvsignore, - tests/test-multiple-scanners-nr/.cvsignore, - tests/test-multiple-scanners-r/.cvsignore, - tests/test-prefix-nr/.cvsignore, tests/test-prefix-r/.cvsignore, - tests/test-pthread/.cvsignore, tests/test-string-nr/.cvsignore, - tests/test-string-r/.cvsignore, tests/test-yyextra/.cvsignore: add - OUTPUT to .cvsignore files in test directories; it's also in the - template directory - -2002-02-06 Will Estes - - * gen.c: fix interrupted reads and freads; from the debian package - maintainer - -2002-02-06 Will Estes - - * flex.texi, flexdef.h, main.c, nfa.c: support large flex tables; - from debian package maintainer - -2002-01-29 Will Estes - - * tests/configure.in: add more output files to account for new tests - -2002-01-03 Will Estes - - * tests/test-array-nr/.cvsignore, tests/test-array-nr/Makefile.in, - tests/test-array-nr/scanner.l, tests/test-array-nr/test.input: add - this test - -2002-01-03 Will Estes - - * tests/test-array-r/.cvsignore, tests/test-array-r/Makefile.in, - tests/test-array-r/scanner.l, tests/test-array-r/test.input: add - this test suite - -2001-11-20 Will Estes - - * flex.skl, main.c: millaway: Fixed yytext_ptr when using %array in - reentrant scanner - -2001-11-20 Will Estes - - * buf.c: oops, forgot this one line - -2001-11-14 Will Estes - - * tests/test-header-r/.cvsignore, tests/test-header-r/Makefile.in, - tests/test-header-r/main.c, tests/test-header-r/scanner.l, - tests/test-header-r/test.input: and more fallout - -2001-11-14 Will Estes - - * TODO, flex.skl, flex.texi, flexdef.h, main.c, misc.c, - tests/README, tests/TEMPLATE/Makefile.in, tests/configure.in, - tests/test-basic-r/scanner.l, tests/test-bison-yylloc/.cvsignore, - tests/test-bison-yylloc/Makefile.in, - tests/test-bison-yylloc/parser.y, - tests/test-bison-yylloc/scanner.l, - tests/test-bison-yylval/.cvsignore, - tests/test-bison-yylval/Makefile.in, - tests/test-bison-yylval/parser.y, - tests/test-bison-yylval/scanner.l, - tests/test-include-by-reentrant/scanner.l, - tests/test-prefix-r/scanner.l, tests/test-pthread/scanner.l, - tests/test-string-r/scanner.l, tests/test-yyextra/scanner.l: more - from the same batch - -2001-11-14 Will Estes - - * tests/test-bison-yylloc/main.c, tests/test-bison-yylval/main.c, - tests/test-header-nr/.cvsignore, tests/test-header-nr/Makefile.in, - tests/test-header-nr/main.c, tests/test-header-nr/scanner.l, - tests/test-header-nr/test.input, - tests/test-multiple-scanners-nr/.cvsignore, - tests/test-multiple-scanners-nr/Makefile.in, - tests/test-multiple-scanners-nr/main.c, - tests/test-multiple-scanners-nr/scanner-1.l, - tests/test-multiple-scanners-nr/scanner-2.l, - tests/test-multiple-scanners-r/.cvsignore, - tests/test-multiple-scanners-r/Makefile.in, - tests/test-multiple-scanners-r/main.c, - tests/test-multiple-scanners-r/scanner-1.l, - tests/test-multiple-scanners-r/scanner-2.l: a big batch from - millaway - -2001-10-26 Will Estes - - * NEWS: now NEWS has forgotten about the _r variables - -2001-10-26 Will Estes - - * flex.skl, flex.texi, gen.c, main.c, - tests/test-bison-yylloc/scanner.l, - tests/test-bison-yylval/scanner.l, - tests/test-include-by-reentrant/scanner.l, - tests/test-prefix-nr/scanner.l, tests/test-pthread/scanner.l, - tests/test-string-r/scanner.l, tests/test-yyextra/scanner.l: - millaway simplified the reentrant api; here's the result - -2001-10-23 Will Estes - - * main.c, options.c, options.h: more from millaway - -2001-10-22 Will Estes - - * main.c, options.c, options.h: the last checkin was broken; - millaway fixed it - -2001-10-22 Will Estes - - * flex.skl, flex.texi, gen.c, main.c, misc.c, options.h, scan.l, - scanopt.c, tests/README, tests/configure.in: phew, millaway's latest - batch - -2001-10-21 Will Estes - - * flex.skl: flex.skl should come up in C mode - -2001-10-21 Will Estes - - * flex.skl: apparently, isatty and c++ need help getting along (from - octave) - -2001-10-19 Will Estes - - * NEWS: document new options and new option handling - -2001-10-19 Will Estes - - * TODO: tell emacs that TODO is a text/outline mode file - -2001-10-19 Will Estes - - * TODO: we have new long options; we need to document that - -2001-10-19 Will Estes - - * NEWS: tell emacs that NEWS is text/outline mode - -2001-10-19 Will Estes - - * flex.skl: oops, lost a line somewhere in the merge process on - millaway's work - -2001-10-17 Will Estes - - * Makefile.am, buf.c, flex.skl, flex.texi, flexdef.h, main.c, - misc.c, options.c, options.h, parse.y, scan.l, scanopt.c, scanopt.h: - merge latest batch of millaway's changes - -2001-09-22 Will Estes - - * main.c: Fixed typo in options display - -2001-09-20 Will Estes - - * main.c: reentrant and non-reentrant scanners share the same yywrap - MACRO. millaway - -2001-09-20 Will Estes - - * TODO: clarify item on comments in lexical files - -2001-09-20 Will Estes - - * NEWS, scan.l: now flex recognizes \r as an eol character - -2001-09-20 Will Estes - - * Makefile.am: specify cvsroot so automake distcheck works - -2001-09-19 Will Estes - - * flex.texi: tex has lost its mind; we remove parentheses to - compensate - -2001-09-19 Will Estes - - * NEWS: now that c++ is better supported, let's mention it as a news - item - -2001-09-19 Will Estes - - * examples/fastwc/wc1.l, examples/fastwc/wc2.l, - examples/fastwc/wc3.l, examples/fastwc/wc4.l, - examples/fastwc/wc5.l, flex.skl, main.c: commit the backwash from - the branch merges - -2001-09-19 Will Estes - - * FlexLexer.h, examples/testxxLexer.l, flex.skl: made preliminary - c++ fixes; the intent is to make it work with recent c++ compilers - -2001-08-26 Will Estes - - * main.c: remove argv_fixup; fix typo in error message; changes from - millaway's branch - -2001-08-24 Will Estes - - * NEWS: mention no more c++ comments in c scanners - -2001-08-21 John Millaway - - * flex.skl: Changed // comments to /* */ comments in skeleton. - -2001-08-19 John Millaway - - * flex.texi: Changed @var to @code everywhere. - -2001-08-16 Will Estes - - * to.do/flex.rmail: more mail - -2001-08-16 Will Estes - - * TODO: the manual now has its own section; we're not adding - comments either - -2001-08-04 John Millaway - - * tests/Makefile.in, tests/README, tests/TEMPLATE/Makefile.in, - tests/test-basic-nr/Makefile.in, tests/test-basic-r/Makefile.in, - tests/test-bison-yylloc/Makefile.in, - tests/test-bison-yylval/Makefile.in, - tests/test-include-by-buffer/Makefile.in, - tests/test-include-by-reentrant/Makefile.in, - tests/test-prefix-nr/Makefile.in, tests/test-prefix-r/Makefile.in, - tests/test-pthread/Makefile.in, tests/test-string-nr/Makefile.in, - tests/test-string-r/Makefile.in, tests/test-yyextra/Makefile.in: - Cleaned up the output of the tests. - -2001-08-03 Will Estes - - * TODO: note jason's thoughts on having a manpage - -2001-08-03 Will Estes - - * TODO: note millaway's assignment and tests to be under flex - license - -2001-08-01 John Millaway - - * tests/test-bison-yylval/scanner.l: Fixed semantics of test (the - success or failure of this test should be unaffected by this - change.) - -2001-08-01 Will Estes - - * autogen.sh: fake automake into believing that ChangeLog already - exists - -2001-08-01 Will Estes - - * Makefile.am: millaway needs to be covered in the ChangeLog - -2001-08-01 Will Estes - - * version.h: automake is supplying version info now so we just pick - it up - -2001-08-01 Will Estes - - * flex.texi: forgot braces on @copyright - -2001-08-01 John Millaway - - * flex.skl: Added missing argument to yy_flex_free. - -2001-08-01 Will Estes - - * AUTHORS: john millaway wrote the reentrant C support - -2001-08-01 Will Estes - - * flex.texi: add license node to the manual - -2001-08-01 Will Estes - - * TODO: c++ ideas - -2001-07-31 Will Estes - - * parse.y: error messages will now show up the way that emacs likes - them - -2001-07-31 Will Estes - - * Makefile.am: oops, left in an extra backslash - -2001-07-31 Will Estes - - * TODO: flex.texi is here; clarify tests/ rewrite issue - -2001-07-31 Will Estes - - * NEWS: hey, we have texinfo, not man - -2001-07-31 Will Estes - - * flex.1: no more manpage - -2001-07-31 Will Estes - - * Makefile.am: remove flex.1 and rewrite the dist-hook so that we - pick up a couple more directories - -2001-07-31 Will Estes - - * flex.texi: the namual now compiles; hurray - -2001-07-31 Will Estes - - * Makefile.am: first attempt at including the tests/ directory via - automake, dist-hook target added - -2001-07-31 Will Estes - - * tests/.cvsignore: ignore config.cache in tests/ directory - -2001-07-31 Will Estes - - * Makefile.am: automake groks the ChangeLog now so we don't have to - remind the maintainer to remake it - -2001-07-30 Will Estes - - * flex.texi: more corrections to the manual; the end is in site - -2001-07-30 Will Estes - - * TODO: auto-generated backup? - -2001-07-27 Will Estes - - * flex.texi: today's tinkering on the manual - -2001-07-27 Will Estes - - * Makefile.am: if we want flex.1 we have to say so in EXTRA_DIST - -2001-07-27 Will Estes - - * TODO: note future issues with flex.texi - -2001-07-27 Will Estes - - * Makefile.am: include flex.1 as it's the only working documentation - for now - -2001-07-27 Will Estes - - * Makefile.am: rearrange to work with automake on building the - ChangeLog - -2001-07-27 Will Estes - - * scan.l: automake is unhappy if we specify the outfile - -2001-07-26 Will Estes - - * flex.texi: more conversions/corrections - -2001-07-26 Will Estes - - * README: we removed misc/ so we don't mention it any more - -2001-07-25 Will Estes - - * flex.texi: begin the manual conversion to texinfo; yes, it's - broken right now - -2001-07-25 Will Estes - - * AUTHORS, THANKS: copy in manual author and thanks info - -2001-07-25 Will Estes - - * Makefile.am: how to fake the ChangeLog into showing up in the - distribution - -2001-07-25 Will Estes - - * Makefile.am: add YFLAGS so parse.h gets made - -2001-07-24 Will Estes - - * examples/fastwc/README, examples/fastwc/mywc.c, - examples/fastwc/wc1.l, examples/fastwc/wc2.l, - examples/fastwc/wc3.l, examples/fastwc/wc4.l, examples/fastwc/wc5.l: - re-add these files - -2001-07-24 Will Estes - - * TODO: reflect recent doings - -2001-07-24 Will Estes - - * Makefile.in: what with automake, we don't need Makefile.in any - more - -2001-07-24 Will Estes - - * configure.in: more rearranging for automake - -2001-07-24 Will Estes - - * to.do/flex.rmail: more mail came in - -2001-07-24 Will Estes - - * autogen.sh: adjust to automake's idea of the world - -2001-07-24 Will Estes - - * Makefile.am: add Vern's misc dependencies; noinst_SCRIPTS was - broken?; list a few last files to be included in the distribution - -2001-07-24 Will Estes - - * NEWS: rearrange for better order; add automake support as a news - item - -2001-07-24 Will Estes - - * Makefile.am: copyright notice on Makefile.am; document some -D - switches (are they still usable?) - -2001-07-24 Will Estes - - * TODO: add lex-replacement issue - -2001-07-24 Will Estes - - * Makefile.am: add EXTRA_DIST - -2001-07-23 Will Estes - - * autogen.sh: we need to do the same thing in each directory - -2001-07-23 Will Estes - - * configure.in: introduce automake into the macro calls - -2001-07-23 Will Estes - - * Makefile.am: add AUTOMAKE_OPTIONS, info_TEXINFOS, include_HEADERS, - noinst_HEADERS; it's libfl.a, not libflex.a - -2001-07-23 Will Estes - - * Makefile.am: bin_PROGRAMS and lib_LIBRARIES - -2001-07-23 Will Estes - - * to.do/streams.mail: streams.mail has moved here - -2001-07-23 Will Estes - - * TODO: add xref for teximanual - -2001-07-19 Will Estes - - * flex.1: include typo/punctuation fixes from a patch submitted by - noon@cote-dazur.com (Fabrice Bauzac) - -2001-07-17 Will Estes - - * TODO: we want gettext - -2001-06-24 Will Estes - - * flex.skl: include c++ STD fixes from quanstro@quanstro.net - -2001-06-24 Will Estes - - * flex.skl, gen.c: change some int types to size_t as per FreeBSD - 28364 from avn@any.ru - -2001-06-24 Will Estes - - * TODO: remove parse.[ch] from make clean target; repackage - distribution (not rework) - -2001-06-19 Will Estes - - * TODO: add memory api and reworking of flex.skl reworking - -2001-06-18 Will Estes - - * flex.skl: remove extraneous notice from flex.skl - -2001-06-18 Will Estes - - * flex.skl: patch memory leak as per millaway - -2001-06-17 Will Estes - - * to.do/flex.rmail: add vern's ok for copyright/license changes and - john's answer on line offsets - -2001-06-17 Will Estes - - * TODO: remove creation of .cvsignore files (it's done); add other - notes about the test suite - -2001-06-17 Will Estes - - * tests/TEMPLATE/.cvsignore, tests/test-basic-nr/.cvsignore, - tests/test-basic-r/.cvsignore, tests/test-bison-yylloc/.cvsignore, - tests/test-bison-yylval/.cvsignore, - tests/test-include-by-buffer/.cvsignore, - tests/test-include-by-reentrant/.cvsignore, - tests/test-prefix-nr/.cvsignore, tests/test-prefix-r/.cvsignore, - tests/test-pthread/.cvsignore, tests/test-string-nr/.cvsignore, - tests/test-string-r/.cvsignore, tests/test-yyextra/.cvsignore: - adding .cvsignore files for existing tests/ subdirectories - -2001-06-17 Will Estes - - * tests/README: reformat, say to add a description to this file and - mention what to do re .cvsignore - -2001-06-17 Will Estes - - * tests/TEMPLATE/cvsignore: create template for .cvsignore - -2001-06-17 Will Estes - - * TODO: reorganize for logical reasons; test suite now seems to run - out of the box - -2001-06-17 Will Estes - - * tests/.cvsignore: we dont want the Makefile either - -2001-06-17 Will Estes - - * tests/test-prefix-nr/test.input, tests/test-prefix-r/test.input: - test.input was supposed to be here - -2001-06-17 Will Estes - - * tests/.cvsignore: add autoconf legacy files to be ignored - -2001-06-17 Will Estes - - * autogen.sh: clarify usage instructions; prepare tests/ as well - -2001-06-17 Will Estes - - * tests/.cvsignore: . cvsignore for tests/ subdirectory - -2001-06-17 Will Estes - - * FlexLexer.h: tell emacs that FlexLexer.h is c++ - -2001-06-17 Will Estes - - * scan.l: tell emacs scan.l is in C mode - -2001-06-17 Will Estes - - * flex.skl: added punctuation - -2001-06-17 Will Estes - - * FlexLexer.h, Makefile.in, README, RoadMap, autogen.sh, ccl.c, - configure.in, dfa.c, ecs.c, flex.1, flex.skl, flexdef.h, gen.c, - libmain.c, libyywrap.c, main.c, misc.c, mkskel.sh, nfa.c, parse.y, - scan.l, sym.c, tblcmp.c, yylex.c: change copyright/license notices - as per Vern's response to Theo - -2001-06-15 Will Estes - - * to.do/flex.rmail: add bill fenlason's emails - -2001-06-15 Will Estes - - * COPYING: make changes as per Theo De Raadt; remove tabs - -2001-06-08 Will Estes - - * flex.skl: save errno as per Theo de Raadt - -2001-06-07 Will Estes - - * flex.1: correct hyphenation as per openbsd tree - -2001-06-05 Will Estes - - * Makefile.in, configure.in: change references to TESTS/ to tests/ - to account for the directory name changes - -2001-05-27 Will Estes - - * flex.skl, gen.c: commit john millaway's YY_G wrapper corrections - -2001-05-21 Will Estes - - * tests/Makefile.in: remove || exit calls - -2001-05-21 Will Estes - - * gen.c: complete john millaway's reentrant patch - -2001-05-21 Will Estes - - * to.do/flex.rmail: more flex messages in the queue - -2001-05-18 Will Estes - - * flex.skl, flexdef.h, gen.c, main.c, nfa.c, scan.l: john millaway's - reentrancy patch - -2001-05-18 Will Estes - - * tests/Makefile.in: remove || exit from testing loop - -2001-05-18 Will Estes - - * Makefile.in: tell make about the tests directory and its - associated targets - -2001-05-18 Will Estes - - * TODO: rethink the todo list - -2001-05-18 Will Estes - - * flex.1: describe reentrant api changes - -2001-05-18 Will Estes - - * TODO: mention work needed for tests/ - -2001-05-18 Will Estes - - * configure.in: tell auto* about the test directory - -2001-05-18 Will Estes - - * README: make punctuation uniform, mention the new tests/ directory - -2001-05-18 Will Estes - - * NEWS: reformat items; cut out old items and move them to ONEWS - -2001-05-18 Will Estes - - * ONEWS: move old NEWS items to ONEWS - -2001-05-18 Will Estes - - * tests/Makefile.in, tests/README, tests/TEMPLATE/Makefile.in, - tests/TEMPLATE/parser.y, tests/TEMPLATE/scanner.l, - tests/TEMPLATE/test.input, tests/configure.in, - tests/test-basic-nr/Makefile.in, tests/test-basic-nr/scanner.l, - tests/test-basic-nr/test.input, tests/test-basic-r/Makefile.in, - tests/test-basic-r/scanner.l, tests/test-basic-r/test.input, - tests/test-bison-yylloc/Makefile.in, - tests/test-bison-yylloc/parser.y, - tests/test-bison-yylloc/scanner.l, - tests/test-bison-yylloc/test.input, - tests/test-bison-yylval/Makefile.in, - tests/test-bison-yylval/parser.y, - tests/test-bison-yylval/scanner.l, - tests/test-bison-yylval/test.input, - tests/test-include-by-buffer/Makefile.in, - tests/test-include-by-buffer/scanner.l, - tests/test-include-by-buffer/test-1.input, - tests/test-include-by-buffer/test-2.input, - tests/test-include-by-buffer/test-3.input, - tests/test-include-by-reentrant/Makefile.in, - tests/test-include-by-reentrant/scanner.l, - tests/test-include-by-reentrant/test-1.input, - tests/test-include-by-reentrant/test-2.input, - tests/test-include-by-reentrant/test-3.input, - tests/test-prefix-nr/Makefile.in, tests/test-prefix-nr/README, - tests/test-prefix-nr/scanner.l, tests/test-prefix-r/Makefile.in, - tests/test-prefix-r/README, tests/test-prefix-r/scanner.l, - tests/test-pthread/Makefile.in, tests/test-pthread/scanner.l, - tests/test-pthread/test-1.input, tests/test-pthread/test-2.input, - tests/test-pthread/test-3.input, tests/test-pthread/test-4.input, - tests/test-pthread/test-5.input, tests/test-string-nr/Makefile.in, - tests/test-string-nr/scanner.l, tests/test-string-r/Makefile.in, - tests/test-string-r/scanner.l, tests/test-yyextra/Makefile.in, - tests/test-yyextra/scanner.l, tests/test-yyextra/test.input: add - john millaway's test directory - -2001-05-04 Will Estes - - * to.do/flex.rmail: more mail in flex.rmail - -2001-05-03 Will Estes - - * FlexLexer.h, ccl.c, dfa.c, ecs.c, flex.skl, flexdef.h, gen.c, - libmain.c, libyywrap.c, main.c, misc.c, nfa.c, parse.y, scan.l, - sym.c, tblcmp.c, yylex.c: remove extraneous rcs keywords - -2001-05-03 Will Estes - - * README: mention RoadMap - -2001-05-01 Will Estes - - * examples/README, examples/debflex.awk, examples/manual/ChangeLog, - examples/manual/Makefile, examples/manual/README, - examples/manual/cat.lex, examples/manual/dates.lex, - examples/manual/datetest.dat, examples/manual/eof_rules.lex, - examples/manual/eof_test01.txt, examples/manual/eof_test02.txt, - examples/manual/eof_test03.txt, examples/manual/expr.lex, - examples/manual/expr.y, examples/manual/front.lex, - examples/manual/front.y, examples/manual/j2t.lex, - examples/manual/myname.lex, examples/manual/myname.txt, - examples/manual/myname2.lex, examples/manual/numbers.lex, - examples/manual/pas_include.lex, examples/manual/pascal.lex, - examples/manual/reject.lex, examples/manual/replace.lex, - examples/manual/string1.lex, examples/manual/string2.lex, - examples/manual/strtest.dat, examples/manual/unput.lex, - examples/manual/user_act.lex, examples/manual/userinit.lex, - examples/manual/wc.lex, examples/manual/yymore.lex, - examples/manual/yymore2.lex, examples/manual/yymoretest.dat, - examples/testxxLexer.l, to.do/README, to.do/Wilhelms.todo, - to.do/Wish-List, to.do/flex.rmail, to.do/unicode/FlexLexer.h, - to.do/unicode/ccl.c, to.do/unicode/changes.txt, - to.do/unicode/ecs.c, to.do/unicode/flex.1, to.do/unicode/flex.skl, - to.do/unicode/flexdef.h, to.do/unicode/gen.c, to.do/unicode/main.c, - to.do/unicode/misc.c, to.do/unicode/scan.l, to.do/unicode/tblcmp.c: - adding the rest of vern's files - -2001-05-01 Will Estes - - * README: mention misc/ directory - -2001-05-01 Will Estes - - * version.h: version is 2.5.5b - -2001-05-01 Will Estes - - * Makefile.in: remove header from top; add rule to generate - initscan.c just in case - -2001-05-01 Will Estes - - * configure.in: dont check for initscan.c; check for scan.l instead - -2001-05-01 Will Estes - - * RoadMap: list of source files - -2001-05-01 Will Estes - - * README: rewrite README to reflect changes in layout of directories - -2001-05-01 Will Estes - - * AUTHORS, THANKS, TODO: initial attempt at the files - -2001-05-01 Will Estes - - * COPYING: add 2001 copyright notice - -2001-05-01 Will Estes - - * autogen.sh: initial attempt at a bootstrap script for developers - -2001-05-01 Will Estes - - * flex.texi: texinfo manual, old contributed version - -2000-08-21 Vern Paxson - - * flex.1: fixed some bugs in examples of [[:...:]] ccls - -2000-08-21 Vern Paxson - - * version.h: version shipped to Dick King - -2000-08-21 Vern Paxson - - * flex.skl: explicit include of iostream.h - -2000-08-21 Vern Paxson - - * scan.l: if a newline is seen in , assume it - terminates the string. - -2000-08-21 Vern Paxson - - * flexdef.h, sym.c: moved symbol table definitions from flexdef.h - into sym.c - -2000-08-21 Vern Paxson - - * dfa.c: fixed underallocation for accset - -1997-06-27 Vern Paxson - - * COPYING: revised for rms - -1997-06-23 Vern Paxson - - * flex.skl: fixed memory leak - -1997-06-23 Vern Paxson - - * flex.1: input() doesn't destroy yytext - -1997-06-23 Vern Paxson - - * FlexLexer.h: wrapped with extern "C++" - -1996-12-13 Vern Paxson - - * flex.skl: use delete [] for yy_state_buf - -1996-10-29 Vern Paxson - - * flex.skl: fixed %option noinput - -1996-10-29 Vern Paxson - - * flex.skl: free(char*) fix ... Sigh ... - -1996-10-11 Vern Paxson - - * gen.c: bug fix for yymore()/yylineno interaction - -1996-10-11 Vern Paxson - - * gen.c: fixed memory leak - -1996-09-10 Vern Paxson - - * NEWS: release 2.5.4 - -1996-09-10 Vern Paxson - - * Makefile.in: more stuff for distclean - -1996-09-10 Vern Paxson - - * flex.skl: "str" -> "yy_str" - -1996-09-10 Vern Paxson - - * version.h: 2.5.4 - -1996-07-02 Vern Paxson - - * flex.skl: (attempted) fix for input() crossing a file boundary - -1996-05-29 Vern Paxson - - * NEWS: don't do Acorn diffs - -1996-05-29 Vern Paxson - - * NEWS: some minor additions for 2.5.3 - -1996-05-29 Vern Paxson - - * NEWS, version.h: 2.5.3 - -1996-05-25 Vern Paxson - - * flex.skl: initialize yy_more_offset etc. for yyFlexLexer class - -1996-05-25 Vern Paxson - - * flex.skl: niggling cosmetic tweak - -1996-05-25 Vern Paxson - - * flex.skl: bug fixes for yymore (especially with %array) - -1996-05-25 Vern Paxson - - * gen.c: yymore + %array tweaks - -1996-05-25 Vern Paxson - - * FlexLexer.h: added yy_{,prev_}more_offset - -1996-05-25 Vern Paxson - - * main.c: removed decl of unused library function - -1996-05-25 Vern Paxson - - * flex.skl: snapshot of cscope yymore fixes, prior to switching - yymore-on-%array approach - -1995-12-18 Vern Paxson - - * gen.c: don't stack states on NUL-transitions that are jams - -1995-09-27 Vern Paxson - - * libmain.c: fixed re Esmond Pitt's ancient suggestion - -1995-04-28 Vern Paxson - - * misc.c: ANSI C / Solaris tweak - -1995-04-24 Vern Paxson - - * flex.1: credits - -1995-04-24 Vern Paxson - - * NEWS: multiple FlexLexer.h includes - -1995-04-24 Vern Paxson - - * FlexLexer.h: fix multiple inclusions - -1995-04-24 Vern Paxson - - * scan.l: lint tweak - -1995-04-24 Vern Paxson - - * flex.1: typo fixed - -1995-04-24 Vern Paxson - - * flex.1: credits update - -1995-04-24 Vern Paxson - - * flex.skl: (char*) cast for realloc - -1995-04-24 Vern Paxson - - * NEWS: (char*) tweak - -1995-04-21 Vern Paxson - - * NEWS: VMS update for 2.5.2 - -1995-04-21 Vern Paxson - - * Makefile.in: clarify when 8-bit scanners are created by default, - vs. 7-bit - -1995-04-21 Vern Paxson - - * parse.y: reworked alloca() chud, from Francois - -1995-04-20 Vern Paxson - - * NEWS, version.h: 2.5.2 - -1995-04-20 Vern Paxson - - * flex.1: 2.5.2 update - -1995-04-20 Vern Paxson - - * dfa.c, main.c: const -> yyconst - -1995-04-20 Vern Paxson - - * Makefile.in: fixed some old libfl.a references - -1995-04-20 Vern Paxson - - * Makefile.in: some (but not all) of Francois' tweaks - -1995-04-20 Vern Paxson - - * configure.in: tweaks from Francois - -1995-04-20 Vern Paxson - - * flex.skl: yy_delete_buffer allows nil buffer pointer - -1995-04-20 Vern Paxson - - * main.c: do_stdinit now defaults to false - -1995-04-20 Vern Paxson - - * FlexLexer.h: remove first default for yylex(new_in, new_out) - -1995-04-20 Vern Paxson - - * flex.skl: rearrange some definitions; fix YY_NO_UNPUT - -1995-04-20 Vern Paxson - - * parse.y: more alloca() bullshit - -1995-04-20 Vern Paxson - - * misc.c: octal escape sequence must have just digits 0-7 - -1995-04-20 Vern Paxson - - * scan.l: '-' means stdin octal escape sequence must just be digits - 0-7 - -1995-04-20 Vern Paxson - - * main.c: -- terminates options - -1995-04-20 Vern Paxson - - * flexdef.h: added dataflush() prototype - -1995-04-20 Vern Paxson - - * misc.c: move dataflush, otoi prototypes into flexdef.h - -1995-04-20 Vern Paxson - - * flex.skl, gen.c: const -> yyconst - -1995-04-20 Vern Paxson - - * gen.c: fixed bug in needing yy_cp for -Cf w/ backing up - -1995-03-28 Vern Paxson - - * README, flex.1: Stan Adermann credit - -1995-03-27 Vern Paxson - - * README: beta-tester update - -1995-03-27 Vern Paxson - - * NEWS, version.h: 2.5.1 - -1995-03-27 Vern Paxson - - * flex.1: update date for 2.5.1 release, some feedbacker credits - -1995-03-27 Vern Paxson - - * gen.c: fixed lint problem with declaring yy_cp unnecessarily - -1995-03-27 Vern Paxson - - * dfa.c: {}'s around full-table initializations - -1995-03-21 Vern Paxson - - * README: for version 2.5 - -1995-03-21 Vern Paxson - - * flex.1: added note regarding yylineno should be maintained on a - per-buffer basis - -1995-03-21 Vern Paxson - - * NEWS: new C++ member functions - -1995-03-21 Vern Paxson - - * NEWS, flex.1: 2.5.0.8 update - -1995-03-21 Vern Paxson - - * main.c: rename yylineno if -P - -1995-03-20 Vern Paxson - - * flexdef.h: do_yylineno MARKER_DIFFERENCE depends on MAXIMUM_MNS - -1995-03-20 Vern Paxson - - * Makefile.in: removed redundant skel.c from DISTFILES - -1995-03-20 Vern Paxson - - * FlexLexer.h: debug(), setdebug(), lineno() - -1995-03-20 Vern Paxson - - * flex.skl: %option yylineno support - -1995-03-20 Vern Paxson - - * gen.c: read up to newline for interactive reads, rather than one - char - -1995-03-20 Vern Paxson - - * main.c, scan.l: added %option yylineno - -1995-03-18 Vern Paxson - - * gen.c: added do_yylineno - -1995-03-06 Vern Paxson - - * NEWS, flex.1: 2.5.0.7 - -1995-03-05 Vern Paxson - - * Makefile.in: realclean -> maintainer-clean - -1995-03-05 Vern Paxson - - * flex.skl: Added yy_flush_buffer - -1995-03-05 Vern Paxson - - * FlexLexer.h: added yy_flush_buffer - -1995-03-05 Vern Paxson - - * main.c: prefix support for yy_flush_buffer - -1995-03-05 Vern Paxson - - * parse.y: added %option yyclass - -1995-03-05 Vern Paxson - - * flexdef.h, main.c, scan.l: added yyclass - -1995-03-05 Vern Paxson - - * FlexLexer.h: Added switch_streams - -1995-03-05 Vern Paxson - - * flex.skl: added switch_streams - -1995-03-05 Vern Paxson - - * main.c: don't rename yy_flex_debug for C++ - -1995-03-05 Vern Paxson - - * gen.c: yy_flex_debug extern only if not C++ - -1995-03-05 Vern Paxson - - * FlexLexer.h: added yy_flex_debug member variable - -1995-03-05 Vern Paxson - - * flex.skl: yyFlexLexer initialization of yy_flex_debug - -1995-03-04 Vern Paxson - - * flexdef.h, main.c: VMS POSIX stuff - -1995-03-04 Vern Paxson - - * flex.skl: moved position of yy_init = 0 - -1995-03-04 Vern Paxson - - * flex.skl: added YY_EXIT_FAILURE - -1995-03-04 Vern Paxson - - * main.c: removed VMS-specific exit - -1995-03-04 Vern Paxson - - * dfa.c, flexdef.h, gen.c, main.c, misc.c, nfa.c, scan.l, sym.c, - yylex.c: internationalization aids - -1995-03-04 Vern Paxson - - * main.c: do yy_flex_debug prefix for both C++ and C - -1995-02-06 Vern Paxson - - * main.c: fixed program_name tweak again - -1995-01-11 Vern Paxson - - * main.c: oops, fixed program_name tweak - -1995-01-11 Vern Paxson - - * main.c: program_name is "flex" if argv[0] nil - -1995-01-10 Vern Paxson - - * NEWS: 2.5.0.5 - -1995-01-10 Vern Paxson - - * flex.1: Documented YY_NUM_RULES - -1995-01-10 Vern Paxson - - * Makefile.in: added formatted man page to MISC - -1995-01-10 Vern Paxson - - * main.c: help messages to stdout - -1995-01-09 Vern Paxson - - * gen.c: Added YY_NUM_RULES - -1995-01-09 Vern Paxson - - * flex.skl: better fix for #pragma problem - -1995-01-09 Vern Paxson - - * flexdef.h: better fix for #pragma portability problem - -1995-01-09 Vern Paxson - - * misc.c: "# line" -> #line - -1995-01-09 Vern Paxson - - * flex.skl, flexdef.h: comment out Turbo C #pragma's - -1995-01-09 Vern Paxson - - * scan.l: reset linenum on new file - -1995-01-09 Vern Paxson - - * flex.skl: isatty() extern - -1995-01-09 Vern Paxson - - * NEWS, flex.1: 2.5.0.4 - -1995-01-09 Vern Paxson - - * main.c: long options, VMS tweaks - -1995-01-09 Vern Paxson - - * Makefile.in: Added parse.c, parse.h for dist MISC directory - -1995-01-09 Vern Paxson - - * flexdef.h: some "const" cleansing - -1995-01-09 Vern Paxson - - * mkskel.sh: skel[] is now const - -1995-01-09 Vern Paxson - - * misc.c: some const cleansing - -1995-01-09 Vern Paxson - - * scan.l: #line in section 1 - -1995-01-05 Vern Paxson - - * sym.c: preen - -1994-12-29 Vern Paxson - - * configure.in: config.h from conf.in - -1994-12-29 Vern Paxson - - * flexdef.h: for VMS, delete -> remove - -1994-12-29 Vern Paxson - - * Makefile.in: config.h.in -> conf.in rm config.h on distclean - -1994-12-29 Vern Paxson - - * main.c: stdinit tweaks - -1994-12-29 Vern Paxson - - * scan.l: added nostdinit - -1994-12-28 Vern Paxson - - * NEWS: added MS-DOS note for 2.5.0.2 - -1994-12-28 Vern Paxson - - * flex.1: typos, tweaks - -1994-12-28 Vern Paxson - - * Makefile.in: removed flexdoc - -1994-12-28 Vern Paxson - - * flex.1: flexdoc/flex merge - -1994-12-28 Vern Paxson - - * flex.1: typos - -1994-12-28 Vern Paxson - - * NEWS: typo - -1994-12-28 Vern Paxson - - * flex.1: 2.5 update - -1994-12-28 Vern Paxson - - * NEWS: 2.5.0.2 - -1994-12-28 Vern Paxson - - * scan.l: fixed sense of %option main implying %option noyywrap - -1994-12-28 Vern Paxson - - * flex.skl: YY_FLEX_{MAJOR,MINOR}_VERSION fixed bug in unput - trashing yytext even with %array - -1994-12-17 Vern Paxson - - * flex.1: prior to 2.5 update - -1994-12-17 Vern Paxson - - * main.c: C++/-P fixes - -1994-12-17 Vern Paxson - - * FlexLexer.h: -P fixes constructor, destructor moved to flex.skl - -1994-12-17 Vern Paxson - - * flex.skl: YY_SKIP_YYWRAP yyFlexLexer constructor, destructor - -1994-12-15 Vern Paxson - - * gen.c: formatting - -1994-12-15 Vern Paxson - - * gen.c: fixed bug in adjusting yytext before backing up - -1994-12-10 Vern Paxson - - * scan.l: switched scanner itself over to [:xxx:] - -1994-12-10 Vern Paxson - - * flex.skl: added YY_FLEX_VERSION - -1994-12-10 Vern Paxson - - * scan.l: Fixed CCL-match pattern for [:whatever:] - -1994-12-10 Vern Paxson - - * parse.y: treat [:upper:] as [:lower:] if -i - -1994-12-06 Vern Paxson - - * NEWS: 2.5.0.1 - -1994-12-06 Vern Paxson - - * flex.skl, gen.c: input() maintains BOL - -1994-12-06 Vern Paxson - - * flex.skl: check size of buffer in yy_scan_buffer - -1994-12-06 Vern Paxson - - * flex.skl: added %option main, fixed missing %* - -1994-12-06 Vern Paxson - - * parse.y: added ccl exprs - -1994-12-06 Vern Paxson - - * scan.l: added ccl exprs, %option main - -1994-12-06 Vern Paxson - - * yylex.c: added %options, ccl exprs - -1994-12-05 Vern Paxson - - * misc.c: undid previous change - -1994-12-04 Vern Paxson - - * Makefile.in: Makefile.in from srcdir - -1994-12-04 Vern Paxson - - * Makefile.in: added skel.c to DISTFILES - -1994-12-04 Vern Paxson - - * flex.skl: added YYSTATE alias - -1994-12-04 Vern Paxson - - * scan.l: NL is now \r?\n - -1994-12-04 Vern Paxson - - * gen.c: use cerr for C++ diagnostics - -1994-12-03 Vern Paxson - - * flex.skl: undid YY_UNIX_NEWLINE - -1994-12-03 Vern Paxson - - * flexdef.h: STDC_HEADERS to check for stdlib - -1994-12-03 Vern Paxson - - * configure.in: AC_STDC_HEADERS -> AC_HEADER_STDC - -1994-12-03 Vern Paxson - - * misc.c: \n -> '\012' - -1994-12-03 Vern Paxson - - * flex.skl: Added YY_UNIX_NEWLINE - -1994-12-03 Vern Paxson - - * flex.skl: BOL changes - -1994-12-03 Vern Paxson - - * dfa.c: fixed bug with caseins but not ecs - -1994-12-03 Vern Paxson - - * gen.c: BOL changes some casts for Turbo C - -1994-12-03 Vern Paxson - - * main.c: messages identify filenames - -1994-12-03 Vern Paxson - - * misc.c: Increase slowly if realloc double overflows - -1994-12-03 Vern Paxson - - * nfa.c: YY_RULE_SETUP - -1994-12-03 Vern Paxson - - * scan.l: Added yy_XX_state %option's Added yy_set_bol - -1994-11-29 Vern Paxson - - * Makefile.in: don't remove ~ files - -1994-11-24 Vern Paxson - - * Makefile.in: get CFLAGS from autoconf - -1994-11-24 Vern Paxson - - * dfa.c, flex.skl, flexdef.h, gen.c, misc.c, parse.y, scan.l, sym.c: - Brian Madsen's tweaks for Borland - -1994-11-24 Vern Paxson - - * version.h: 2.5.0 - -1994-11-24 Vern Paxson - - * flexdef.h: Added do_stdinit - -1994-11-24 Vern Paxson - - * FlexLexer.h: Added yy_delete_buffer() in destructor - -1994-11-24 Vern Paxson - - * flex.skl: Added yy_set_interactive, YY_ALWAYS_INTERACTIVE, - YY_NEVER_INTERACTIVE, YY_NO_INPUT, YY_NO_UNPUT, YY_NO_*_STATE - -1994-11-24 Vern Paxson - - * main.c: Added do_stdinit, Think C hacks - -1994-11-24 Vern Paxson - - * scan.l: Added %options for input, always-interactive, - never-interactive, yy_scan_{buffer,bytes,string} - -1994-11-05 Vern Paxson - - * flex.skl: size_t #ifdef's for not compiling some statics - -1994-11-05 Vern Paxson - - * Makefile.in: $(FLEX) config.h - -1994-11-05 Vern Paxson - - * configure.in: config.h, size_t, malloc.h, sys/types.h - -1994-11-05 Vern Paxson - - * flexdef.h: config.h, size_t - -1994-11-05 Vern Paxson - - * main.c: yywrap option, no stdin/out init for VMS, mundane tweaks - -1994-11-05 Vern Paxson - - * parse.y: alloca, lint tweaks - -1994-11-05 Vern Paxson - - * scan.l: %option yywrap size_t tweaks - -1994-11-05 Vern Paxson - - * tblcmp.c: size_t tweaks - -1994-11-05 Vern Paxson - - * misc.c: size_t, STDC tweaks - -1994-11-05 Vern Paxson - - * flex.skl: Added yy_scan_{buffer,bytes,string}, plus tweaks - -1994-10-12 Vern Paxson - - * flex.skl: made stack code conditional on "stack" option - -1994-10-12 Vern Paxson - - * scan.l: added use of "stack" %option - -1994-08-03 Vern Paxson - - * gen.c: Fixed fencepost in call to yy_flex_strncpy - -1994-07-25 Vern Paxson - - * flex.skl: yy_eof_status -> yy_buffer_status - -1994-07-25 Vern Paxson - - * flex.skl: yy_flex_strcpy -> yy_flex_strncpy minor prototype tweak - -1994-07-25 Vern Paxson - - * gen.c: Bug fix for matching NUL's at end of token when - interactive. yy_flex_strcpy -> yy_flex_strncpy - -1994-07-25 Vern Paxson - - * nfa.c: No YY_USER_ACTION if continued action - -1994-03-16 Vern Paxson - - * flex.skl: Added fix for 8-bit chars returned by input() - -1994-03-16 Vern Paxson - - * flex.skl: Move definition of yy_flex_strcpy to come after #define - of yytext_ptr - -1994-01-08 Vern Paxson - - * mkskel.sh: flex.skel -> flex.skl - -1994-01-08 Vern Paxson - - * mkskel.sh: Initial revision - -1993-12-29 Vern Paxson - - * Makefile.in: Fixed scan.c target so "make" detects flex failure - -1993-12-27 Vern Paxson - - * scan.l: Added %option's - -1993-12-27 Vern Paxson - - * Makefile.in: Nuked FLEX_FLAGS that are now done using %option - -1993-12-27 Vern Paxson - - * parse.y, scan.l: %option - -1993-12-27 Vern Paxson - - * main.c: Reworked for %option - -1993-12-27 Vern Paxson - - * flexdef.h: Added "unspecified", globals for %option - -1993-12-27 Vern Paxson - - * sym.c: start condition #define's go to action file - -1993-12-27 Vern Paxson - - * misc.c: Added action_define() - -1993-12-27 Vern Paxson - - * scan.l: Minor consolidation using scon scopes etc - -1993-12-27 Vern Paxson - - * scan.l: Modified to use scon scopes - -1993-12-27 Vern Paxson - - * scan.l: indented rules - -1993-12-26 Vern Paxson - - * parse.y: Added scon_stk stuff, format_warn - -1993-12-26 Vern Paxson - - * flexdef.h: Added format_warn - -1993-12-26 Vern Paxson - - * parse.y: Working checkpoint prior to adding { stuff - -1993-12-26 Vern Paxson - - * flexdef.h, main.c: Added in_rule, deleted actvsc - -1993-12-26 Vern Paxson - - * misc.c: Added doubling of '\'s in filenames - -1993-12-26 Vern Paxson - - * scan.l: Added in_rule, doing_rule_action - -1993-12-26 Vern Paxson - - * sym.c: Removed actvsc - -1993-12-23 Vern Paxson - - * flex.1: -ooutput #line directives credits - -1993-12-23 Vern Paxson - - * flex.skl: Fixsed sense of test for %array - -1993-12-23 Vern Paxson - - * NEWS: 2.5.0 snapshot for Craig - -1993-12-23 Vern Paxson - - * parse.y: Added beginnings of { ... } - -1993-12-23 Vern Paxson - - * scan.l: Simplified scanning {}'s - -1993-12-20 Vern Paxson - - * flexdef.h: Added - -1993-12-17 Vern Paxson - - * flex.skl: prototypes for alloc/string routines - -1993-12-17 Vern Paxson - - * flex.skl: alloc, string routines internal - -1993-12-17 Vern Paxson - - * Makefile.in: Nuked lib{string,alloc}.c, added dependency of - yylex.o on parse.h - -1993-12-17 Vern Paxson - - * configure.in: Check for string.h - -1993-12-17 Vern Paxson - - * flexdef.h: Use autoconf for string/strings.h yy_flex_XXX -> - flex_XXX - -1993-12-17 Vern Paxson - - * scan.l: Added flex_XXX -> yy_flex_XXX wrappers - -1993-12-17 Vern Paxson - - * dfa.c, misc.c, sym.c: yy_flex_XXX -> flex_XXX - -1993-12-17 Vern Paxson - - * yylex.c: No more WHITESPACE token - -1993-12-16 Vern Paxson - - * FlexLexer.h, flex.skl: Added yy_top_state() - -1993-12-16 Vern Paxson - - * scan.l: simplified comment-scanning using push/pop states - -1993-12-16 Vern Paxson - - * parse.y: removed crufty WHITESPACE token, some uses of '\n' token - -1993-12-15 Vern Paxson - - * FlexLexer.h: start stack, extern "C++" moved - -1993-12-15 Vern Paxson - - * dfa.c: Bug fix for -CF - -1993-12-15 Vern Paxson - - * flexdef.h, misc.c: alloc routines take unsigned - -1993-12-15 Vern Paxson - - * flex.skl: start-state stacks, alloc routines take unsigned - -1993-12-15 Vern Paxson - - * flexdef.h, misc.c: bracket -CF table elements - -1993-12-13 Vern Paxson - - * misc.c: Do #bytes computation in {re,}allocate_array() only once - -1993-12-11 Vern Paxson - - * flex.skl, flexdef.h, gen.c, main.c, misc.c, scan.l, sym.c: - yy_str*() -> str*() - -1993-12-11 Vern Paxson - - * Makefile.in, dfa.c, flexdef.h, gen.c, main.c, misc.c, nfa.c, - parse.y, scan.l, sym.c: -o option - -1993-12-11 Vern Paxson - - * gen.c: lint tweak - -1993-12-11 Vern Paxson - - * NEWS: Expanded on extern "C++" news item - -1993-12-11 Vern Paxson - - * NEWS: 2.4.5 - -1993-12-11 Vern Paxson - - * flex.skl: Added yy_fill_buffer - -1993-12-11 Vern Paxson - - * gen.c: is_interactive -> yy_is_interactive - -1993-12-11 Vern Paxson - - * flex.1: Updated credits - -1993-12-11 Vern Paxson - - * Makefile.in: Fixed typo in "uninstall" target - -1993-12-11 Vern Paxson - - * gen.c: Updated comment regarding 0-based vs. 1-based arrays for - -CF. - -1993-12-11 Vern Paxson - - * dfa.c: Initialize dfaacc[0] for -CF representation Fixed minor - memory leak - -1993-12-11 Vern Paxson - - * main.c: #include "FlexLexer.h" -> - -1993-12-11 Vern Paxson - - * FlexLexer.h: Added extern "C++" wrapper - -1993-12-09 Vern Paxson - - * main.c: Detect REJECT etc. before generating YY_USES_REJECT! - -1993-12-09 Vern Paxson - - * gen.c: Fixed bug in interactive reads where char is unsigned - -1993-12-09 Vern Paxson - - * parse.y: Fixed bug in treating '$' as variable trailing context - -1993-12-09 Vern Paxson - - * version.h: 2.4.5 - -1993-12-07 Vern Paxson - - * README: pretester update - -1993-12-07 Vern Paxson - - * NEWS: 2.4.4 - -1993-12-07 Vern Paxson - - * flex.1: LexError(), C++ experiment warning, credits - -1993-12-07 Vern Paxson - - * scan.l: Fixed 8-bit bug - -1993-12-07 Vern Paxson - - * flex.skl, gen.c: Fixed nasty 8-bit bugs - -1993-12-07 Vern Paxson - - * dfa.c, ecs.c, flexdef.h, gen.c, main.c, nfa.c, tblcmp.c: - {min,max,abs} -> {MIN,MAX,ABS} - -1993-12-07 Vern Paxson - - * FlexLexer.h, flex.skl: Support for yyFlexLexer::LexerError - -1993-12-06 Vern Paxson - - * version.h: 2.4.4 - -1993-12-05 Vern Paxson - - * flex.1: credits update - -1993-12-05 Vern Paxson - - * Makefile.in: very minor "install" tweaks - -1993-12-05 Vern Paxson - - * flex.skl, nfa.c: YY_USER_ACTION generated now for each case in - action switch - -1993-12-04 Vern Paxson - - * flex.skl: Fixed bug in pointing yyin at a new file and resuming - scanning - -1993-12-03 Vern Paxson - - * NEWS: Added note regarding g++ 2.5.X - -1993-12-03 Vern Paxson - - * flex.1: updated credits - -1993-12-03 Vern Paxson - - * NEWS: ranlib addition for 2.4.3 - -1993-12-03 Vern Paxson - - * Makefile.in: Minor tweak to last change - -1993-12-03 Vern Paxson - - * Makefile.in: run ranlib on libfl.a - -1993-12-03 Vern Paxson - - * NEWS: Hopefully last update prior to 2.4.3 - -1993-12-03 Vern Paxson - - * flexdef.h, gen.c, misc.c, sym.c: lint tweaks - -1993-12-03 Vern Paxson - - * Makefile.in: Added exec_prefix - -1993-12-03 Vern Paxson - - * flex.1: credit update - -1993-12-03 Vern Paxson - - * flex.skl: lint tweak - -1993-12-03 Vern Paxson - - * NEWS: FlexLexer.h fixed for separate inclusion - -1993-12-03 Vern Paxson - - * FlexLexer.h, flex.skl, main.c: mods so FlexLexer.h can be included - separately - -1993-12-03 Vern Paxson - - * flex.1: -F incompatible with -+ - -1993-12-02 Vern Paxson - - * NEWS: Elaborated comments for 2.4.3 - -1993-12-02 Vern Paxson - - * NEWS: 2.4.3 - -1993-12-02 Vern Paxson - - * flex.1: Updated message regarding missing libfl.a routines Added - thanks to Noah Friedman - -1993-12-02 Vern Paxson - - * Makefile.in: Added libstring.c Modified "lint" target to use - -Dconst= Added a.out, lex.yy.cc to sundry clean targets - -1993-12-02 Vern Paxson - - * flex.skl, flexdef.h, gen.c, main.c, misc.c, scan.l, sym.c: Use - yy_strXXX() routines instead of - -1993-12-01 Vern Paxson - - * version.h: 2.4.3 - -1993-12-01 Vern Paxson - - * flexdef.h, misc.c: yy_flex_xmalloc() moved to misc.c - -1993-12-01 Vern Paxson - - * flex.skl: Fixed bug in yy_fatal_error() - -1993-12-01 Vern Paxson - - * Makefile.in: ... and remove plain tar file after compression - -1993-12-01 Vern Paxson - - * NEWS: 2.4.2 - -1993-12-01 Vern Paxson - - * Makefile.in: Produce both compress'd and gzip'd distribution tar - files - -1993-12-01 Vern Paxson - - * version.h: Release 2.4.2 - -1993-11-30 Vern Paxson - - * NEWS: -a -> -Ca - -1993-11-30 Vern Paxson - - * README: described configuration files in manifest - -1993-11-30 Vern Paxson - - * Makefile.in: Added intermediate step of copying MISC/alloca.c -> - alloca.c Included CPPFLAGS when compiling alloca.c - -1993-11-30 Vern Paxson - - * README: Credit to 2.4 pre-testers. - -1993-11-30 Vern Paxson - - * gen.c: Fixed nasty bug in short/long decl decision - -1993-11-30 Vern Paxson - - * flexdef.h: Lowered MAX_SHORT out of increased general paranoia. - Added yy_flex_xmalloc() proto - -1993-11-30 Vern Paxson - - * main.c: Fixed very minor typo in -v output - -1993-11-30 Vern Paxson - - * misc.c: Removed vestigal cast to (char) in isupper() call - -1993-11-30 Vern Paxson - - * misc.c: Added casts to unsigned Char for isascii() calls - -1993-11-30 Vern Paxson - - * parse.y: Added #ifdef chud for alloca() - -1993-11-30 Vern Paxson - - * Makefile.in: Added alloca - -1993-11-30 Vern Paxson - - * configure.in: Add AC_ALLOCA if using bison - -1993-11-29 Vern Paxson - - * Makefile.in: Added intermediate file going scan.l -> scan.c - -1993-11-29 Vern Paxson - - * Makefile.in: Removed parse.{c,h} from distribution files, since - they may not be all that portable. - -1993-11-29 Vern Paxson - - * flex.skl: Fixed %array YYLMAX headaches, added error message if - buffer needs growing but REJECT used - -1993-11-29 Vern Paxson - - * gen.c, main.c: Fixed YYLMAX headaches - -1993-11-29 Vern Paxson - - * flex.1: Documented that buffer can't grow if REJECT used - -1993-11-29 Vern Paxson - - * Makefile.in: Added parse.{c,h} to dist files - -1993-11-29 Vern Paxson - - * flex.skl, flexdef.h, gen.c, main.c, misc.c, scan.l: Fixed to - buffer section 1 definitions - -1993-11-29 Vern Paxson - - * sym.c: Fixed ANSI-C glitch with '%' operator - -1993-11-29 Vern Paxson - - * scan.l: Fixed mis-definition of ndlookup() - -1993-11-29 Vern Paxson - - * NEWS: 2.4 -> 2.4.1 - -1993-11-29 Vern Paxson - - * Makefile.in: Added install.sh, mkinstalldirs to distribution files - -1993-11-29 Vern Paxson - - * flex.1: Added Nathan Zelle, "promoted" Francois - -1993-11-29 Vern Paxson - - * Makefile.in: only "realclean" removes flex dist depends on flex - -1993-11-29 Vern Paxson - - * flexdef.h, misc.c: myctoi takes char[] instead of Char[] - -1993-11-28 Vern Paxson - - * flexdef.h: -a -> -Ca all_lower, all_upper -> work on char* - -1993-11-28 Vern Paxson - - * Makefile.in: Added -Ca to bigcheck - -1993-11-28 Vern Paxson - - * main.c: -a -> -Ca; fixed help output - -1993-11-28 Vern Paxson - - * dfa.c, flex.1: -a -> -Ca - -1993-11-28 Vern Paxson - - * misc.c: all_lower, all_upper work on char* - -1993-11-28 Vern Paxson - - * scan.l: Fixed some casts now that yytext is always char* and never - unsigned char* - -1993-11-28 Vern Paxson - - * Makefile.in: Francois' tweaks - -1993-11-28 Vern Paxson - - * configure.in: AC_LN_S, AC_STDC_HEADERS (but not AC_ALLOCA) - -1993-11-27 Vern Paxson - - * NEWS: fixed typo - -1993-11-27 Vern Paxson - - * Makefile.in: Don't remove dist directory - -1993-11-27 Vern Paxson - - * Makefile.in: Include liballoc.c in lint targets - -1993-11-27 Vern Paxson - - * misc.c: lint tweak - -1993-11-27 Vern Paxson - - * Makefile.in: Added -l compression to bigcheck - -1993-11-27 Vern Paxson - - * Makefile.in: permission tweaking for "dist" - -1993-11-27 Vern Paxson - - * Makefile.in: more "dist" tweaks - -1993-11-27 Vern Paxson - - * Makefile.in: Changed "make dist" to use version.h, include scan.c - in initial dir copy - -1993-11-27 Vern Paxson - - * version.h: 2.4.1 - -1993-11-27 Vern Paxson - - * README: Revised as per Francois Pinard - -1993-11-27 Vern Paxson - - * COPYING: flex.skel -> flex.skl - -1993-11-27 Vern Paxson - - * NEWS: Updated date of 2.4 release - -1993-11-27 Vern Paxson - - * Makefile.in: Removed manual & nroff output from distribution - -1993-11-27 Vern Paxson - - * NEWS: 2.4.1 release - -1993-11-27 Vern Paxson - - * configure.in: Initial revision - -1993-11-27 Vern Paxson - - * Makefile.in: Merge w/ 2.4.1 changes added "dist2" target - -1993-11-26 Vern Paxson - - * Makefile.in: Initial revision - -1993-11-26 Vern Paxson - - * flexdef.h: Removed #ifndef FILE protection from include of stdio - -1993-11-26 Vern Paxson - - * flex.1: Added Francois Pinard to distribution headache helpers - -1993-11-26 Vern Paxson - - * flex.skl: Modified C++ scanners to get input a character at a time - for interactive scanners. - -1993-11-26 Vern Paxson - - * main.c: Added YY_INTERACTIVE. - -1993-11-26 Vern Paxson - - * scan.l: Put definitions inside ()'s so we can test -l option for - "make bigcheck" - -1993-11-26 Vern Paxson - - * flex.1: Documented YY_INTERACTIVE. - -1993-11-26 Vern Paxson - - * flex.1, flex.skl, flexdef.h, gen.c, main.c, parse.y, scan.l: -l - lex compatibility flag - -1993-11-20 Vern Paxson - - * flex.skl: Support for read()/fread() section 1 definitions precede - default macro definitions - -1993-11-20 Vern Paxson - - * flexdef.h: Added use_read global - -1993-11-20 Vern Paxson - - * gen.c: Cleaner definition for yymore() Fixed string broken across - multiple lines - -1993-11-20 Vern Paxson - - * main.c: Added -Cr - -1993-11-20 Vern Paxson - - * misc.c: K&R declaration for check_char() - -1993-11-20 Vern Paxson - - * flex.1: Documented -Cr - -1993-11-20 Vern Paxson - - * flex.1: No need to #undef before redefining prior to -Cr - documentation - -1993-11-10 Vern Paxson - - * README: Heavily massaged for 2.4 - -1993-11-10 Vern Paxson - - * flex.1: Added Landon Noll to thanks. - -1993-11-10 Vern Paxson - - * NEWS: 2.4 release - -1993-11-10 Vern Paxson - - * flex.1: 2.4 documentation - -1993-11-10 Vern Paxson - - * main.c: Added global to remember -P prefix so it can be written in - -v summary. Alphabetized prefix generation, added yywrap - -1993-11-09 Vern Paxson - - * version.h: updated date for 2.4.0 :-( - -1993-10-10 Vern Paxson - - * FlexLexer.h: Whitespace tweaking - -1993-10-10 Vern Paxson - - * main.c: Use DEFAULT_CSIZE only if not using equivalence classes. - -1993-10-10 Vern Paxson - - * flex.1: Checkpoint prior to final 2.4 update - -1993-10-04 Vern Paxson - - * NEWS: Raw 2.4 changes - -1993-10-04 Vern Paxson - - * flex.skl: osfcn.h -> unistd.h - -1993-10-04 Vern Paxson - - * flex.skl: Added "static" to definition of yy_fatal_error as well - as fwd decl. - -1993-10-04 Vern Paxson - - * flex.skl: Added yy_fatal_error function. - -1993-10-03 Vern Paxson - - * flex.skl, gen.c: Got rid of (char *) casts of yytext, no longer - needed. - -1993-10-03 Vern Paxson - - * FlexLexer.h: YY_CHAR -> char added YYText(), YYLeng() - -1993-10-03 Vern Paxson - - * flex.skl, gen.c: Minimized use of YY_CHAR - -1993-10-03 Vern Paxson - - * main.c: Added "flex++" feature Minimized use of YY_CHAR - -1993-10-02 Vern Paxson - - * main.c: Clarified help message for -S - -1993-10-02 Vern Paxson - - * libyywrap.c, version.h: Initial revision - -1993-10-02 Vern Paxson - - * main.c: If -+ used, output to lex.yy.cc - -1993-10-02 Vern Paxson - - * FlexLexer.h, flex.skl: Switched from FILE*'s to stream's - -1993-10-02 Vern Paxson - - * flexdef.h: Added expand_nxt_chk() extern. - -1993-10-02 Vern Paxson - - * flex.skl: Added dynamic buffer growing. Added yyless() for - section 3. - -1993-10-02 Vern Paxson - - * dfa.c, flexdef.h, gen.c, main.c: Added -a option for long-align. - -1993-10-02 Vern Paxson - - * scan.l: formfeed no longer considered whitespace - -1993-09-21 Vern Paxson - - * flexdef.h: Nuked FILENAMESIZE - -1993-09-21 Vern Paxson - - * main.c: yyflexlexer.h -> FlexLexer.h minor portability tweak - -1993-09-21 Vern Paxson - - * gen.c: Added start condition to EOF trace output - -1993-09-21 Vern Paxson - - * flex.skl: Added YY_START changed yyFlexLexer to define yylex() - -1993-09-21 Vern Paxson - - * misc.c: Minor portability tweaks - -1993-09-21 Vern Paxson - - * FlexLexer.h: Split into two classes, one fully abstract. yylex() - no longer abstract in yyFlexLexer - -1993-09-21 Vern Paxson - - * scan.l: PC lint tweak - -1993-09-21 Vern Paxson - - * parse.y: YYSTYPE #define'd to int - -1993-09-21 Vern Paxson - - * nfa.c: minor lint tweak - -1993-09-16 Vern Paxson - - * FlexLexer.h: Initial revision - -1993-09-16 Vern Paxson - - * flexdef.h: Delete prototypes for Unix system calls. - -1993-09-16 Vern Paxson - - * ccl.c, dfa.c, ecs.c, gen.c, main.c, misc.c, nfa.c, parse.y, - scan.l, sym.c, tblcmp.c, yylex.c: nuked static RCS string - -1993-09-16 Vern Paxson - - * main.c: %array not allowed with C++ scanners - -1993-09-16 Vern Paxson - - * scan.l: Fixed bugs regarding %{%} code in section 2 prolog %array - not allowed with C++ scanners - -1993-08-25 Vern Paxson - - * flexdef.h: Added C_plus_plus flag. - -1993-08-25 Vern Paxson - - * flex.skl: First version of C/C++ skeleton - -1993-08-25 Vern Paxson - - * gen.c: yy_state_type declared earlier. Made a bunch of statics - only output if not -+ - -1993-08-25 Vern Paxson - - * main.c: Added -+ option, updated usage() output, rearranged some - generated code to come at the right point in the output for - yyflexlexer.h. - -1993-08-25 Vern Paxson - - * misc.c: Added %+/%-/%* to skelout() - -1993-08-25 Vern Paxson - - * scan.l: EOF in section 2 prolog leads to section 0, not section 3 - -1993-08-25 Vern Paxson - - * yylex.c: Dump promotion of EOF in section 2 to turn on section 3; - instead just treat it like a final EOF - -1993-08-25 Vern Paxson - - * dfa.c: yy_nxt table should be "const" - -1993-08-24 Vern Paxson - - * flexdef.h: Removed a lot of #ifdef chud "backtracking" -> "backing - up" - -1993-08-24 Vern Paxson - - * main.c: "backtracking" -> "backing up" got rid of time reports - -1993-08-24 Vern Paxson - - * gen.c: "backtracking" -> "backing up" some portability tweaks - fixed to only call flexscan() when done if known to be in section 3 - -1993-08-24 Vern Paxson - - * misc.c: isascii() moved to flexdef.h nuked flex_gettime() - -1993-08-24 Vern Paxson - - * scan.l: Fixed bug with empty section 2 - -1993-08-24 Vern Paxson - - * yylex.c: Chucked definition of isascii() - -1993-08-24 Vern Paxson - - * flex.skl: preserve yytext on input() bug fix when combining - yyless() with yymore() checkpoint prior to C++ option - -1993-08-24 Vern Paxson - - * dfa.c: "backtracking" -> "backing up" - -1993-07-09 Vern Paxson - - * flex.skl: Fixed to not generate extra EOF's after reading one. - -1993-07-05 Vern Paxson - - * main.c: Spit out definition of YY_CHAR early - -1993-07-05 Vern Paxson - - * flex.skl: Some rearranging to make sure things get declared in the - right order - -1993-07-05 Vern Paxson - - * tblcmp.c: Some comment fixes as per Wilhelms - -1993-07-05 Vern Paxson - - * scan.l: Nuked #undef of yywrap, now that it's a function - -1993-07-05 Vern Paxson - - * parse.y: Fixed bug with Z-a character classes as per Wilhelms - -1993-07-05 Vern Paxson - - * nfa.c: added check_char call in mkstate() to prevent bad xtion - chars - -1993-07-05 Vern Paxson - - * gen.c: Fixed some reallocation bugs, etc. as per Wilhelms - -1993-07-05 Vern Paxson - - * flexdef.h: Added check_char(), readable_form() - -1993-07-05 Vern Paxson - - * flex.skl: Added #ifndef's around #define's to let user override - Moved a bunch of definitions prior to section 1 - -1993-07-05 Vern Paxson - - * dfa.c: Wilhems bug fixes. - -1993-07-05 Vern Paxson - - * ccl.c, misc.c: Added check_char() - -1993-06-12 Vern Paxson - - * flexdef.h: Changed to use yy_flex_alloc() and friends - -1993-06-12 Vern Paxson - - * main.c: Added -P flag - -1993-06-12 Vern Paxson - - * scan.l: Fixed bug in lex % directives - -1993-06-12 Vern Paxson - - * misc.c: Modified to use yy_flex_alloc() and friends - -1993-06-12 Vern Paxson - - * sym.c: Modified to use yy_flex_alloc() - -1993-06-12 Vern Paxson - - * flex.skl: Modified to use yy_flex_alloc() and friends Moved some - globals earlier in the file to permit access in section 1 - -1993-06-12 Vern Paxson - - * dfa.c: Got rid of code needed for %t - -1993-04-14 Vern Paxson - - * ccl.c, dfa.c, ecs.c, flex.skl, flexdef.h, gen.c, libmain.c, - main.c, misc.c, nfa.c, parse.y, scan.l, sym.c, tblcmp.c, yylex.c: - Reformatting. - -1993-04-05 Vern Paxson - - * flex.1: Fixed bug in description of backtracking - -1993-04-05 Vern Paxson - - * NEWS: 2.3.8 - -1993-04-05 Vern Paxson - - * flex.skl, main.c: %array support - -1993-04-05 Vern Paxson - - * misc.c: Added non-STDC clause for '\a' - -1993-04-05 Vern Paxson - - * scan.l: Fixed subtle problems regarding '*'s in comments - %pointer/%array match entire lines - -1993-04-05 Vern Paxson - - * gen.c: Added %array support - -1993-02-06 Vern Paxson - - * README: Finally updated email addr - -1993-02-06 Vern Paxson - - * flex.1: Mostly .LP -> .PP - -1993-02-06 Vern Paxson - - * flexdef.h: [no log message] - -1993-02-06 Vern Paxson - - * main.c, scan.l: A lot of tweaks ... - -1993-02-06 Vern Paxson - - * ccl.c: reallocate_character_array -> reallocate_Character_array - -1993-02-06 Vern Paxson - - * gen.c: Bug/lint fixes Modified to work with "action" array instead - of temp file - -1993-02-06 Vern Paxson - - * sym.c: Fixed bug in 8-bit hashing - -1993-02-06 Vern Paxson - - * parse.y: numerous bug fixes extra formatting of error/warning - messages added support of <*>, partial support for nested start - conditions - -1993-02-06 Vern Paxson - - * ecs.c: Remove %t cruft - -1993-02-06 Vern Paxson - - * flex.skl: Beginning of %pointer/%array support - -1993-02-06 Vern Paxson - - * dfa.c: Added keeping track of which rules are useful fixed a - fencepost error in checking for scanners that require -8 - -1993-02-06 Vern Paxson - - * nfa.c: Added checking for whether rules are useful modified to - work with internal "action" array - -1993-02-06 Vern Paxson - - * misc.c: Added internal "action" array, internal skeleton, - zero_out() in lieu of bzero - -1993-02-06 Vern Paxson - - * tblcmp.c: Fixed a bunch of fencepost errors in increasing tables. - -1993-02-06 Vern Paxson - - * yylex.c: -Wall fix - -1991-03-28 Vern Paxson - - * gen.c: Fixed out-of-bounds access bug; patch #7 for release 2.3 - -1991-03-28 Vern Paxson - - * NEWS: Patch #7 for 2.3 - -1990-10-23 Vern Paxson - - * gen.c: fixed missing "rule_type" entry for end-of-buffer action - -1990-08-29 Vern Paxson - - * gen.c: Fixed yymore() but in not resetting yy_more_len - -1990-08-29 Vern Paxson - - * NEWS: Patch #6 for 2.3 - -1990-08-16 Vern Paxson - - * NEWS: Patch #5 - -1990-08-14 Vern Paxson - - * misc.c: fixed comment in myesc() - -1990-08-14 Vern Paxson - - * NEWS: fixed date in patch #4 - -1990-08-14 Vern Paxson - - * NEWS: patch #4 - -1990-08-14 Vern Paxson - - * misc.c: fixed hexadecimal escapes; added is_hex_digit() - -1990-08-03 Vern Paxson - - * NEWS: Patch #3 - -1990-08-03 Vern Paxson - - * flex.skl, flexdef.h: changed to include for __GNUC__ - -1990-08-02 Vern Paxson - - * NEWS: 2.3 patch #2 - -1990-08-02 Vern Paxson - - * flex.skl: Another try at getting the malloc() definitions correct; - this time for g++, too - -1990-08-02 Vern Paxson - - * flex.skl, flexdef.h: fixed to declare malloc() and free() by hand - if __GNUC__ - -1990-07-28 Vern Paxson - - * flexdef.h: Changed to get malloc definition in identical fashion - to that used by flex.skel - -1990-06-28 Vern Paxson - - * NEWS: [no log message] - -1990-06-28 Vern Paxson - - * flex.1: Fixed bug in mini-scanner examle Fixed bug in YY_INPUT - redefinition yylineno defense reentrancy documentation Something - else which I forget. - -1990-06-27 Vern Paxson - - * COPYING, ccl.c, dfa.c, ecs.c, flexdef.h, gen.c, main.c, misc.c, - nfa.c, parse.y, scan.l, sym.c, tblcmp.c, yylex.c: 4.4 BSD copyright - -1990-05-26 Vern Paxson - - * README: Changed prolog to reflect 2.3 release. - -1990-05-26 Vern Paxson - - * NEWS: pointed reader at Makefile instead of README for porting - considerations added Makefile comments: support for SCO Unix; - parameterization - -1990-05-26 Vern Paxson - - * flex.skl: Added DONT_HAVE_STDLIB_H and declarations of malloc() - -1990-05-26 Vern Paxson - - * NEWS: 2.3 changes - -1990-05-26 Vern Paxson - - * flex.1: documentation on new features Comment regarding Ove's work - ^foo|bar difference between flex / lex yyin initialization - difference documented that yy_switch_to_buffer can be used in - yywrap() documented that # comments are deprecated - -1990-05-26 Vern Paxson - - * main.c: declared void functions as such added prototypes for - forward references changed to check for error status when closing - files - -1990-05-26 Vern Paxson - - * yylex.c: Added macro definition for isascii() if not already - present - -1990-05-26 Vern Paxson - - * sym.c: declared void functions as such added prototypes for - forward references changed to use format_pinpoint_message where - appropriate - -1990-05-26 Vern Paxson - - * scan.l: declared void functions as such changed to strip # - comments, as documented moved #undef of yywrap() to before include - of flexdef, so prototype doesn't get screwed up - -1990-05-26 Vern Paxson - - * parse.y: introduced format_pinpoint_message() declared void - functions as such changed lone <> to apply to all outstanding - start conditions - -1990-05-26 Vern Paxson - - * nfa.c, tblcmp.c: declared void functions as such added prototypes - for forward references - -1990-05-26 Vern Paxson - - * misc.c: declared void functions as such prototypes for forward - references shuffled around some routines to make the order perhaps a - little more logical changed memory references to use void* instead - of char* - -1990-05-26 Vern Paxson - - * libmain.c: Added declaration of arguments made yylex() a function - -1990-05-26 Vern Paxson - - * gen.c: prototypes for forward references declared void functions - as such yy_flex_debug testing of error on file closes casts to void - for sprintf() and strcpy() - -1990-05-26 Vern Paxson - - * flexdef.h: Added prototypes changed memory allocation routines to - deal with void*'s instead of char*'s some rearranging for VMS - -1990-05-26 Vern Paxson - - * flex.skl: Added YY_USER_INIT Added yy_new_buffer() alias for - yy_create_buffer() fixed (hopefully) malloc declaration headaches - -1990-05-26 Vern Paxson - - * ecs.c: declared void functions as such declared void functions as - such - -1990-05-26 Vern Paxson - - * dfa.c: prototypes for forward references declared void functions - as such - -1990-05-26 Vern Paxson - - * ccl.c: Declared void functions as such - -1990-04-12 Vern Paxson - - * flex.skl: added fix for allowing yy_switch_to_buffer() in yywrap() - -1990-04-03 Vern Paxson - - * NEWS: patch #3 - -I fix - -1990-03-30 Vern Paxson - - * gen.c: Changed generation of archaic "continue" to "goto - yy_find_action" - -1990-03-27 Vern Paxson - - * NEWS: Patch #2 changes - -1990-03-27 Vern Paxson - - * flex.skl: fixed fencepost errors with yy_buf_size and detecting - NUL's - -1990-03-26 Vern Paxson - - * NEWS: [no log message] - -1990-03-26 Vern Paxson - - * flex.skl: g++ tweaks - -1990-03-23 Vern Paxson - - * NEWS: Changes for Patch #1. - -1990-03-23 Vern Paxson - - * flex.skl: fix for g++ - -1990-03-23 Vern Paxson - - * flex.1: minor typos and formatting changes. Removed BITNET - address. - -1990-03-23 Vern Paxson - - * README: nuked BITNET address. - -1990-03-20 Vern Paxson - - * README: 2.2 README - -1990-03-20 Vern Paxson - - * NEWS: USG alias. - -1990-03-20 Vern Paxson - - * flexdef.h: Added USG alias for SYS_V - -1990-03-20 Vern Paxson - - * : [no log message] - -1990-03-20 Vern Paxson - - * flex.skl: Tweaks for lint and C++ - -1990-03-20 Vern Paxson - - * flex.1: -ll => -lfl - -1990-03-20 Vern Paxson - - * NEWS: 2.2 changes - -1990-03-20 Vern Paxson - - * flex.skl: Changed to use YY_BUFFER_STATE everywhere. - -1990-03-20 Vern Paxson - - * flex.1: [no log message] - -1990-03-20 Vern Paxson - - * dfa.c: "associated rules" changed to "associated rule line - numbers". - -1990-03-20 Vern Paxson - - * scan.l: cast added to malloc() call to keep lint happy. - -1990-03-20 Vern Paxson - - * yylex.c: Fixed handling of premature EOF's. - -1990-03-20 Vern Paxson - - * sym.c: Removed declaration of malloc() - -1990-03-20 Vern Paxson - - * scan.l: Removed malloc() declaration. Added detection of EOF in - actions. - -1990-03-20 Vern Paxson - - * parse.y: Rules rewritten so '/' and '$' parsed correctly. - -1990-03-20 Vern Paxson - - * nfa.c: Corrected line numbers for continued actions. - -1990-03-20 Vern Paxson - - * misc.c: Removed declarations of malloc() and realloc(). - -1990-03-20 Vern Paxson - - * main.c: Summary of generation flags. Minor -8 tweaks. - -1990-03-20 Vern Paxson - - * gen.c: full support for -d - -1990-03-20 Vern Paxson - - * flexdef.h: defines for malloc() and realloc() conditional defines - for abs(), min(), and max() - -1990-03-20 Vern Paxson - - * flex.skl: Many multiple-buffer additions. - -1990-03-20 Vern Paxson - - * dfa.c: -8 tweaks. - -1990-03-19 Vern Paxson - - * flex.skl: Proto hacks. NUL hacks. Debugging hacks. C++ hacks. - -1990-03-16 Vern Paxson - - * : RCS won't let me unedit! gets "Missing access list" - -1990-03-16 Vern Paxson - - * tblcmp.c: Minor tweaks for NUL's. - -1990-03-16 Vern Paxson - - * : no changes -- had checked out for testing smaller read buffer - sizes - -1990-03-16 Vern Paxson - - * nfa.c: hack for NUL's. - -1990-03-16 Vern Paxson - - * misc.c: Hack to cshell for NUL's. - -1990-03-16 Vern Paxson - - * main.c: NUL's. -8 - -1990-03-16 Vern Paxson - - * gen.c: NUL's. - -1990-03-16 Vern Paxson - - * flexdef.h: NUL's. 8-bit chars. - -1990-03-16 Vern Paxson - - * flex.skl: NUL's; indenting - -1990-03-16 Vern Paxson - - * dfa.c: more thrashing around with NUL's - -1990-03-16 Vern Paxson - - * ccl.c: removed NUL hack - -1990-03-14 Vern Paxson - - * yylex.c: Added <> token - -1990-03-14 Vern Paxson - - * ecs.c, flexdef.h: Tweaks for NUL chars. - -1990-03-14 Vern Paxson - - * dfa.c, gen.c, main.c, misc.c, parse.y, scan.l, tblcmp.c: Tweaks - for NUL chars. - -1990-03-14 Vern Paxson - - * ccl.c: Tweaks for handling NUL's. - -1990-02-28 Vern Paxson - - * flex.1: [no log message] - -1990-02-28 Vern Paxson - - * flex.1: Changed .so options.man to inlined version since flex.1 - will have a different (shorter) options description. - -1990-02-28 Vern Paxson - - * flex.1: [no log message] - -1990-02-28 Vern Paxson - - * flex.1: [no log message] - -1990-02-26 Vern Paxson - - * flex.1: [no log message] - -1990-02-25 Vern Paxson - - * flex.1: [no log message] - -1990-02-25 Vern Paxson - - * flex.1: Initial revision - -1990-01-16 Vern Paxson - - * gen.c: Restored EOB accepting list for REJECT. Second try at 2.2 - Release. - -1990-01-16 Vern Paxson - - * misc.c: Added missing ',' in error message. 2.2 Release, second - try. - -1990-01-16 Vern Paxson - - * yylex.c: 8-bit char support. 2.2 Release. - -1990-01-15 Vern Paxson - - * scan.l: 8-bit char support. Arbitrary indented/%{} code allowed - in section 2. \x escapes. %t support. Minor POSIX-compliance - changes. BEGIN(0) -> BEGIN(INITIAL). yywrap() and set_input_file() - for multiple input files. C_COMMENT_2 removed. 2.2 Release. - -1990-01-15 Vern Paxson - - * flexdef.h: 8-bit char support. SYS_V / Atari portability fixes. - Removed generated array names. CSIZE now only defined if not - already defined. Added "csize" global. Added "input_files", - "num_input_files", and "program_name" globals. %t support globals. - 2.2 Release. - -1990-01-15 Vern Paxson - - * gen.c: Removed unused EOB_accepting_list array. 2.2 Release. - -1990-01-15 Vern Paxson - - * gen.c: Bug in -F table generation fixed. 8-bit char support. - Hardwired generated array names. "const"'s added to generated code. - Fixed yymore() / trailing context bug. - -1990-01-15 Vern Paxson - - * parse.y: 8-bit char support. Error-message pinpointing. 2.2 - Release. - -1990-01-15 Vern Paxson - - * main.c: Unsigned char support. %t support. Removed hard-wiring - of program name "flex". -c changed to -C; -c now deprecated. -n - added. :-( Multiple input files. SYSV tmpnam() use. Removed old - #define's from output. Identified error messages w/ filename and - line. 2.2 Release. - -1990-01-15 Vern Paxson - - * sym.c: Unsigned char support. 2.2 Release. - -1990-01-15 Vern Paxson - - * nfa.c: Removed redundant test. 2.2 Release. - -1990-01-15 Vern Paxson - - * misc.c: Unsigned char support. \x support. 2.2 Release. - -1990-01-15 Vern Paxson - - * tblcmp.c: 8-bit char support. 2.2 Release. - -1990-01-15 Vern Paxson - - * flex.skl: C++ support. Turbo-C support. 8-bit char support. - yyleng is an int. unput() callable in section 3. yymore hacks. - yyrestart() no longer closes stdin. 2.2 Release. - -1990-01-15 Vern Paxson - - * ecs.c: %t support. 8-bit/unsigned char support. 2.2 Release. - -1990-01-15 Vern Paxson - - * dfa.c: %t hacks. minor cosmetics. 2.2 Relase. - -1990-01-15 Vern Paxson - - * ccl.c: Changes for unsigned/8-bit chars. 2.2 Release. - -1990-01-10 Vern Paxson - - * libmain.c: Initial revision - -1989-12-30 Vern Paxson - - * nfa.c: removed gratuitous trailing context code - -1989-12-30 Vern Paxson - - * main.c: made -c case-sensitive - -1989-12-30 Vern Paxson - - * flex.skl: unput() bug fix - -1989-12-30 Vern Paxson - - * README: [no log message] - -1989-06-20 Vern Paxson - - * scan.l: changed to not use '|' and trailing context combo so users - can test using -F ... - -1989-06-20 Vern Paxson - - * parse.y: made trailing context combined with '|' warning always - come out - -1989-06-20 Vern Paxson - - * README: [no log message] - -1989-06-20 Vern Paxson - - * COPYING: Initial revision - -1989-06-20 Vern Paxson - - * NEWS, README, main.c: [no log message] - -1989-06-20 Vern Paxson - - * README: [no log message] - -1989-06-20 Vern Paxson - - * NEWS, README, main.c: [no log message] - -1989-06-20 Vern Paxson - - * : Beta release - -1989-06-20 Vern Paxson - - * NEWS, main.c: [no log message] - -1989-06-20 Vern Paxson - - * flex.skl, flexdef.h, gen.c, misc.c, nfa.c, parse.y, scan.l, sym.c: - 2.0.1 beta - -1989-06-20 Vern Paxson - - * README: [no log message] - -1989-05-25 Vern Paxson - - * gen.c: fixsed bug with -I and backtracking - -1989-05-25 Vern Paxson - - * flex.skl: Cleaned up forward declarations of yyunput() and input() - -1989-05-25 Vern Paxson - - * parse.y: Split copyright string. - -1989-05-25 Vern Paxson - - * nfa.c: Split copyright string. Added check for empty machine in - dupmachine(). - -1989-05-25 Vern Paxson - - * ccl.c, dfa.c, ecs.c, gen.c, main.c, misc.c, scan.l, sym.c, - tblcmp.c, yylex.c: Split copyright string into two to avoid tempting - fate with \ sequences ... - -1989-05-24 Vern Paxson - - * README: updated for 2nd release Beta test added RCS header - -1989-05-24 Vern Paxson - - * flexdef.h: removed static char copyright - -1989-05-24 Vern Paxson - - * flexdef.h: Added BSD copyright notice. Removed - FAST_SKELETON_FILE. - -1989-05-24 Vern Paxson - - * main.c: added BSD copyright notice. Removed references to - FAST_SKELETON_FILE. - -1989-05-24 Vern Paxson - - * ecs.c, gen.c, nfa.c: Added BSD copyright notice - -1989-05-24 Vern Paxson - - * ccl.c, dfa.c, misc.c, parse.y, scan.l, sym.c, tblcmp.c, yylex.c: - added BSD copyright notice - -1989-05-24 Vern Paxson - - * flex.skl: Initial revision - -1989-05-19 Vern Paxson - - * yylex.c: renamed accnum to num_rules - -1989-05-19 Vern Paxson - - * tblcmp.c: moved table generation code to gen.c moved ntod() to - dfa.c - -1989-05-19 Vern Paxson - - * sym.c: the most piddling format change imaginable - -1989-05-19 Vern Paxson - - * scan.l: changed to look for yymore, REJECT, %used and %unused - removed gross magic for dealing with section 3 - -1989-05-19 Vern Paxson - - * nfa.c, parse.y: changes for variable trailing context - -1989-05-19 Vern Paxson - - * misc.c: added all_lower() and all_upper() - -1989-05-19 Vern Paxson - - * main.c: added checking for features being Really used - backtracking, performance reports misc. cleanup - -1989-05-19 Vern Paxson - - * gen.c: major overhaul for merged skeleton - -1989-05-19 Vern Paxson - - * flexdef.h: a zillion changes/additions/cleanups - -1989-05-19 Vern Paxson - - * dfa.c: added backtrack report added checking for dangerous - trailing context considerable minor cleanup - -1989-05-19 Vern Paxson - - * ccl.c: list_character_set() modified to take a FILE to write to - ... - -1989-05-19 Vern Paxson - - * README: updated for beta release - -1988-11-25 Vern Paxson - - * main.c: added -p flag generation of #define's for scanner - -1988-11-25 Vern Paxson - - * flexdef.h: Added END_OF_BUFFER_ACTION and bol_needed - -1988-11-25 Vern Paxson - - * dfa.c: added ntod() - -1988-05-09 Vern Paxson - - * gen.c: Initial revision - -1988-05-08 Vern Paxson - - * yylex.c: RCS header changed display style of non-printings from ^x - to \0xx - -1988-05-08 Vern Paxson - - * tblcmp.c: RCS header MAX_XTIONS_FOR_FULL_INTERIOR_FIT -> - MAX_XTIONS_FULL_INTERIOR_FIT made back-tracking accepting number be - one greater than the last legit accepting number, instead of 0. - This way, end-of-buffer can take 0 and no negative accepting numbers - are needed. added genftbl() changed last ftl references to C added - check for UNSIGNED_CHAR's added back-track logic to make_tables() - added checking and report for backtracking fixed fence-post error - with onesp stack pointer - -1988-05-08 Vern Paxson - - * sym.c: RCS header changed "entry" to "sym_entry" to avoid conflict - with old keyword - -1988-05-08 Vern Paxson - - * scan.l: RCS header removed \^ from ESCSEQ - -1988-05-08 Vern Paxson - - * parse.y: RCS header bug fix due to missing default rule, could - have to backtrack when backtrack variables haven't been set up - -1988-05-08 Vern Paxson - - * nfa.c: RCS ident yy_cp, yy_bp support name shortenings assoc_rule - support - -1988-05-08 Vern Paxson - - * misc.c: RCS header check before malloc()'ing for 16 bit overflow - MS_DOS, VMS ifdef's removed commented-out \^ code removed FTLSOURCE - code added readable_form() - -1988-05-08 Vern Paxson - - * main.c: Added RCS header removed revision history misc additions - and fixes to globals VMS ifdef's backtracking statistics -p flag - name shortenings - -1988-05-08 Vern Paxson - - * flexdef.h: removed revision history added RCS header added VMS, - MS_DOS ifdef's removed DEFAULT_ACTION, changed END_OF_BUFFER_ACTION - shortened MAX_XTIONS_FOR_FULL_INTERIOR_FIT to - MAX_XTIONS_FULL_INTERIOR_FIT added MAX_ASSOC_RULES added - performance_report, assoc_rule gloabls added num_backtracking gloabl - shortened allocate_integer_pointer_array, - reallocate_integer_pointer_array - -1988-05-08 Vern Paxson - - * ecs.c: added RCS id added PROCFLG to avoid assumption of signed - char's - -1988-05-08 Vern Paxson - - * dfa.c: added RCS id added check_for_backtracking() added - dump_associated_rules() added dump_transitions() shortened - reallocate_integer_pointer_array to reallocate_int_ptr_array removed - some dfaacc_{state,set} abuses - -1988-05-08 Vern Paxson - - * ccl.c: Added list_character_set() - -1988-05-07 Vern Paxson - - * ccl.c: added RCS id - -1988-04-10 Vern Paxson - - * README: minor tweaks - -1988-04-10 Vern Paxson - - * README: forgot sh flex.shar - -1988-04-10 Vern Paxson - - * README: final tweaking - -1988-04-10 Vern Paxson - - * tblcmp.c: removed minor lint fluff - -1988-04-10 Vern Paxson - - * NEWS: [no log message] - -1988-04-10 Vern Paxson - - * NEWS, README: Initial revision - -1988-04-10 Vern Paxson - - * yylex.c: added identifying comment. changed to include "parse.h" - instead of "y.tab.h" - -1988-04-10 Vern Paxson - - * tblcmp.c: Changed name from flexcmp.c -> tblcmp.c fixed misc. - typos made generating ec tables be a routine - -1988-04-10 Vern Paxson - - * sym.c: changed name from flexsym.c -> sym.c revamped calling - sequences, etc., for extended table struct definition which now has - both char * and int fields. - -1988-04-10 Vern Paxson - - * scan.l: Changed name from flexscan.l -> scan.l fixed bug in - added block comments between rules. - -1988-04-10 Vern Paxson - - * parse.y: changed name from flexparse.y -> parse.y added start - condition "INITIAL" made a{3} have "variable length" - -1988-04-10 Vern Paxson - - * nfa.c: changed name from flexnfa.c -> nfa.c corrected some typos. - -1988-04-10 Vern Paxson - - * misc.c: changed name from flexmisc.c -> misc.c - -1988-04-10 Vern Paxson - - * main.c: fixed bug causing core dumps if skeleton files could not - be opened. Added -cF. Added fullspd to be equivalent to fulltbl - for which options is cannot be mixed with. - -1988-04-10 Vern Paxson - - * flexdef.h: fixed typos, enhanced symbol table definition. - -1988-04-10 Vern Paxson - - * ecs.c: changed name from flexecs.c to ecs.c - -1988-04-10 Vern Paxson - - * dfa.c: changed name from flexdfa.c to dfa.c - -1988-04-10 Vern Paxson - - * ccl.c: changed name from flexccl.c -> ccl.c - -1988-02-13 Vern Paxson - - * ccl.c, dfa.c, ecs.c, flexdef.h, main.c, misc.c, nfa.c, parse.y, - scan.l, sym.c, tblcmp.c, yylex.c: Beta Release. - -1987-11-08 Vern Paxson - - * Initial revision - diff --git a/third_party/lex/FlexLexer.h b/third_party/lex/FlexLexer.h deleted file mode 100644 index 70663e37..00000000 --- a/third_party/lex/FlexLexer.h +++ /dev/null @@ -1,211 +0,0 @@ -/* clang-format off */ -/* $OpenBSD: FlexLexer.h,v 1.7 2015/11/19 19:43:40 tedu Exp $ */ - -// $Header: /cvs/src/usr.bin/lex/FlexLexer.h,v 1.7 2015/11/19 19:43:40 tedu Exp $ - -// -*-C++-*- -// FlexLexer.h -- define interfaces for lexical analyzer classes generated -// by flex - -// Copyright (c) 1993 The Regents of the University of California. -// All rights reserved. -// -// This code is derived from software contributed to Berkeley by -// Kent Williams and Tom Epperly. -// -// 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. - -// This file defines FlexLexer, an abstract class which specifies the -// external interface provided to flex C++ lexer objects, and yyFlexLexer, -// which defines a particular lexer class. -// -// If you want to create multiple lexer classes, you use the -P flag -// to rename each yyFlexLexer to some other xxFlexLexer. You then -// include in your other sources once per lexer class: -// -// #undef yyFlexLexer -// #define yyFlexLexer xxFlexLexer -// #include -// -// #undef yyFlexLexer -// #define yyFlexLexer zzFlexLexer -// #include -// ... - -#ifndef __FLEX_LEXER_H -// Never included before - need to define base class. -#define __FLEX_LEXER_H - -#include -# ifndef FLEX_STD -# define FLEX_STD std:: -# endif - -extern "C++" { - -struct yy_buffer_state; -typedef int yy_state_type; - -class FlexLexer { -public: - virtual ~FlexLexer() { } - - const char* YYText() const { return yytext; } - int YYLeng() const { return yyleng; } - - virtual void - yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; - virtual struct yy_buffer_state* - yy_create_buffer( FLEX_STD istream* s, int size ) = 0; - virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; - virtual void yyrestart( FLEX_STD istream* s ) = 0; - - virtual int yylex() = 0; - - // Call yylex with new input/output sources. - int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) - { - switch_streams( new_in, new_out ); - return yylex(); - } - - // Switch to new input/output streams. A nil stream pointer - // indicates "keep the current one". - virtual void switch_streams( FLEX_STD istream* new_in = 0, - FLEX_STD ostream* new_out = 0 ) = 0; - - int lineno() const { return yylineno; } - - int debug() const { return yy_flex_debug; } - void set_debug( int flag ) { yy_flex_debug = flag; } - -protected: - char* yytext; - int yyleng; - int yylineno; // only maintained if you use %option yylineno - int yy_flex_debug; // only has effect with -d or "%option debug" -}; - -} -#endif // FLEXLEXER_H - -#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) -// Either this is the first time through (yyFlexLexerOnce not defined), -// or this is a repeated include to define a different flavor of -// yyFlexLexer, as discussed in the flex manual. -#define yyFlexLexerOnce - -extern "C++" { - -class yyFlexLexer : public FlexLexer { -public: - // arg_yyin and arg_yyout default to the cin and cout, but we - // only make that assignment when initializing in yylex(). - yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); - - virtual ~yyFlexLexer(); - - void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); - struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); - void yy_delete_buffer( struct yy_buffer_state* b ); - void yyrestart( FLEX_STD istream* s ); - - void yypush_buffer_state( struct yy_buffer_state* new_buffer ); - void yypop_buffer_state(); - - virtual int yylex(); - virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); - virtual int yywrap(); - -protected: - virtual int LexerInput( char* buf, int max_size ); - virtual void LexerOutput( const char* buf, int size ); - virtual void LexerError( const char* msg ); - - void yyunput( int c, char* buf_ptr ); - int yyinput(); - - void yy_load_buffer_state(); - void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); - void yy_flush_buffer( struct yy_buffer_state* b ); - - int yy_start_stack_ptr; - int yy_start_stack_depth; - int* yy_start_stack; - - void yy_push_state( int new_state ); - void yy_pop_state(); - int yy_top_state(); - - yy_state_type yy_get_previous_state(); - yy_state_type yy_try_NUL_trans( yy_state_type current_state ); - int yy_get_next_buffer(); - - FLEX_STD istream* yyin; // input source for default LexerInput - FLEX_STD ostream* yyout; // output sink for default LexerOutput - - // yy_hold_char holds the character lost when yytext is formed. - char yy_hold_char; - - // Number of characters read into yy_ch_buf. - int yy_n_chars; - - // Points to current character in buffer. - char* yy_c_buf_p; - - int yy_init; // whether we need to initialize - int yy_start; // start state number - - // Flag which is used to allow yywrap()'s to do buffer switches - // instead of setting up a fresh yyin. A bit of a hack ... - int yy_did_buffer_switch_on_eof; - - - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ - void yyensure_buffer_stack(void); - - // The following are not always needed, but may be depending - // on use of certain flex features (like REJECT or yymore()). - - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - yy_state_type* yy_state_buf; - yy_state_type* yy_state_ptr; - - char* yy_full_match; - int* yy_full_state; - int yy_full_lp; - - int yy_lp; - int yy_looking_for_trail_begin; - - int yy_more_flag; - int yy_more_len; - int yy_more_offset; - int yy_prev_more_offset; -}; - -} - -#endif // yyFlexLexer || ! yyFlexLexerOnce - diff --git a/third_party/lex/NEWS b/third_party/lex/NEWS deleted file mode 100644 index aa30e43d..00000000 --- a/third_party/lex/NEWS +++ /dev/null @@ -1,532 +0,0 @@ -This is the file NEWS for the flex package. It records user -visible -changes between releases of flex. - -See the file COPYING for copying conditions. - -* flex version 2.5.39 - -** no user visible changes in this release - -* version 2.5.38 released 2014-02-14 - -** internationalization - -*** add sr translation from the translation project - -*** update da, es, ko, nl, pt_BR, ro, ru, sv, tr, vi, zh_CN translations from the translation project - -*** rename zh_tw to its proper zh_TW name - -* version 2.5.37 released 2012-08-03 - -** Import flex into git. See - git://flex.git.sourceforge.net/gitroot/flex/flex. - -** Fix make install target to not fail when the flex++ program is - already installed - -** New translations from the translation project: de, fi, pl, vi - -* version 2.5.36 released 2012-07-20 - -** various portability fixes that quiet compiler warnings on 64-bit - hosts - -** various manual fixes, including correcting the name of a %option and - updating some simple examples to use ANSI C syntax - -** various bug fixes that prevent certain error conditions from - persisting when they should not persist - -** improvements to the test suite so it behaves better when linking - compiled files - -** new translations from the translation project: ca, da, es, fi, fr, - ga, ko, pt_br, ro, ru, sv, tr, zh_cn - -** the flex distribution is now built with automake 1.10.1 and automake - 2.61 - -* version 2.5.35 released 2008-02-26 - -** fixed bug that prevented flex from accepting certain comments in the - scanner file (resolves bugs #1849809 and #1849805) - -** fix bug that prevented headers for all functions from being generated - (resolves bug #1628314) - -** change yy_size_t to be size_t (resolves bug #1849812) - -** new de, nl, pl, pt_br, vi translations from the translation project - -* version 2.5.34 released 2007-12-12 - -** introduce yylex_init_extra; see the manual for details - -** introduce %option extra-type="your_type *" (resolves bug #1744505) - -** The flex program now parses multiple short concatenated options (resolves bug - #1619820). Thanks to Petr Machata of Red Hat on this issue. - -** better checking after yyalloc/yyrealloc (resolves bug #1595967) - -** flex now provides for a libfl_pic.a compiled with position - independent code. Particularly useful when including a flex scanner - in a shared library and with more recent versions of gcc. Thanks to the Debian project for the idea. - -** SourceForge feature request #1658379: Expose YY_BUF_SIZE in the - header file. - -** flex better escapes filenames with special characters in them - (resolves bug #1623600) - -** a memory leak was plugged(resolves bug #1601111) - -** pattern language expanded; see the manual for details on the below - highlights - -*** pattern options added to specify patterns as case-insensitive or - case-sensitive - -*** pattern options to specify whether the "." character should match - the newline character - -*** pattern options added to allow ignoring of whitespace in patterns - -*** POSIX character classes may be negated in patterns - -*** patterns may now use set difference, union operators - -** the manual now contains an appendix listing various common patterns - which may be useful when writing scanners - -** some memory leaks were removed from the C++ scanner (but the C++ - scanner is still experimental and may change radically without - notice) - -** c++ scanners can now use yywrap - -** added new unit test for c++ and yywrap - -** portability fixes to some unit tests - -** flex man page and flex manual in pdf now distributed in the flex -distribution - -** new ca, vi, ga, nl translations from the translation project - -** flex no longer comes with an rpm spec file - -** flex development now happens with automake 1.9.6 - -* version 2.5.33 released 2006-2-20 - -** all flex resources are now to be found from the website at - http://flex.sourceforge.net/ - -** there was no release 2.5.32 published - -** numerous bug and security fixes - -** new nl, vi, sv, ro, po, ga, ca, fr, tr translations from the translation project - -** upgrade to use gettext 0.12 (this now makes the "pdf" and "ps" - targets in the build system able to be run successfully) - -* version 2.5.31 released 2003-4-1 - -** remove --enable-maintainer-mode configure option; none of the - Makefiles were using it and it can be unduely confusing - -* version 2.5.30 released 2003-4-1 - -** yylineno is per-buffer in reentrant scanners - -** added %top directive for placing code at the top of the generated - scanner; see manual for details - -** flex now uses m4 to generate scanners; while this means that - scanners are more readable, it means that flex requires m4 to be - installed; see manual for details - -* version 2.5.29 released 2003-3-5 - -** Automatic stack management for multiple input buffers in C and C++ scanners - -** moved the flex documentation to a new doc/ subdirectory - -** cleanups to the yy namespace - -* version 2.5.28 released 2003-2-12 - -** flex is now hosted at sourceforge - -** Fixed trailing slash bug in YY_INPUT macro def - -** Flex now warns if always-interactive is specified with fast or full - -* version 2.5.27 released 2003-1-21 - -** flex now works with recent bison versions - -** new pt_br translation from the translation project - -* version 2.5.26 released 2003-1-14 - -** Fixed table deserialization bug on big-endian archs. Patch sent from Bryce Nichols - -** yyleng has proper declarations now; this caused flex to generate - unusable scanners for some programs - -** the flex distribution now includes a spec file suitable for use - with rpm - -** some more c++ fixes - -** new es translation from the translation project - -** slight tweeks to the flex_int*_t types - -** flex now warns about pattern ranges that might be ambiguous when - generating a case-insensitive scanner - - -* version 2.5.25 released 2002-12-2 - -** flex now uses flex_int*_t types. For C99 systems, they are just the - int*_t types; for non-C99 systems, we just make some typedefs - -** new pt_br translation from the translation project - -* version 2.5.24 released 2002-11-25 - -* more portability fixes - -** the manual continues to be updated and edited, but it's still got a - ways to go - -** it is possible to have multiple c++ scanners in the same program again - -** new turkish translation from the translation project - -* version 2.5.23 released 2002-10-21 - -** more portability fixes - -** the manual includes a title page and a table-of-contents when printed - -** the test suite can be run with "make check" from the top-level - directory - -** configure now accepts the --enable-maintainer-mode option - -** gettext functionality is now only available externally - -** the constant FLEX_BETA is defined if flex is a beta release - -** the script create-test was not included in the distribution and it - should have been - -* version 2.5.22 released 2002-10-10 - -** more portability fixes around how we get ahold of the integral - types; there is a constant FLEX_NEED_INTEGRAL_TYPE_DEFINITIONS - which you should define if you don't have the header - file (after you complain to your C vendor for not providing a - reasonable C environment) - -** more test suite cleanups; in particular, the test suite should run - correctly when build from a different directory - -** upgraded automake to 1.7 and consequently autoconf to 2.54; this - means, among other things, that there is some support for -formatting the manual in postscript and pdf in the distributed - Makefile.in (and therefore in the Makefile built by configure) - -** the flex.1 manpage is generated by help2man; (this has been true - for quite a while but was not listed here) - -** flex now includes three defined constants to indicate which version - of flex generated a scanner (YY_FLEX_{MAJOR,MINOR,SUBMINOR}_VERSION) - -** flex tries its best to output only the relevant portions of the - skeleton when generating a scanner, thus avoiding as much - conditional compilation as possible - -* version 2.5.21 released 2002-9-17 - -** one of the tests in the test suite broke the dist target - -* version 2.5.20 released 2002-9-16 - -** A flex scanner has the ability to save the DFA tables to a file, - and load them at runtime when needed; see the manual for details - -** Added %option bison-bridge (--bison-bridge) - -** Removed %option reentrant-bison/--reentrant-bison/-Rb - -** yylineno is present in all scanners; Modified nasty performance - penalty warning with yylineno in documentation - -** test-table-opts is now run last in the test suite because it's so fat - -** flex can, to some extent, diagnose where internal problems occur - -** new translations from the translation project: fr, ca, de, ru, sv - -**Flex generates C99 defs now; see YY_TRADITIONAL_FUNC_DEFS in the - manual if that's not a good thing for you - -* version 2.5.19 released 2002-9-5 - -** prevent segfault on input lines which are longer than the allocated - space (problem report from Manoj Srivastava - ) - -** Changed option 'header' to 'header-file' - -* version 2.5.18 released 2002-9-4 - -** portability fixes for integer constants and in the way the test - suite reports its results - -** the test for bison was reporting bison missing when it was, in - fact, found - -** if we don't find GNU indent, we're more careful when we're not - finding it - -* version 2.5.17 released 2002-8-29 - -** more portability fixes - -** updated config.sub and config.guess - -** flex is indented by GNU indent (this was done earlier but not - explicitly documented) - -* version 2.5.16 released 2002-8-28 - -** c++ scanners compile again - -** there is now an indent target in the top-level Makefile; configure - checks for GNU indent which is required for proper operation of the - indent target - -** some more portability fixes were made - -** %options and invocation sections of manual merged - -** a c++ test was added to the test suite - -** we're trying to clean up more files in the test suite's make clean - targets - -* version 2.5.15 released 2002-8-21 - -** reject-state buffer is now dynamically allocated and REJECT buffer - variables are reentrant-safe - -** manual now discusses memory usage - -** skeleton now processed by m4 before mkskel.sh; (this only matters - if you want to change the skeleton or if you're doing flex development) - -** zh_cn translation added from translation project - -** a bug that caused a segfault has now been fixed - -** the test suite now respects the usual CFLAGS, etc. variables - -** removed some warnings which some tests trigggered with the -s option - -** the flex-generated header file now tries to be smarter about - conditionally including start conditions - -** tables code omitted from generated scanner when not used - -* version 2.5.14 released 2002-8-15 - -** the tests using the reentrant c scanner as c++ were reworked - slightly to be sure that the c++ was enforced - -** de translation now included in the distribution - -** various portability fixes regarding nls support, c++ include - headers, etc. - -* version 2.5.13 released 2002-8-15 - -** the header file output with %option header is now much smaller - -** Fixed type mismatch in printf in scanner skeleton - -** yylex_init now reports errors - -* version 2.5.12 released 2002-8-8 - -** updated gettext support to 0.11.5 - -** new fr translation from the translation project - -** bison is no longer needed to build flex; If you are building flex - from a release (i.e., not from a cvs snapshot), then you don't need - to have a pre-built lex around either (unless you modify scan.l, of - course); (This has been true for some time, but was not mentioned - here.) - -* version 2.5.11 released 2002-7-31 - -** Fixed bug where yyless did not consider yylineno - -** the yylineno performance hit is now gone - -** fixed some typos in the manual and we now include texinfo.tex in - the distribution - -** traditional prototypes output for C scanners, controlled by a - preprocessor symbol; see documentation for details - -* version 2.5.10 released 2002-7-24 - -** yy_globals renamed to yyscanner and yy_globals_t renamed to - yy_guts_t - -** added dist-bzip2 option to Makefile.am so we now produce a bzip2'd - archive in addition to the standard gzip archive - -* version 2.5.9 - -** new tests in test suite: test-mem-{nr,r}, test-posix, - test-posixly-correct, test-debug-{nr,r} - -** made changes to work with gcc-3.2 development code - -** ability to choose which memory functions are used in flex - -** new yylex_destroy() function for the non-reentrant scanner - -** new handling of POSIXLY_CORRECT environment variable - -** the test suite now has its copyrights explicitly described - -** new ca, de, fr, ru, sv, tr translations - -* version 2.5.8 - -** a new --posix option generates scanners with posix-style abc{1,3} - compatible parsing, see manual for the screwy details - -* version 2.5.7 - -** configure.in now includes a call to AC_PREREQ to enforce the - requirement for autoconf at least 2.50 (This only effects you if - you're doing flex development.) - -** configure now uses autoconf's versioning information and configure - --help reports the bug-reporting address for flex - -** test suite now only reports success versus failure; reporting - skipped is problematic under the current setup - -** compilation with --disable-nls now works - -** flex can now be built in a separate directory - -* version 2.5.6 - -** gettext support added (from gettext 0.11) - -*** translations for ca, da, de, es, fr, ko, ru, sv, tr included - -** distribution now built under automake 1.6 and autoconf 2.53 - -** command-line option parsing happens differently now: - -*** Added long option parsing - -*** Options -n and -c, previously deprecated, now simply do nothing - -*** Options are now parsed left to right - -** added a number of new options - -*** All positive %options are now accessible from the command line - -*** Added option -D, to define a preprocessor symbol - -*** Added option --header=FILE to specify a C .h file to generate - -*** added option --yywrap to call yywrap on EOF - -*** added option --yylineno to track line count in yylineno - -*** --yyclass=NAME name of C++ class when generating c++ scanners - -*** for long option names which are associated with existing short -options, see accompanying documentation - -*** new %option nounistd or command-line --nounistd added to prevent - flex from generating #include on systems that don't - have that include file - -** Support for reentrant C scanners has been added - -*** Updated the manual with the new reentrant API - -*** Two new options %option reentrant (-R) and -%option reentrant-bison (-Rb) - -*** All globals optionally placed into struct yyglobals_t - -*** All access to globals replaced by macro invocations - -*** All functions optionally take one additional -argument, yy_globals - -*** New style for invoking reentrant scanner: -yylex_init(void** scanner ); -yylex( scanner ); -yylex_destroy( scanner ); - -*** Added get/set functions for members of struct yy_globals_t -e.g., yyget_text, yyget_leng, etc - -*** Prefix substitution added for new functions - -*** Macro shortcuts to the lengthy get/set functions -provided for use in actions, e.g., yytext, yyleng, etc - -*** Arbitrary, user-defined data, "yyextra", may be added to scanner - -** %option nomain no longer implies %option yywrap -But the inverse is still true - -** Developer test suite added - -*** TESTS/ directory has been added. Users can -'make test' in the TESTS directory to execute the test suite - -** Support for bison variables yylval and yylloc added - -** automake support for the build process - -** manual is now in texinfo/info format - -*** flex.1 removed from distribution - -** flex no longer generates C-language scanners with C++-style - comments - -** flex now generates scanners in c++ which are compatible with - recent c++ compilers - -** flex input scanner now recognizes '\r' as an EOL character - -See the file ONEWS for changes in earlier releases. - -Local Variables: -mode: text -mode: outline-minor -end: diff --git a/third_party/lex/NOTES b/third_party/lex/NOTES deleted file mode 100644 index 8906709e..00000000 --- a/third_party/lex/NOTES +++ /dev/null @@ -1,113 +0,0 @@ -This is flex, the fast lexical analyzer generator. - -flex is a tool for generating scanners: programs which recognize -lexical patterns in text. - -More information about flex as well as the latest official release of -flex can be found at: - -http://flex.sourceforge.net/ - -Bug reports should be submitted using the SourceForge Bug Tracker for -flex at: - -http://sourceforge.net/tracker/?group_id=97492&atid=618177 - -The flex codebase is kept in git at: - -https://github.com/westes/flex - -There are several mailing lists available as well: - -flex-announce@lists.sourceforge.net - where posts will be made -announcing new releases of flex. - -flex-help@lists.sourceforge.net - where you can post questions about -using flex - -flex-devel@lists.sourceforge.net - where you can discuss development of -flex itself - -Find information on subscribing to the mailing lists at: - -http://sourceforge.net/mail/?group_id=97492 - -The flex distribution contains the following files which may be of interest: - -README - This file. - -NEWS - current version number and list of user-visible changes. - -INSTALL - basic installation information. - -ABOUT-NLS - description of internationalization support in flex. - -COPYING - flex's copyright and license. - -doc/ - user documentation. - -examples/ - containing examples of some possible flex scanners and a -few other things. See the file examples/README for more details. - -TODO - outstanding bug reports, desired features, etc. - -tests/ - regression tests. See TESTS/README for details. - -po/ - internationalization support files. - -You need the following tools to build flex from the maintainer's -repository: - -compiler suite - flex is built with gcc -bash, or a good Bourne-style shell -m4 - m4 -p needs to work; GNU m4 and a few others are suitable -GNU bison; to generate parse.c from parse.y -autoconf 2.69; for handling the build system -automake 1.12.2; for Makefile generation -gettext 0.18; fori18n support -help2man 1.36; to generate the flex man page -tar, gzip, etc.; for packaging of the source distribution -GNU texinfo 498; to build and test the flex manual -GNU indent 2.8; for indenting the flex source the way we want it done - -Once you have all the necessary tools installed, life becomes -simple. To prepare the flex tree for building, run the script: - -$ ./autogen.sh - -in the top level of the flex source tree. -This script calls the various tools needed to get flex ready for the -GNU-style configure script to be able to work. - -From this point on, building flex follows the usual configure, make, -make install routine. - -This file is part of flex. - -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. - -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. - - diff --git a/third_party/lex/ONEWS b/third_party/lex/ONEWS deleted file mode 100644 index 33415772..00000000 --- a/third_party/lex/ONEWS +++ /dev/null @@ -1,1233 +0,0 @@ -Changes between release 2.5.4 (11Sep96) and release 2.5.3: - - - Fixed a bug introduced in 2.5.3 that blew it when a call - to input() occurred at the end of an input file. - - - Fixed scanner skeleton so the example in the man page of - scanning strings using exclusive start conditions works. - - - Minor Makefile tweaks. - - -Changes between release 2.5.3 (29May96) and release 2.5.2: - - - Some serious bugs in yymore() have been fixed. In particular, - when using AT&T-lex-compatibility or %array, you can intermix - calls to input(), unput(), and yymore(). (This still doesn't - work for %pointer, and isn't likely to in the future.) - - - A bug in handling NUL's in the input stream of scanners using - REJECT has been fixed. - - - The default main() in libfl.a now repeatedly calls yylex() until - it returns 0, rather than just calling it once. - - - Minor tweak for Windows NT Makefile, MISC/NT/Makefile. - - -Changes between release 2.5.2 (25Apr95) and release 2.5.1: - - - The --prefix configuration option now works. - - - A bug that completely broke the "-Cf" table compression - option has been fixed. - - - A major headache involving "const" declarators and Solaris - systems has been fixed. - - - An octal escape sequence in a flex regular expression must - now contain only the digits 0-7. - - - You can now use "--" on the flex command line to mark the - end of flex options. - - - You can now specify the filename '-' as a synonym for stdin. - - - By default, the scanners generated by flex no longer - statically initialize yyin and yyout to stdin and stdout. - This change is necessary because in some ANSI environments, - stdin and stdout are not compile-time constant. You can - force the initialization using "%option stdinit" in the first - section of your flex input. - - - "%option nounput" now correctly omits the unput() routine - from the output. - - - "make clean" now removes config.log, config.cache, and the - flex binary. The fact that it removes the flex binary means - you should take care if making changes to scan.l, to make - sure you don't wind up in a bootstrap problem. - - - In general, the Makefile has been reworked somewhat (thanks - to Francois Pinard) for added flexibility - more changes will - follow in subsequent releases. - - - The .texi and .info files in MISC/texinfo/ have been updated, - thanks also to Francois Pinard. - - - The FlexLexer::yylex(istream* new_in, ostream* new_out) method - now does not have a default for the first argument, to disambiguate - it from FlexLexer::yylex(). - - - A bug in destructing a FlexLexer object before doing any scanning - with it has been fixed. - - - A problem with including FlexLexer.h multiple times has been fixed. - - - The alloca() chud necessary to accommodate bison has grown - even uglier, but hopefully more correct. - - - A portability tweak has been added to accommodate compilers that - use char* generic pointers. - - - EBCDIC contact information in the file MISC/EBCDIC has been updated. - - - An OS/2 Makefile and config.h for flex 2.5 is now available in - MISC/OS2/, contributed by Kai Uwe Rommel. - - - The descrip.mms file for building flex under VMS has been updated, - thanks to Pat Rankin. - - - The notes on building flex for the Amiga have been updated for - flex 2.5, contributed by Andreas Scherer. - - -Changes between release 2.5.1 (28Mar95) and release 2.4.7: - - - A new concept of "start condition" scope has been introduced. - A start condition scope is begun with: - - { - - where SCs is a list of one or more start conditions. Inside - the start condition scope, every rule automatically has the - prefix applied to it, until a '}' which matches the - initial '{'. So, for example: - - { - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - } - - is equivalent to: - - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - - As indicated in this example, rules inside start condition scopes - (and any rule, actually, other than the first) can be indented, - to better show the extent of the scope. - - Start condition scopes may be nested. - - - The new %option directive can be used in the first section of - a flex scanner to control scanner-generation options. Most - options are given simply as names, optionally preceded by the - word "no" (with no intervening whitespace) to negate their - meaning. Some are equivalent to flex flags, so putting them - in your scanner source is equivalent to always specifying - the flag (%option's take precedence over flags): - - 7bit -7 option - 8bit -8 option - align -Ca option - backup -b option - batch -B option - c++ -+ option - caseful opposite of -i option (caseful is the default); - case-sensitive same as above - caseless -i option; - case-insensitive same as above - debug -d option - default opposite of -s option - ecs -Ce option - fast -F option - full -f option - interactive -I option - lex-compat -l option - meta-ecs -Cm option - perf-report -p option - read -Cr option - stdout -t option - verbose -v option - warn opposite of -w option (so use "%option nowarn" for -w) - - array equivalent to "%array" - pointer equivalent to "%pointer" (default) - - Some provide new features: - - always-interactive generate a scanner which always - considers its input "interactive" (no call to isatty() - will be made when the scanner runs) - main supply a main program for the scanner, which - simply calls yylex(). Implies %option noyywrap. - never-interactive generate a scanner which never - considers its input "interactive" (no call to isatty() - will be made when the scanner runs) - stack if set, enable start condition stacks (see below) - stdinit if unset ("%option nostdinit"), initialize yyin - and yyout statically to nil FILE* pointers, instead - of stdin and stdout - yylineno if set, keep track of the current line - number in global yylineno (this option is expensive - in terms of performance). The line number is available - to C++ scanning objects via the new member function - lineno(). - yywrap if unset ("%option noyywrap"), scanner does not - call yywrap() upon EOF but simply assumes there - are no more files to scan - - Flex scans your rule actions to determine whether you use the - REJECT or yymore features (this is not new). Two %options can be - used to override its decision, either by setting them to indicate - the feature is indeed used, or unsetting them to indicate it - actually is not used: - - reject - yymore - - Three %option's take string-delimited values, offset with '=': - - outfile="" equivalent to -o - prefix="" equivalent to -P - yyclass="" set the name of the C++ scanning class - (see below) - - A number of %option's are available for lint purists who - want to suppress the appearance of unneeded routines in - the generated scanner. Each of the following, if unset, - results in the corresponding routine not appearing in the - generated scanner: - - input, unput - yy_push_state, yy_pop_state, yy_top_state - yy_scan_buffer, yy_scan_bytes, yy_scan_string - - You can specify multiple options with a single %option directive, - and multiple directives in the first section of your flex input file. - - - The new function: - - YY_BUFFER_STATE yy_scan_string( const char *str ) - - returns a YY_BUFFER_STATE (which also becomes the current input - buffer) for scanning the given string, which occurs starting - with the next call to yylex(). The string must be NUL-terminated. - A related function: - - YY_BUFFER_STATE yy_scan_bytes( const char *bytes, int len ) - - creates a buffer for scanning "len" bytes (including possibly NUL's) - starting at location "bytes". - - Note that both of these functions create and scan a *copy* of - the string/bytes. (This may be desirable, since yylex() modifies - the contents of the buffer it is scanning.) You can avoid the - copy by using: - - YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) - - which scans in place the buffer starting at "base", consisting - of "size" bytes, the last two bytes of which *must* be - YY_END_OF_BUFFER_CHAR (these bytes are not scanned; thus, scanning - consists of base[0] through base[size-2], inclusive). If you - fail to set up "base" in this manner, yy_scan_buffer returns a - nil pointer instead of creating a new input buffer. - - The type yy_size_t is an integral type to which you can cast - an integer expression reflecting the size of the buffer. - - - Three new routines are available for manipulating stacks of - start conditions: - - void yy_push_state( int new_state ) - - pushes the current start condition onto the top of the stack - and BEGIN's "new_state" (recall that start condition names are - also integers). - - void yy_pop_state() - - pops the top of the stack and BEGIN's to it, and - - int yy_top_state() - - returns the top of the stack without altering the stack's - contents. - - The start condition stack grows dynamically and so has no built-in - size limitation. If memory is exhausted, program execution - is aborted. - - To use start condition stacks, your scanner must include - a "%option stack" directive. - - - flex now supports POSIX character class expressions. These - are expressions enclosed inside "[:" and ":]" delimiters (which - themselves must appear between the '[' and ']' of a character - class; other elements may occur inside the character class, too). - The expressions flex recognizes are: - - [:alnum:] [:alpha:] [:blank:] [:cntrl:] [:digit:] [:graph:] - [:lower:] [:print:] [:punct:] [:space:] [:upper:] [:xdigit:] - - These expressions all designate a set of characters equivalent to - the corresponding isXXX function (for example, [:alnum:] designates - those characters for which isalnum() returns true - i.e., any - alphabetic or numeric). Some systems don't provide isblank(), - so flex defines [:blank:] as a blank or a tab. - - For example, the following character classes are all equivalent: - - [[:alnum:]] - [[:alpha:][:digit:] - [[:alpha:]0-9] - [a-zA-Z0-9] - - If your scanner is case-insensitive (-i flag), then [:upper:] - and [:lower:] are equivalent to [:alpha:]. - - - The promised rewrite of the C++ FlexLexer class has not yet - been done. Support for FlexLexer is limited at the moment to - fixing show-stopper bugs, so, for example, the new functions - yy_scan_string() & friends are not available to FlexLexer - objects. - - - The new macro - - yy_set_interactive(is_interactive) - - can be used to control whether the current buffer is considered - "interactive". An interactive buffer is processed more slowly, - but must be used when the scanner's input source is indeed - interactive to avoid problems due to waiting to fill buffers - (see the discussion of the -I flag in flex.1). A non-zero value - in the macro invocation marks the buffer as interactive, a zero - value as non-interactive. Note that use of this macro overrides - "%option always-interactive" or "%option never-interactive". - - yy_set_interactive() must be invoked prior to beginning to - scan the buffer. - - - The new macro - - yy_set_bol(at_bol) - - can be used to control whether the current buffer's scanning - context for the next token match is done as though at the - beginning of a line (non-zero macro argument; makes '^' anchored - rules active) or not at the beginning of a line (zero argument, - '^' rules inactive). - - - Related to this change, the mechanism for determining when a scan is - starting at the beginning of a line has changed. It used to be - that '^' was active iff the character prior to that at which the - scan started was a newline. The mechanism now is that '^' is - active iff the last token ended in a newline (or the last call to - input() returned a newline). For most users, the difference in - mechanisms is negligible. Where it will make a difference, - however, is if unput() or yyless() is used to alter the input - stream. When in doubt, use yy_set_bol(). - - - The new beginning-of-line mechanism involved changing some fairly - twisted code, so it may have introduced bugs - beware ... - - - The macro YY_AT_BOL() returns true if the next token scanned from - the current buffer will have '^' rules active, false otherwise. - - - The new function - - void yy_flush_buffer( struct yy_buffer_state* b ) - - flushes the contents of the current buffer (i.e., next time - the scanner attempts to match a token using b as the current - buffer, it will begin by invoking YY_INPUT to fill the buffer). - This routine is also available to C++ scanners (unlike some - of the other new routines). - - The related macro - - YY_FLUSH_BUFFER - - flushes the contents of the current buffer. - - - A new "-ooutput" option writes the generated scanner to "output". - If used with -t, the scanner is still written to stdout, but - its internal #line directives (see previous item) use "output". - - - Flex now generates #line directives relating the code it - produces to the output file; this means that error messages - in the flex-generated code should be correctly pinpointed. - - - When generating #line directives, filenames with embedded '\'s - have those characters escaped (i.e., turned into '\\'). This - feature helps with reporting filenames for some MS-DOS and OS/2 - systems. - - - The FlexLexer class includes two new public member functions: - - virtual void switch_streams( istream* new_in = 0, - ostream* new_out = 0 ) - - reassigns yyin to new_in (if non-nil) and yyout to new_out - (ditto), deleting the previous input buffer if yyin is - reassigned. It is used by: - - int yylex( istream* new_in = 0, ostream* new_out = 0 ) - - which first calls switch_streams() and then returns the value - of calling yylex(). - - - C++ scanners now have yy_flex_debug as a member variable of - FlexLexer rather than a global, and member functions for testing - and setting it. - - - When generating a C++ scanning class, you can now use - - %option yyclass="foo" - - to inform flex that you have derived "foo" as a subclass of - yyFlexLexer, so flex will place your actions in the member - function foo::yylex() instead of yyFlexLexer::yylex(). It also - generates a yyFlexLexer::yylex() member function that generates a - run-time error if called (by invoking yyFlexLexer::LexerError()). - This feature is necessary if your subclass "foo" introduces some - additional member functions or variables that you need to access - from yylex(). - - - Current texinfo files in MISC/texinfo, contributed by Francois - Pinard. - - - You can now change the name "flex" to something else (e.g., "lex") - by redefining $(FLEX) in the Makefile. - - - Two bugs (one serious) that could cause "bigcheck" to fail have - been fixed. - - - A number of portability/configuration changes have been made - for easier portability. - - - You can use "YYSTATE" in your scanner as an alias for YY_START - (for AT&T lex compatibility). - - - input() now maintains yylineno. - - - input() no longer trashes yytext. - - - interactive scanners now read characters in YY_INPUT up to a - newline, a large performance gain. - - - C++ scanner objects now work with the -P option. You include - once per scanner - see comments in - (or flex.1) for details. - - - C++ FlexLexer objects now use the "cerr" stream to report -d output - instead of stdio. - - - The -c flag now has its full glorious POSIX interpretation (do - nothing), rather than being interpreted as an old-style -C flag. - - - Scanners generated by flex now include two #define's giving - the major and minor version numbers (YY_FLEX_MAJOR_VERSION, - YY_FLEX_MINOR_VERSION). These can then be tested to see - whether certain flex features are available. - - - Scanners generated using -l lex compatibility now have the symbol - YY_FLEX_LEX_COMPAT #define'd. - - - When initializing (i.e., yy_init is non-zero on entry to yylex()), - generated scanners now set yy_init to zero before executing - YY_USER_INIT. This means that you can set yy_init back to a - non-zero value in YY_USER_INIT if you need the scanner to be - reinitialized on the next call. - - - You can now use "#line" directives in the first section of your - scanner specification. - - - When generating full-table scanners (-Cf), flex now puts braces - around each row of the 2-d array initialization, to silence warnings - on over-zealous compilers. - - - Improved support for MS-DOS. The flex sources have been successfully - built, unmodified, for Borland 4.02 (all that's required is a - Borland Makefile and config.h file, which are supplied in - MISC/Borland - contributed by Terrence O Kane). - - - Improved support for Macintosh using Think C - the sources should - build for this platform "out of the box". Contributed by Scott - Hofmann. - - - Improved support for VMS, in MISC/VMS/, contributed by Pat Rankin. - - - Support for the Amiga, in MISC/Amiga/, contributed by Andreas - Scherer. Note that the contributed files were developed for - flex 2.4 and have not been tested with flex 2.5. - - - Some notes on support for the NeXT, in MISC/NeXT, contributed - by Raf Schietekat. - - - The MISC/ directory now includes a preformatted version of flex.1 - in flex.man, and pre-yacc'd versions of parse.y in parse.{c,h}. - - - The flex.1 and flexdoc.1 manual pages have been merged. There - is now just one document, flex.1, which includes an overview - at the beginning to help you find the section you need. - - - Documentation now clarifies that start conditions persist across - switches to new input files or different input buffers. If you - want to e.g., return to INITIAL, you must explicitly do so. - - - The "Performance Considerations" section of the manual has been - updated. - - - Documented the "yy_act" variable, which when YY_USER_ACTION is - invoked holds the number of the matched rule, and added an - example of using yy_act to profile how often each rule is matched. - - - Added YY_NUM_RULES, a definition that gives the total number - of rules in the file, including the default rule (even if you - use -s). - - - Documentation now clarifies that you can pass a nil FILE* pointer - to yy_create_buffer() or yyrestart() if you've arrange YY_INPUT - to not need yyin. - - - Documentation now clarifies that YY_BUFFER_STATE is a pointer to - an opaque "struct yy_buffer_state". - - - Documentation now stresses that you gain the benefits of removing - backing-up states only if you remove *all* of them. - - - Documentation now points out that traditional lex allows you - to put the action on a separate line from the rule pattern if - the pattern has trailing whitespace (ugh!), but flex doesn't - support this. - - - A broken example in documentation of the difference between - inclusive and exclusive start conditions is now fixed. - - - Usage (-h) report now goes to stdout. - - - Version (-V) info now goes to stdout. - - - More #ifdef chud has been added to the parser in attempt to - deal with bison's use of alloca(). - - - "make clean" no longer deletes emacs backup files (*~). - - - Some memory leaks have been fixed. - - - A bug was fixed in which dynamically-expanded buffers were - reallocated a couple of bytes too small. - - - A bug was fixed which could cause flex to read and write beyond - the end of the input buffer. - - - -S will not be going away. - - -Changes between release 2.4.7 (03Aug94) and release 2.4.6: - - - Fixed serious bug in reading multiple files. - - - Fixed bug in scanning NUL's. - - - Fixed bug in input() returning 8-bit characters. - - - Fixed bug in matching text with embedded NUL's when - using %array or lex compatibility. - - - Fixed multiple invocations of YY_USER_ACTION when using '|' - continuation action. - - - Minor prototyping fixes. - -Changes between release 2.4.6 (04Jan94) and release 2.4.5: - - - Linking with -lfl no longer required if your program includes - its own yywrap() and main() functions. (This change will cause - problems if you have a non-ANSI compiler on a system for which - sizeof(int) != sizeof(void*) or sizeof(int) != sizeof(size_t).) - - - The use of 'extern "C++"' in FlexLexer.h has been modified to - get around an incompatibility with g++'s header files. - -Changes between release 2.4.5 (11Dec93) and release 2.4.4: - - - Fixed bug breaking C++ scanners that use REJECT or variable - trailing context. - - - Fixed serious input problem for interactive scanners on - systems for which char is unsigned. - - - Fixed bug in incorrectly treating '$' operator as variable - trailing context. - - - Fixed bug in -CF table representation that could lead to - corrupt tables. - - - Fixed fairly benign memory leak. - - - Added `extern "C++"' wrapper to FlexLexer.h header. This - should overcome the g++ 2.5.X problems mentioned in the - NEWS for release 2.4.3. - - - Changed #include of FlexLexer.h to use <> instead of "". - - - Added feature to control whether the scanner attempts to - refill the input buffer once it's exhausted. This feature - will be documented in the 2.5 release. - - -Changes between release 2.4.4 (07Dec93) and release 2.4.3: - - - Fixed two serious bugs in scanning 8-bit characters. - - - Fixed bug in YY_USER_ACTION that caused it to be executed - inappropriately (on the scanner's own internal actions, and - with incorrect yytext/yyleng values). - - - Fixed bug in pointing yyin at a new file and resuming scanning. - - - Portability fix regarding min/max/abs macros conflicting with - function definitions in standard header files. - - - Added a virtual LexerError() method to the C++ yyFlexLexer class - for reporting error messages instead of always using cerr. - - - Added warning in flexdoc that the C++ scanning class is presently - experimental and subject to considerable change between major - releases. - - -Changes between release 2.4.3 (03Dec93) and release 2.4.2: - - - Fixed bug causing fatal scanner messages to fail to print. - - - Fixed things so FlexLexer.h can be included in other C++ - sources. One side-effect of this change is that -+ and -CF - are now incompatible. - - - libfl.a now supplies private versions of the the / - string routines needed by flex and the scanners - it generates, to enhance portability to some BSD systems. - - - More robust solution to 2.4.2's flexfatal() bug fix. - - - Added ranlib of installed libfl.a. - - - Some lint tweaks. - - - NOTE: problems have been encountered attempting to build flex - C++ scanners using g++ version 2.5.X. The problem is due to an - unfortunate heuristic in g++ 2.5.X that attempts to discern between - C and C++ headers. Because FlexLexer.h is installed (by default) - in /usr/local/include and not /usr/local/lib/g++-include, g++ 2.5.X - decides that it's a C header :-(. So if you have problems, install - the header in /usr/local/lib/g++-include instead. - - -Changes between release 2.4.2 (01Dec93) and release 2.4.1: - - - Fixed bug in libfl.a referring to non-existent "flexfatal" function. - - - Modified to produce both compress'd and gzip'd tar files for - distributions (you probably don't care about this change!). - - -Changes between release 2.4.1 (30Nov93) and release 2.3.8: - - - The new '-+' flag instructs flex to generate a C++ scanner class - (thanks to Kent Williams). flex writes an implementation of the - class defined in FlexLexer.h to lex.yy.cc. You may include - multiple scanner classes in your program using the -P flag. Note - that the scanner class also provides a mechanism for creating - reentrant scanners. The scanner class uses C++ streams for I/O - instead of FILE*'s (thanks to Tom Epperly). If the flex executable's - name ends in '+' then the '-+' flag is automatically on, so creating - a symlink or copy of "flex" to "flex++" results in a version of - flex that can be used exclusively for C++ scanners. - - Note that without the '-+' flag, flex-generated scanners can still - be compiled using C++ compilers, though they use FILE*'s for I/O - instead of streams. - - See the "GENERATING C++ SCANNERS" section of flexdoc for details. - - - The new '-l' flag turns on maximum AT&T lex compatibility. In - particular, -l includes support for "yylineno" and makes yytext - be an array instead of a pointer. It does not, however, do away - with all incompatibilities. See the "INCOMPATIBILITIES WITH LEX - AND POSIX" section of flexdoc for details. - - - The new '-P' option specifies a prefix to use other than "yy" - for the scanner's globally-visible variables, and for the - "lex.yy.c" filename. Using -P you can link together multiple - flex scanners in the same executable. - - - The distribution includes a "texinfo" version of flexdoc.1, - contributed by Roland Pesch (thanks also to Marq Kole, who - contributed another version). It has not been brought up to - date, but reflects version 2.3. See MISC/flex.texinfo. - - The flex distribution will soon include G.T. Nicol's flex - manual; he is presently bringing it up-to-date for version 2.4. - - - yywrap() is now a function, and you now *must* link flex scanners - with libfl.a. - - - Site-configuration is now done via an autoconf-generated - "configure" script contributed by Francois Pinard. - - - Scanners now use fread() (or getc(), if interactive) and not - read() for input. A new "table compression" option, -Cr, - overrides this change and causes the scanner to use read() - (because read() is a bit faster than fread()). -f and -F - are now equivalent to -Cfr and -CFr; i.e., they imply the - -Cr option. - - - In the blessed name of POSIX compliance, flex supports "%array" - and "%pointer" directives in the definitions (first) section of - the scanner specification. The former specifies that yytext - should be an array (of size YYLMAX), the latter, that it should - be a pointer. The array version of yytext is universally slower - than the pointer version, but has the advantage that its contents - remain unmodified across calls to input() and unput() (the pointer - version of yytext is, still, trashed by such calls). - - "%array" cannot be used with the '-+' C++ scanner class option. - - - The new '-Ca' option directs flex to trade off memory for - natural alignment when generating a scanner's tables. In - particular, table entries that would otherwise be "short" - become "long". - - - The new '-h' option produces a summary of the flex flags. - - - The new '-V' option reports the flex version number and exits. - - - The new scanner macro YY_START returns an integer value - corresponding to the current start condition. You can return - to that start condition by passing the value to a subsequent - "BEGIN" action. You also can implement "start condition stacks" - by storing the values in an integer stack. - - - You can now redefine macros such as YY_INPUT by just #define'ing - them to some other value in the first section of the flex input; - no need to first #undef them. - - - flex now generates warnings for rules that can't be matched. - These warnings can be turned off using the new '-w' flag. If - your scanner uses REJECT then you will not get these warnings. - - - If you specify the '-s' flag but the default rule can be matched, - flex now generates a warning. - - - "yyleng" is now a global, and may be modified by the user (though - doing so and then using yymore() will yield weird results). - - - Name definitions in the first section of a scanner specification - can now include a leading '^' or trailing '$' operator. In this - case, the definition is *not* pushed back inside of parentheses. - - - Scanners with compressed tables are now "interactive" (-I option) - by default. You can suppress this attribute (which makes them - run slightly slower) using the new '-B' flag. - - - Flex now generates 8-bit scanners by default, unless you use the - -Cf or -CF compression options (-Cfe and -CFe result in 8-bit - scanners). You can force it to generate a 7-bit scanner using - the new '-7' flag. You can build flex to generate 8-bit scanners - for -Cf and -CF, too, by adding -DDEFAULT_CSIZE=256 to CFLAGS - in the Makefile. - - - You no longer need to call the scanner routine yyrestart() to - inform the scanner that you have switched to a new file after - having seen an EOF on the current input file. Instead, just - point yyin at the new file and continue scanning. - - - You no longer need to invoke YY_NEW_FILE in an <> action - to indicate you wish to continue scanning. Simply point yyin - at a new file. - - - A leading '#' no longer introduces a comment in a flex input. - - - flex no longer considers formfeed ('\f') a whitespace character. - - - %t, I'm happy to report, has been nuked. - - - The '-p' option may be given twice ('-pp') to instruct flex to - report minor performance problems as well as major ones. - - - The '-v' verbose output no longer includes start/finish time - information. - - - Newlines in flex inputs can optionally include leading or - trailing carriage-returns ('\r'), in support of several PC/Mac - run-time libraries that automatically include these. - - - A start condition of the form "<*>" makes the following rule - active in every start condition, whether exclusive or inclusive. - - - The following items have been corrected in the flex documentation: - - - '-C' table compression options *are* cumulative. - - - You may modify yytext but not lengthen it by appending - characters to the end. Modifying its final character - will affect '^' anchoring for the next rule matched - if the character is changed to or from a newline. - - - The term "backtracking" has been renamed "backing up", - since it is a one-time repositioning and not a repeated - search. What used to be the "lex.backtrack" file is now - "lex.backup". - - - Unindented "/* ... */" comments are allowed in the first - flex input section, but not in the second. - - - yyless() can only be used in the flex input source, not - externally. - - - You can use "yyrestart(yyin)" to throw away the - current contents of the input buffer. - - - To write high-speed scanners, attempt to match as much - text as possible with each rule. See MISC/fastwc/README - for more information. - - - Using the beginning-of-line operator ('^') is fairly - cheap. Using unput() is expensive. Using yyless() is - cheap. - - - An example of scanning strings with embedded escape - sequences has been added. - - - The example of backing-up in flexdoc was erroneous; it - has been corrected. - - - A flex scanner's internal buffer now dynamically grows if needed - to match large tokens. Note that growing the buffer presently - requires rescanning the (large) token, so consuming a lot of - text this way is a slow process. Also note that presently the - buffer does *not* grow if you unput() more text than can fit - into the buffer. - - - The MISC/ directory has been reorganized; see MISC/README for - details. - - - yyless() can now be used in the third (user action) section - of a scanner specification, thanks to Ceriel Jacobs. yyless() - remains a macro and cannot be used outside of the scanner source. - - - The skeleton file is no longer opened at run-time, but instead - compiled into a large string array (thanks to John Gilmore and - friends at Cygnus). You can still use the -S flag to point flex - at a different skeleton file. - - - flex no longer uses a temporary file to store the scanner's - actions. - - - A number of changes have been made to decrease porting headaches. - In particular, flex no longer uses memset() or ctime(), and - provides a single simple mechanism for dealing with C compilers - that still define malloc() as returning char* instead of void*. - - - Flex now detects if the scanner specification requires the -8 flag - but the flag was not given or on by default. - - - A number of table-expansion fencepost bugs have been fixed, - making flex more robust for generating large scanners. - - - flex more consistently identifies the location of errors in - its input. - - - YY_USER_ACTION is now invoked only for "real" actions, not for - internal actions used by the scanner for things like filling - the buffer or handling EOF. - - - The rule "[^]]" now matches any character other than a ']'; - formerly it matched any character at all followed by a ']'. - This change was made for compatibility with AT&T lex. - - - A large number of miscellaneous bugs have been found and fixed - thanks to Gerhard Wilhelms. - - - The source code has been heavily reformatted, making patches - relative to previous flex releases no longer accurate. - - -Changes between 2.3 Patch #8 (21Feb93) and 2.3 Patch #7: - - - Fixed bugs in dynamic memory allocation leading to grievous - fencepost problems when generating large scanners. - - Fixed bug causing infinite loops on character classes with 8-bit - characters in them. - - Fixed bug in matching repetitions with a lower bound of 0. - - Fixed bug in scanning NUL characters using an "interactive" scanner. - - Fixed bug in using yymore() at the end of a file. - - Fixed bug in misrecognizing rules with variable trailing context. - - Fixed bug compiling flex on Suns using gcc 2. - - Fixed bug in not recognizing that input files with the character - ASCII 128 in them require the -8 flag. - - Fixed bug that could cause an infinite loop writing out - error messages. - - Fixed bug in not recognizing old-style lex % declarations if - followed by a tab instead of a space. - - Fixed potential crash when flex terminated early (usually due - to a bad flag) and the -v flag had been given. - - Added some missing declarations of void functions. - - Changed to only use '\a' for __STDC__ compilers. - - Updated mailing addresses. - - -Changes between 2.3 Patch #7 (28Mar91) and 2.3 Patch #6: - - - Fixed out-of-bounds array access that caused bad tables - to be produced on machines where the bad reference happened - to yield a 1. This caused problems installing or running - flex on some Suns, in particular. - - -Changes between 2.3 Patch #6 (29Aug90) and 2.3 Patch #5: - - - Fixed a serious bug in yymore() which basically made it - completely broken. Thanks goes to Jean Christophe of - the Nethack development team for finding the problem - and passing along the fix. - - -Changes between 2.3 Patch #5 (16Aug90) and 2.3 Patch #4: - - - An up-to-date version of initscan.c so "make test" will - work after applying the previous patches - - -Changes between 2.3 Patch #4 (14Aug90) and 2.3 Patch #3: - - - Fixed bug in hexadecimal escapes which allowed only digits, - not letters, in escapes - - Fixed bug in previous "Changes" file! - - -Changes between 2.3 Patch #3 (03Aug90) and 2.3 Patch #2: - - - Correction to patch #2 for gcc compilation; thanks goes to - Paul Eggert for catching this. - - -Changes between 2.3 Patch #2 (02Aug90) and original 2.3 release: - - - Fixed (hopefully) headaches involving declaring malloc() - and free() for gcc, which defines __STDC__ but (often) doesn't - come with the standard include files such as . - Reordered #ifdef maze in the scanner skeleton in the hope of - getting the declarations right for cfront and g++, too. - - - Note that this patch supercedes patch #1 for release 2.3, - which was never announced but was available briefly for - anonymous ftp. - - -Changes between 2.3 (full) release of 28Jun90 and 2.2 (alpha) release: - -User-visible: - - - A lone <> rule (that is, one which is not qualified with - a list of start conditions) now specifies the EOF action for - *all* start conditions which haven't already had <> actions - given. To specify an end-of-file action for just the initial - state, use <>. - - - -d debug output is now contigent on the global yy_flex_debug - being set to a non-zero value, which it is by default. - - - A new macro, YY_USER_INIT, is provided for the user to specify - initialization action to be taken on the first call to the - scanner. This action is done before the scanner does its - own initialization. - - - yy_new_buffer() has been added as an alias for yy_create_buffer() - - - Comments beginning with '#' and extending to the end of the line - now work, but have been deprecated (in anticipation of making - flex recognize #line directives). - - - The funky restrictions on when semi-colons could follow the - YY_NEW_FILE and yyless macros have been removed. They now - behave identically to functions. - - - A bug in the sample redefinition of YY_INPUT in the documentation - has been corrected. - - - A bug in the sample simple tokener in the documentation has - been corrected. - - - The documentation on the incompatibilities between flex and - lex has been reordered so that the discussion of yylineno - and input() come first, as it's anticipated that these will - be the most common source of headaches. - - -Things which didn't used to be documented but now are: - - - flex interprets "^foo|bar" differently from lex. flex interprets - it as "match either a 'foo' or a 'bar', providing it comes at the - beginning of a line", whereas lex interprets it as "match either - a 'foo' at the beginning of a line, or a 'bar' anywhere". - - - flex initializes the global "yyin" on the first call to the - scanner, while lex initializes it at compile-time. - - - yy_switch_to_buffer() can be used in the yywrap() macro/routine. - - - flex scanners do not use stdio for their input, and hence when - writing an interactive scanner one must explictly call fflush() - after writing out a prompt. - - - flex scanner can be made reentrant (after a fashion) by using - "yyrestart( yyin );". This is useful for interactive scanners - which have interrupt handlers that long-jump out of the scanner. - - - a defense of why yylineno is not supported is included, along - with a suggestion on how to convert scanners which rely on it. - - -Other changes: - - - Prototypes and proper declarations of void routines have - been added to the flex source code, courtesy of Kevin B. Kenny. - - - Routines dealing with memory allocation now use void* pointers - instead of char* - see Makefile for porting implications. - - - Error-checking is now done when flex closes a file. - - - Various lint tweaks were added to reduce the number of gripes. - - - Makefile has been further parameterized to aid in porting. - - - Support for SCO Unix added. - - - Flex now sports the latest & greatest UC copyright notice - (which is only slightly different from the previous one). - - - A note has been added to flexdoc.1 mentioning work in progress - on modifying flex to generate straight C code rather than a - table-driven automaton, with an email address of whom to contact - if you are working along similar lines. - - -Changes between 2.2 Patch #3 (30Mar90) and 2.2 Patch #2: - - - fixed bug which caused -I scanners to bomb - - -Changes between 2.2 Patch #2 (27Mar90) and 2.2 Patch #1: - - - fixed bug writing past end of input buffer in yyunput() - - fixed bug detecting NUL's at the end of a buffer - - -Changes between 2.2 Patch #1 (23Mar90) and 2.2 (alpha) release: - - - Makefile fixes: definition of MAKE variable for systems - which don't have it; installation of flexdoc.1 along with - flex.1; fixed two bugs which could cause "bigtest" to fail. - - - flex.skel fix for compiling with g++. - - - README and flexdoc.1 no longer list an out-of-date BITNET address - for contacting me. - - - minor typos and formatting changes to flex.1 and flexdoc.1. - - -Changes between 2.2 (alpha) release of March '90 and previous release: - -User-visible: - - - Full user documentation now available. - - - Support for 8-bit scanners. - - - Scanners now accept NUL's. - - - A facility has been added for dealing with multiple - input buffers. - - - Two manual entries now. One which fully describes flex - (rather than just its differences from lex), and the - other for quick(er) reference. - - - A number of changes to bring flex closer into compliance - with the latest POSIX lex draft: - - %t support - flex now accepts multiple input files and concatenates - them together to form its input - previous -c (compress) flag renamed -C - do-nothing -c and -n flags added - Any indented code or code within %{}'s in section 2 is - now copied to the output - - - yyleng is now a bona fide global integer. - - - -d debug information now gives the line number of the - matched rule instead of which number rule it was from - the beginning of the file. - - - -v output now includes a summary of the flags used to generate - the scanner. - - - unput() and yyrestart() are now globally callable. - - - yyrestart() no longer closes the previous value of yyin. - - - C++ support; generated scanners can be compiled with C++ compiler. - - - Primitive -lfl library added, containing default main() - which calls yylex(). A number of routines currently living - in the scanner skeleton will probably migrate to here - in the future (in particular, yywrap() will probably cease - to be a macro and instead be a function in the -lfl library). - - - Hexadecimal (\x) escape sequences added. - - - Support for MS-DOS, VMS, and Turbo-C integrated. - - - The %used/%unused operators have been deprecated. They - may go away soon. - - -Other changes: - - - Makefile enhanced for easier testing and installation. - - The parser has been tweaked to detect some erroneous - constructions which previously were missed. - - Scanner input buffer overflow is now detected. - - Bugs with missing "const" declarations fixed. - - Out-of-date Minix/Atari patches provided. - - Scanners no longer require printf() unless FLEX_DEBUG is being used. - - A subtle input() bug has been fixed. - - Line numbers for "continued action" rules (those following - the special '|' action) are now correct. - - unput() bug fixed; had been causing problems porting flex to VMS. - - yymore() handling rewritten to fix bug with interaction - between yymore() and trailing context. - - EOF in actions now generates an error message. - - Bug involving -CFe and generating equivalence classes fixed. - - Bug which made -CF be treated as -Cf fixed. - - Support for SysV tmpnam() added. - - Unused #define's for scanner no longer generated. - - Error messages which are associated with a particular input - line are now all identified with their input line in standard - format. - - % directives which are valid to lex but not to flex are - now ignored instead of generating warnings. - - -DSYS_V flag can now also be specified -DUSG for System V - compilation. - - -Changes between 2.1 beta-test release of June '89 and previous release: - -User-visible: - - - -p flag generates a performance report to stderr. The report - consists of comments regarding features of the scanner rules - which result in slower scanners. - - - -b flag generates backtracking information to lex.backtrack. - This is a list of scanner states which require backtracking - and the characters on which they do so. By adding rules - one can remove backtracking states. If all backtracking states - are eliminated, the generated scanner will run faster. - Backtracking is not yet documented in the manual entry. - - - Variable trailing context now works, i.e., one can have - rules like "(foo)*/[ \t]*bletch". Some trailing context - patterns still cannot be properly matched and generate - error messages. These are patterns where the ending of the - first part of the rule matches the beginning of the second - part, such as "zx*/xy*", where the 'x*' matches the 'x' at - the beginning of the trailing context. Lex won't get these - patterns right either. - - - Faster scanners. - - - End-of-file rules. The special rule "<>" indicates - actions which are to be taken when an end-of-file is - encountered and yywrap() returns non-zero (i.e., indicates - no further files to process). See manual entry for example. - - - The -r (reject used) flag is gone. flex now scans the input - for occurrences of the string "REJECT" to determine if the - action is needed. It tries to be intelligent about this but - can be fooled. One can force the presence or absence of - REJECT by adding a line in the first section of the form - "%used REJECT" or "%unused REJECT". - - - yymore() has been implemented. Similarly to REJECT, flex - detects the use of yymore(), which can be overridden using - "%used" or "%unused". - - - Patterns like "x{0,3}" now work (i.e., with lower-limit == 0). - - - Removed '\^x' for ctrl-x misfeature. - - - Added '\a' and '\v' escape sequences. - - - \ now works for octal escape sequences; previously - \0 was required. - - - Better error reporting; line numbers are associated with rules. - - - yyleng is a macro; it cannot be accessed outside of the - scanner source file. - - - yytext and yyleng should not be modified within a flex action. - - - Generated scanners #define the name FLEX_SCANNER. - - - Rules are internally separated by YY_BREAK in lex.yy.c rather - than break, to allow redefinition. - - - The macro YY_USER_ACTION can be redefined to provide an action - which is always executed prior to the matched rule's action. - - - yyrestart() is a new action which can be used to restart - the scanner after it has seen an end-of-file (a "real" one, - that is, one for which yywrap() returned non-zero). It takes - a FILE* argument indicating a new file to scan and sets - things up so that a subsequent call to yylex() will start - scanning that file. - - - Internal scanner names all preceded by "yy_" - - - lex.yy.c is deleted if errors are encountered during processing. - - - Comments may be put in the first section of the input by preceding - them with '#'. - - - -Other changes: - - - Some portability-related bugs fixed, in particular for machines - with unsigned characters or sizeof( int* ) != sizeof( int ). - Also, tweaks for VMS and Microsoft C (MS-DOS), and identifiers all - trimmed to be 31 or fewer characters. Shortened file names - for dinosaur OS's. Checks for allocating > 64K memory - on 16 bit'ers. Amiga tweaks. Compiles using gcc on a Sun-3. - - Compressed and fast scanner skeletons merged. - - Skeleton header files done away with. - - Generated scanner uses prototypes and "const" for __STDC__. - - -DSV flag is now -DSYS_V for System V compilation. - - Removed all references to FTL language. - - Software now covered by BSD Copyright. - - flex will replace lex in subsequent BSD releases. diff --git a/third_party/lex/README.txt b/third_party/lex/README.txt deleted file mode 100644 index f7bd40b7..00000000 --- a/third_party/lex/README.txt +++ /dev/null @@ -1,2759 +0,0 @@ -FLEX(1) Cosmopolitan General Commands Manual -*-text-*- - -𝐍𝐀𝐌𝐄 - 𝗳𝗹𝗲𝘅, 𝗳𝗹𝗲𝘅++, 𝗹𝗲𝘅 — fast lexical analyzer generator - -𝐒𝐘𝐍𝐎𝐏𝐒𝐈𝐒 - 𝗳𝗹𝗲𝘅 [-𝟳𝟴𝐁𝗯𝗱𝐅𝗳𝗵𝐈𝗶𝐋𝗹𝗻𝗽𝘀𝐓𝘁𝐕𝘃𝘄+?] [-𝐂[𝗮𝗲𝐅𝗳𝗺𝗿]] [--𝗵𝗲𝗹𝗽] [--𝘃𝗲𝗿𝘀𝗶𝗼𝗻] - [-𝗼o̲u̲t̲p̲u̲t̲] [-𝐏p̲r̲e̲f̲i̲x̲] [-𝐒s̲k̲e̲l̲e̲t̲o̲n̲] [f̲i̲l̲e̲ .̲.̲.̲] - -𝐃𝐄𝐒𝐂𝐑𝐈𝐏𝐓𝐈𝐎𝐍 - 𝗳𝗹𝗲𝘅 is a tool for generating s̲c̲a̲n̲n̲e̲r̲s̲: programs which recognize - lexical patterns in text. 𝗳𝗹𝗲𝘅 reads the given input files, or its - standard input if no file names are given, for a description of a - scanner to generate. The description is in the form of pairs of - regular expressions and C code, called r̲u̲l̲e̲s̲. 𝗳𝗹𝗲𝘅 generates as - output a C source file, l̲e̲x̲.̲y̲y̲.̲c̲, which defines a routine 𝘆𝘆𝗹𝗲𝘅(). - This file is compiled and linked with the -𝗹𝗳𝗹 library to produce - an executable. When the executable is run, it analyzes its input - for occurrences of the regular expressions. Whenever it finds one, - it executes the corresponding C code. - - 𝗹𝗲𝘅 is a synonym for 𝗳𝗹𝗲𝘅. 𝗳𝗹𝗲𝘅++ is a synonym for 𝗳𝗹𝗲𝘅 -+. - - The manual includes both tutorial and reference sections: - - 𝐒𝗼𝗺𝗲 𝐒𝗶𝗺𝗽𝗹𝗲 𝐄𝘅𝗮𝗺𝗽𝗹𝗲𝘀 - - 𝐅𝗼𝗿𝗺𝗮𝘁 𝗼𝗳 𝘁𝗵𝗲 𝐈𝗻𝗽𝘂𝘁 𝐅𝗶𝗹𝗲 - - 𝐏𝗮𝘁𝘁𝗲𝗿𝗻𝘀 - The extended regular expressions used by 𝗳𝗹𝗲𝘅. - - 𝐇𝗼𝘄 𝘁𝗵𝗲 𝐈𝗻𝗽𝘂𝘁 𝗶𝘀 𝐌𝗮𝘁𝗰𝗵𝗲𝗱 - The rules for determining what has been matched. - - 𝐀𝗰𝘁𝗶𝗼𝗻𝘀 - How to specify what to do when a pattern is matched. - - 𝐓𝗵𝗲 𝐆𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 𝐒𝗰𝗮𝗻𝗻𝗲𝗿 - Details regarding the scanner that 𝗳𝗹𝗲𝘅 produces; how to control - the input source. - - 𝐒𝘁𝗮𝗿𝘁 𝐂𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀 - Introducing context into scanners, and managing "mini-scanners". - - 𝐌𝘂𝗹𝘁𝗶𝗽𝗹𝗲 𝐈𝗻𝗽𝘂𝘁 𝐁𝘂𝗳𝗳𝗲𝗿𝘀 - How to manipulate multiple input sources; how to scan from strings - instead of files. - - 𝐄𝗻𝗱-𝗼𝗳-𝐅𝗶𝗹𝗲 𝐑𝘂𝗹𝗲𝘀 - Special rules for matching the end of the input. - - 𝐌𝗶𝘀𝗰𝗲𝗹𝗹𝗮𝗻𝗲𝗼𝘂𝘀 𝐌𝗮𝗰𝗿𝗼𝘀 - A summary of macros available to the actions. - - 𝐕𝗮𝗹𝘂𝗲𝘀 𝐀𝘃𝗮𝗶𝗹𝗮𝗯𝗹𝗲 𝘁𝗼 𝘁𝗵𝗲 𝐔𝘀𝗲𝗿 - A summary of values available to the actions. - - 𝐈𝗻𝘁𝗲𝗿𝗳𝗮𝗰𝗶𝗻𝗴 𝘄𝗶𝘁𝗵 𝐘𝗮𝗰𝗰 - Connecting flex scanners together with yacc(1) parsers. - - 𝐎𝗽𝘁𝗶𝗼𝗻𝘀 - 𝗳𝗹𝗲𝘅 command-line options, and the “%option” directive. - - 𝐏𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝐂𝗼𝗻𝘀𝗶𝗱𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀 - How to make scanners go as fast as possible. - - 𝐆𝗲𝗻𝗲𝗿𝗮𝘁𝗶𝗻𝗴 𝐂++ 𝐒𝗰𝗮𝗻𝗻𝗲𝗿𝘀 - The (experimental) facility for generating C++ scanner classes. - - 𝐈𝗻𝗰𝗼𝗺𝗽𝗮𝘁𝗶𝗯𝗶𝗹𝗶𝘁𝗶𝗲𝘀 𝘄𝗶𝘁𝗵 𝐋𝗲𝘅 𝗮𝗻𝗱 𝐏𝐎𝐒𝐈𝐗 - How 𝗳𝗹𝗲𝘅 differs from AT&T UNIX 𝗹𝗲𝘅 and the POSIX 𝗹𝗲𝘅 standard. - - 𝐅𝗶𝗹𝗲𝘀 - Files used by 𝗳𝗹𝗲𝘅. - - 𝐃𝗶𝗮𝗴𝗻𝗼𝘀𝘁𝗶𝗰𝘀 - Those error messages produced by 𝗳𝗹𝗲𝘅 (or scanners it generates) - whose meanings might not be apparent. - - 𝐒𝗲𝗲 𝐀𝗹𝘀𝗼 - Other documentation, related tools. - - 𝐀𝘂𝘁𝗵𝗼𝗿𝘀 - Includes contact information. - - 𝐁𝘂𝗴𝘀 - Known problems with 𝗳𝗹𝗲𝘅. - -𝐒𝐎𝐌𝐄 𝐒𝐈𝐌𝐏𝐋𝐄 𝐄𝐗𝐀𝐌𝐏𝐋𝐄𝐒 - First some simple examples to get the flavor of how one uses 𝗳𝗹𝗲𝘅. - The following 𝗳𝗹𝗲𝘅 input specifies a scanner which whenever it - encounters the string "username" will replace it with the user's - login name: - - %% - username printf("%s", getlogin()); - - By default, any text not matched by a 𝗳𝗹𝗲𝘅 scanner is copied to the - output, so the net effect of this scanner is to copy its input file - to its output with each occurrence of "username" expanded. In this - input, there is just one rule. "username" is the p̲a̲t̲t̲e̲r̲n̲ and the - "printf" is the a̲c̲t̲i̲o̲n̲. The "%%" marks the beginning of the rules. - - Here's another simple example: - - %{ - int num_lines = 0, num_chars = 0; - %} - - %% - \n ++num_lines; ++num_chars; - . ++num_chars; - - %% - main() - { - yylex(); - printf("# of lines = %d, # of chars = %d\n", - num_lines, num_chars); - } - - This scanner counts the number of characters and the number of - lines in its input (it produces no output other than the final - report on the counts). The first line declares two globals, - "num_lines" and "num_chars", which are accessible both inside - 𝘆𝘆𝗹𝗲𝘅() and in the 𝗺𝗮𝗶𝗻() routine declared after the second "%%". - There are two rules, one which matches a newline ("\n") and incre‐ - ments both the line count and the character count, and one which - matches any character other than a newline (indicated by the "." - regular expression). - - A somewhat more complicated example: - - /* scanner for a toy Pascal-like language */ - - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - %% - - {DIGIT}+ { - printf("An integer: %s (%d)\n", yytext, - atoi(yytext)); - } - - {DIGIT}+"."{DIGIT}* { - printf("A float: %s (%g)\n", yytext, - atof(yytext)); - } - - if|then|begin|end|procedure|function { - printf("A keyword: %s\n", yytext); - } - - {ID} printf("An identifier: %s\n", yytext); - - "+"|"-"|"*"|"/" printf("An operator: %s\n", yytext); - - "{"[^}\n]*"}" /* eat up one-line comments */ - - [ \t\n]+ /* eat up whitespace */ - - . printf("Unrecognized character: %s\n", yytext); - - %% - - main(int argc, char *argv[]) - { - ++argv; --argc; /* skip over program name */ - if (argc > 0) - yyin = fopen(argv[0], "r"); - else - yyin = stdin; - - yylex(); - } - - This is the beginnings of a simple scanner for a language like Pas‐ - cal. It identifies different types of t̲o̲k̲e̲n̲s̲ and reports on what - it has seen. - - The details of this example will be explained in the following sec‐ - tions. - -𝐅𝐎𝐑𝐌𝐀𝐓 𝐎𝐅 𝐓𝐇𝐄 𝐈𝐍𝐏𝐔𝐓 𝐅𝐈𝐋𝐄 - The 𝗳𝗹𝗲𝘅 input file consists of three sections, separated by a line - with just "%%" in it: - - definitions - %% - rules - %% - user code - - The d̲e̲f̲i̲n̲i̲t̲i̲o̲n̲s̲ section contains declarations of simple n̲a̲m̲e̲ defi‐ - nitions to simplify the scanner specification, and declarations of - s̲t̲a̲r̲t̲ c̲o̲n̲d̲i̲t̲i̲o̲n̲s̲, which are explained in a later section. - - Name definitions have the form: - - name definition - - The "name" is a word beginning with a letter or an underscore (‘_’) - followed by zero or more letters, digits, ‘_’, or ‘-’ (dash). The - definition is taken to begin at the first non-whitespace character - following the name and continuing to the end of the line. The def‐ - inition can subsequently be referred to using "{name}", which will - expand to "(definition)". For example: - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - This defines "DIGIT" to be a regular expression which matches a - single digit, and "ID" to be a regular expression which matches a - letter followed by zero-or-more letters-or-digits. A subsequent - reference to - - {DIGIT}+"."{DIGIT}* - - is identical to - - ([0-9])+"."([0-9])* - - and matches one-or-more digits followed by a ‘.’ followed by zero- - or-more digits. - - The r̲u̲l̲e̲s̲ section of the 𝗳𝗹𝗲𝘅 input contains a series of rules of - the form: - - pattern action - - The pattern must be unindented and the action must begin on the - same line. - - See below for a further description of patterns and actions. - - Finally, the user code section is simply copied to l̲e̲x̲.̲y̲y̲.̲c̲ verba‐ - tim. It is used for companion routines which call or are called by - the scanner. The presence of this section is optional; if it is - missing, the second "%%" in the input file may be skipped too. - - In the definitions and rules sections, any indented text or text - enclosed in ‘%{’ and ‘%}’ is copied verbatim to the output (with - the %{}'s removed). The %{}'s must appear unindented on lines by - themselves. - - In the rules section, any indented or %{} text appearing before the - first rule may be used to declare variables which are local to the - scanning routine and (after the declarations) code which is to be - executed whenever the scanning routine is entered. Other indented - or %{} text in the rule section is still copied to the output, but - its meaning is not well-defined and it may well cause compile-time - errors (this feature is present for POSIX compliance; see below for - other such features). - - In the definitions section (but not in the rules section), an unin‐ - dented comment (i.e., a line beginning with "/*") is also copied - verbatim to the output up to the next "*/". - -𝐏𝐀𝐓𝐓𝐄𝐑𝐍𝐒 - The patterns in the input are written using an extended set of reg‐ - ular expressions. These are: - - x Match the character ‘x’. - - . Any character (byte) except newline. - - [xyz] A "character class"; in this case, the pattern matches - either an ‘x’, a ‘y’, or a ‘z’. - - [abj-oZ] A "character class" with a range in it; matches an ‘a’, a - ‘b’, any letter from ‘j’ through ‘o’, or a ‘Z’. - - [^A-Z] A "negated character class", i.e., any character but - those in the class. In this case, any character EXCEPT - an uppercase letter. - - [^A-Z\n] Any character EXCEPT an uppercase letter or a newline. - - r* Zero or more r's, where ‘r’ is any regular expression. - - r+ One or more r's. - - r? Zero or one r's (that is, "an optional r"). - - r{2,5} Anywhere from two to five r's. - - r{2,} Two or more r's. - - r{4} Exactly 4 r's. - - {name} The expansion of the "name" definition (see above). - - "[xyz]\"foo" - The literal string: [xyz]"foo. - - \X If ‘X’ is an ‘a’, ‘b’, ‘f’, ‘n’, ‘r’, ‘t’, or ‘v’, then - the ANSI-C interpretation of ‘\X’. Otherwise, a literal - ‘X’ (used to escape operators such as ‘*’). - - \0 A NUL character (ASCII code 0). - - \123 The character with octal value 123. - - \x2a The character with hexadecimal value 2a. - - (r) Match an ‘r’; parentheses are used to override precedence - (see below). - - rs The regular expression ‘r’ followed by the regular - expression ‘s’; called "concatenation". - - r|s Either an ‘r’ or an ‘s’. - - r/s An ‘r’, but only if it is followed by an ‘s’. The text - matched by ‘s’ is included when determining whether this - rule is the "longest match", but is then returned to the - input before the action is executed. So the action only - sees the text matched by ‘r’. This type of pattern is - called "trailing context". (There are some combinations - of r/s that 𝗳𝗹𝗲𝘅 cannot match correctly; see notes in the - B̲U̲G̲S̲ section below regarding "dangerous trailing - context".) - - ^r An ‘r’, but only at the beginning of a line (i.e., just - starting to scan, or right after a newline has been - scanned). - - r$ An ‘r’, but only at the end of a line (i.e., just before - a newline). Equivalent to "r/\n". - - Note that 𝗳𝗹𝗲𝘅's notion of "newline" is exactly whatever - the C compiler used to compile 𝗳𝗹𝗲𝘅 interprets ‘\n’ as. - - r An ‘r’, but only in start condition ‘s’ (see below for - discussion of start conditions). - - r - The same, but in any of start conditions s1, s2, or s3. - - <*>r An ‘r’ in any start condition, even an exclusive one. - - <> An end-of-file. - - <> - An end-of-file when in start condition s1 or s2. - - Note that inside of a character class, all regular expression oper‐ - ators lose their special meaning except escape (‘\’) and the char‐ - acter class operators, ‘-’, ‘]’, and, at the beginning of the - class, ‘^’. - - The regular expressions listed above are grouped according to - precedence, from highest precedence at the top to lowest at the - bottom. Those grouped together have equal precedence. For exam‐ - ple, - - foo|bar* - - is the same as - - (foo)|(ba(r*)) - - since the ‘*’ operator has higher precedence than concatenation, - and concatenation higher than alternation (‘|’). This pattern - therefore matches e̲i̲t̲h̲e̲r̲ the string "foo" o̲r̲ the string "ba" fol‐ - lowed by zero-or-more r's. To match "foo" or zero-or-more "bar"'s, - use: - - foo|(bar)* - - and to match zero-or-more "foo"'s-or-"bar"'s: - - (foo|bar)* - - In addition to characters and ranges of characters, character - classes can also contain character class e̲x̲p̲r̲e̲s̲s̲i̲o̲n̲s̲. These are - expressions enclosed inside ‘[:’ and ‘:]’ delimiters (which them‐ - selves must appear between the ‘[’ and ‘]’ of the character class; - other elements may occur inside the character class, too). The - valid expressions are: - - [:alnum:] [:alpha:] [:blank:] - [:cntrl:] [:digit:] [:graph:] - [:lower:] [:print:] [:punct:] - [:space:] [:upper:] [:xdigit:] - - These expressions all designate a set of characters equivalent to - the corresponding standard C 𝗶𝘀𝐗𝐗𝐗() function. For example, - [:alnum:] designates those characters for which isalnum(3) returns - true - i.e., any alphabetic or numeric. Some systems don't provide - isblank(3), so 𝗳𝗹𝗲𝘅 defines [:blank:] as a blank or a tab. - - For example, the following character classes are all equivalent: - - [[:alnum:]] - [[:alpha:][:digit:]] - [[:alpha:]0-9] - [a-zA-Z0-9] - - If the scanner is case-insensitive (the -𝗶 flag), then [:upper:] - and [:lower:] are equivalent to [:alpha:]. - - Some notes on patterns: - - - A negated character class such as the example "[^A-Z]" above - will match a newline unless "\n" (or an equivalent escape - sequence) is one of the characters explicitly present in the - negated character class (e.g., "[^A-Z\n]"). This is unlike how - many other regular expression tools treat negated character - classes, but unfortunately the inconsistency is historically - entrenched. Matching newlines means that a pattern like - "[^"]*" can match the entire input unless there's another quote - in the input. - - - A rule can have at most one instance of trailing context (the - ‘/’ operator or the ‘$’ operator). The start condition, ‘^’, - and "<>" patterns can only occur at the beginning of a - pattern and, as well as with ‘/’ and ‘$’, cannot be grouped - inside parentheses. A ‘^’ which does not occur at the begin‐ - ning of a rule or a ‘$’ which does not occur at the end of a - rule loses its special properties and is treated as a normal - character. - - - The following are illegal: - - foo/bar$ - foobar - - Note that the first of these, can be written "foo/bar\n". - - - The following will result in ‘$’ or ‘^’ being treated as a nor‐ - mal character: - - foo|(bar$) - foo|^bar - - If what's wanted is a "foo" or a bar-followed-by-a-newline, the - following could be used (the special ‘|’ action is explained - below): - - foo | - bar$ /* action goes here */ - - A similar trick will work for matching a foo or a bar-at-the- - beginning-of-a-line. - -𝐇𝐎𝐖 𝐓𝐇𝐄 𝐈𝐍𝐏𝐔𝐓 𝐈𝐒 𝐌𝐀𝐓𝐂𝐇𝐄𝐃 - When the generated scanner is run, it analyzes its input looking - for strings which match any of its patterns. If it finds more than - one match, it takes the one matching the most text (for trailing - context rules, this includes the length of the trailing part, even - though it will then be returned to the input). If it finds two or - more matches of the same length, the rule listed first in the 𝗳𝗹𝗲𝘅 - input file is chosen. - - Once the match is determined, the text corresponding to the match - (called the t̲o̲k̲e̲n̲) is made available in the global character - pointer y̲y̲t̲e̲x̲t̲, and its length in the global integer y̲y̲l̲e̲n̲g̲. The - a̲c̲t̲i̲o̲n̲ corresponding to the matched pattern is then executed (a - more detailed description of actions follows), and then the remain‐ - ing input is scanned for another match. - - If no match is found, then the default rule is executed: the next - character in the input is considered matched and copied to the - standard output. Thus, the simplest legal 𝗳𝗹𝗲𝘅 input is: - - %% - - which generates a scanner that simply copies its input (one - character at a time) to its output. - - Note that y̲y̲t̲e̲x̲t̲ can be defined in two different ways: either as a - character pointer or as a character array. Which definition 𝗳𝗹𝗲𝘅 - uses can be controlled by including one of the special directives - “%pointer” or “%array” in the first (definitions) section of flex - input. The default is “%pointer”, unless the -𝗹 𝗹𝗲𝘅 compatibility - option is used, in which case y̲y̲t̲e̲x̲t̲ will be an array. The advan‐ - tage of using “%pointer” is substantially faster scanning and no - buffer overflow when matching very large tokens (unless not enough - dynamic memory is available). The disadvantage is that actions are - restricted in how they can modify y̲y̲t̲e̲x̲t̲ (see the next section), - and calls to the 𝘂𝗻𝗽𝘂𝘁() function destroy the present contents of - y̲y̲t̲e̲x̲t̲, which can be a considerable porting headache when moving - between different 𝗹𝗲𝘅 versions. - - The advantage of “%array” is that y̲y̲t̲e̲x̲t̲ can be modified as much as - wanted, and calls to 𝘂𝗻𝗽𝘂𝘁() do not destroy y̲y̲t̲e̲x̲t̲ (see below). - Furthermore, existing 𝗹𝗲𝘅 programs sometimes access y̲y̲t̲e̲x̲t̲ exter‐ - nally using declarations of the form: - - extern char yytext[]; - - This definition is erroneous when used with “%pointer”, but correct - for “%array”. - - “%array” defines y̲y̲t̲e̲x̲t̲ to be an array of YYLMAX characters, which - defaults to a fairly large value. The size can be changed by sim‐ - ply #define'ing YYLMAX to a different value in the first section of - 𝗳𝗹𝗲𝘅 input. As mentioned above, with “%pointer” yytext grows - dynamically to accommodate large tokens. While this means a - “%pointer” scanner can accommodate very large tokens (such as - matching entire blocks of comments), bear in mind that each time - the scanner must resize y̲y̲t̲e̲x̲t̲ it also must rescan the entire token - from the beginning, so matching such tokens can prove slow. y̲y̲t̲e̲x̲t̲ - presently does not dynamically grow if a call to 𝘂𝗻𝗽𝘂𝘁() results in - too much text being pushed back; instead, a run-time error results. - - Also note that “%array” cannot be used with C++ scanner classes - (the c++ option; see below). - -𝐀𝐂𝐓𝐈𝐎𝐍𝐒 - Each pattern in a rule has a corresponding action, which can be any - arbitrary C statement. The pattern ends at the first non-escaped - whitespace character; the remainder of the line is its action. If - the action is empty, then when the pattern is matched the input - token is simply discarded. For example, here is the specification - for a program which deletes all occurrences of "zap me" from its - input: - - %% - "zap me" - - (It will copy all other characters in the input to the output since - they will be matched by the default rule.) - - Here is a program which compresses multiple blanks and tabs down to - a single blank, and throws away whitespace found at the end of a - line: - - %% - [ \t]+ putchar(' '); - [ \t]+$ /* ignore this token */ - - If the action contains a ‘{’, then the action spans till the bal‐ - ancing ‘}’ is found, and the action may cross multiple lines. 𝗳𝗹𝗲𝘅 - knows about C strings and comments and won't be fooled by braces - found within them, but also allows actions to begin with ‘%{’ and - will consider the action to be all the text up to the next ‘%}’ - (regardless of ordinary braces inside the action). - - An action consisting solely of a vertical bar (‘|’) means "same as - the action for the next rule". See below for an illustration. - - Actions can include arbitrary C code, including return statements - to return a value to whatever routine called 𝘆𝘆𝗹𝗲𝘅(). Each time - 𝘆𝘆𝗹𝗲𝘅() is called, it continues processing tokens from where it - last left off until it either reaches the end of the file or exe‐ - cutes a return. - - Actions are free to modify y̲y̲t̲e̲x̲t̲ except for lengthening it (adding - characters to its end - these will overwrite later characters in - the input stream). This, however, does not apply when using - “%array” (see above); in that case, y̲y̲t̲e̲x̲t̲ may be freely modified - in any way. - - Actions are free to modify y̲y̲l̲e̲n̲g̲ except they should not do so if - the action also includes use of 𝘆𝘆𝗺𝗼𝗿𝗲() (see below). - - There are a number of special directives which can be included - within an action: - - ECHO Copies y̲y̲t̲e̲x̲t̲ to the scanner's output. - - BEGIN Followed by the name of a start condition, places the scan‐ - ner in the corresponding start condition (see below). - - REJECT Directs the scanner to proceed on to the "second best" rule - which matched the input (or a prefix of the input). The - rule is chosen as described above in H̲O̲W̲ T̲H̲E̲ I̲N̲P̲U̲T̲ I̲S̲ - M̲A̲T̲C̲H̲E̲D̲, and y̲y̲t̲e̲x̲t̲ and y̲y̲l̲e̲n̲g̲ set up appropriately. It - may either be one which matched as much text as the origi‐ - nally chosen rule but came later in the 𝗳𝗹𝗲𝘅 input file, or - one which matched less text. For example, the following - will both count the words in the input and call the routine - 𝘀𝗽𝗲𝗰𝗶𝗮𝗹() whenever "frob" is seen: - - int word_count = 0; - %% - - frob special(); REJECT; - [^ \t\n]+ ++word_count; - - Without the R̲E̲J̲E̲C̲T̲, any "frob"'s in the input would not be - counted as words, since the scanner normally executes only - one action per token. Multiple R̲E̲J̲E̲C̲T̲'s are allowed, each - one finding the next best choice to the currently active - rule. For example, when the following scanner scans the - token "abcd", it will write "abcdabcaba" to the output: - - %% - a | - ab | - abc | - abcd ECHO; REJECT; - .|\n /* eat up any unmatched character */ - - (The first three rules share the fourth's action since they - use the special ‘|’ action.) R̲E̲J̲E̲C̲T̲ is a particularly - expensive feature in terms of scanner performance; if it is - used in any of the scanner's actions it will slow down all - of the scanner's matching. Furthermore, R̲E̲J̲E̲C̲T̲ cannot be - used with the -𝐂𝗳 or -𝐂𝐅 options (see below). - - Note also that unlike the other special actions, R̲E̲J̲E̲C̲T̲ is - a b̲r̲a̲n̲c̲h̲; code immediately following it in the action will - not be executed. - - yymore() - Tells the scanner that the next time it matches a rule, the - corresponding token should be appended onto the current - value of y̲y̲t̲e̲x̲t̲ rather than replacing it. For example, - given the input "mega-kludge" the following will write - "mega-mega-kludge" to the output: - - %% - mega- ECHO; yymore(); - kludge ECHO; - - First "mega-" is matched and echoed to the output. Then - "kludge" is matched, but the previous "mega-" is still - hanging around at the beginning of y̲y̲t̲e̲x̲t̲ so the E̲C̲H̲O̲ for - the "kludge" rule will actually write "mega-kludge". - - Two notes regarding use of 𝘆𝘆𝗺𝗼𝗿𝗲(): First, 𝘆𝘆𝗺𝗼𝗿𝗲() - depends on the value of y̲y̲l̲e̲n̲g̲ correctly reflecting the - size of the current token, so y̲y̲l̲e̲n̲g̲ must not be modified - when using 𝘆𝘆𝗺𝗼𝗿𝗲(). Second, the presence of 𝘆𝘆𝗺𝗼𝗿𝗲() in - the scanner's action entails a minor performance penalty in - the scanner's matching speed. - - yyless(n) - Returns all but the first n̲ characters of the current token - back to the input stream, where they will be rescanned when - the scanner looks for the next match. y̲y̲t̲e̲x̲t̲ and y̲y̲l̲e̲n̲g̲ - are adjusted appropriately (e.g., y̲y̲l̲e̲n̲g̲ will now be equal - to n̲). For example, on the input "foobar" the following - will write out "foobarbar": - - %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; - - An argument of 0 to y̲y̲l̲e̲s̲s̲ will cause the entire current - input string to be scanned again. Unless how the scanner - will subsequently process its input has been changed (using - B̲E̲G̲I̲N̲, for example), this will result in an endless loop. - - Note that y̲y̲l̲e̲s̲s̲ is a macro and can only be used in the - 𝗳𝗹𝗲𝘅 input file, not from other source files. - - unput(c) - Puts the character c̲ back into the input stream. It will - be the next character scanned. The following action will - take the current token and cause it to be rescanned - enclosed in parentheses. - - { - int i; - char *yycopy; - - /* Copy yytext because unput() trashes yytext */ - if ((yycopy = strdup(yytext)) == NULL) - err(1, NULL); - unput(')'); - for (i = yyleng - 1; i >= 0; --i) - unput(yycopy[i]); - unput('('); - free(yycopy); - } - - Note that since each 𝘂𝗻𝗽𝘂𝘁() puts the given character back - at the beginning of the input stream, pushing back strings - must be done back-to-front. - - An important potential problem when using 𝘂𝗻𝗽𝘂𝘁() is that - if using “%pointer” (the default), a call to 𝘂𝗻𝗽𝘂𝘁() - destroys the contents of y̲y̲t̲e̲x̲t̲, starting with its right‐ - most character and devouring one character to the left with - each call. If the value of y̲y̲t̲e̲x̲t̲ should be preserved - after a call to 𝘂𝗻𝗽𝘂𝘁() (as in the above example), it must - either first be copied elsewhere, or the scanner must be - built using “%array” instead (see H̲O̲W̲ T̲H̲E̲ I̲N̲P̲U̲T̲ I̲S̲ - M̲A̲T̲C̲H̲E̲D̲). - - Finally, note that EOF cannot be put back to attempt to - mark the input stream with an end-of-file. - - input() - Reads the next character from the input stream. For exam‐ - ple, the following is one way to eat up C comments: - - %% - "/*" { - int c; - - for (;;) { - while ((c = input()) != '*' && c != EOF) - ; /* eat up text of comment */ - - if (c == '*') { - while ((c = input()) == '*') - ; - if (c == '/') - break; /* found the end */ - } - - if (c == EOF) { - errx(1, "EOF in comment"); - break; - } - } - } - - (Note that if the scanner is compiled using C++, then - 𝗶𝗻𝗽𝘂𝘁() is instead referred to as 𝘆𝘆𝗶𝗻𝗽𝘂𝘁(), in order to - avoid a name clash with the C++ stream by the name of - input.) - - YY_FLUSH_BUFFER - Flushes the scanner's internal buffer so that the next time - the scanner attempts to match a token, it will first refill - the buffer using YY_INPUT (see T̲H̲E̲ G̲E̲N̲E̲R̲A̲T̲E̲D̲ S̲C̲A̲N̲N̲E̲R̲, - below). This action is a special case of the more general - 𝘆𝘆_𝗳𝗹𝘂𝘀𝗵_𝗯𝘂𝗳𝗳𝗲𝗿() function, described below in the section - M̲U̲L̲T̲I̲P̲L̲E̲ I̲N̲P̲U̲T̲ B̲U̲F̲F̲E̲R̲S̲. - - yyterminate() - Can be used in lieu of a return statement in an action. It - terminates the scanner and returns a 0 to the scanner's - caller, indicating "all done". By default, 𝘆𝘆𝘁𝗲𝗿𝗺𝗶𝗻𝗮𝘁𝗲() - is also called when an end-of-file is encountered. It is a - macro and may be redefined. - -𝐓𝐇𝐄 𝐆𝐄𝐍𝐄𝐑𝐀𝐓𝐄𝐃 𝐒𝐂𝐀𝐍𝐍𝐄𝐑 - The output of 𝗳𝗹𝗲𝘅 is the file l̲e̲x̲.̲y̲y̲.̲c̲, which contains the scan‐ - ning routine 𝘆𝘆𝗹𝗲𝘅(), a number of tables used by it for matching - tokens, and a number of auxiliary routines and macros. By default, - 𝘆𝘆𝗹𝗲𝘅() is declared as follows: - - int yylex() - { - ... various definitions and the actions in here ... - } - - (If the environment supports function prototypes, then it will be - "int yylex(void)".) This definition may be changed by defining the - YY_DECL macro. For example: - - #define YY_DECL float lexscan(a, b) float a, b; - - would give the scanning routine the name l̲e̲x̲s̲c̲a̲n̲, returning a - float, and taking two floats as arguments. Note that if arguments - are given to the scanning routine using a K&R-style/non-prototyped - function declaration, the definition must be terminated with a - semi-colon (‘;’). - - Whenever 𝘆𝘆𝗹𝗲𝘅() is called, it scans tokens from the global input - file y̲y̲i̲n̲ (which defaults to stdin). It continues until it either - reaches an end-of-file (at which point it returns the value 0) or - one of its actions executes a r̲e̲t̲u̲r̲n̲ statement. - - If the scanner reaches an end-of-file, subsequent calls are unde‐ - fined unless either y̲y̲i̲n̲ is pointed at a new input file (in which - case scanning continues from that file), or 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() is called. - 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() takes one argument, a F̲I̲L̲E̲ *̲ pointer (which can be nil, - if YY_INPUT has been set up to scan from a source other than y̲y̲i̲n̲), - and initializes y̲y̲i̲n̲ for scanning from that file. Essentially - there is no difference between just assigning y̲y̲i̲n̲ to a new input - file or using 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() to do so; the latter is available for - compatibility with previous versions of 𝗳𝗹𝗲𝘅, and because it can be - used to switch input files in the middle of scanning. It can also - be used to throw away the current input buffer, by calling it with - an argument of y̲y̲i̲n̲; but better is to use YY_FLUSH_BUFFER (see - above). Note that 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() does not reset the start condition - to I̲N̲I̲T̲I̲A̲L̲ (see S̲T̲A̲R̲T̲ C̲O̲N̲D̲I̲T̲I̲O̲N̲S̲, below). - - If 𝘆𝘆𝗹𝗲𝘅() stops scanning due to executing a r̲e̲t̲u̲r̲n̲ statement in - one of the actions, the scanner may then be called again and it - will resume scanning where it left off. - - By default (and for purposes of efficiency), the scanner uses - block-reads rather than simple getc(3) calls to read characters - from y̲y̲i̲n̲. The nature of how it gets its input can be controlled - by defining the YY_INPUT macro. YY_INPUT's calling sequence is - "YY_INPUT(buf,result,max_size)". Its action is to place up to - max_size characters in the character array b̲u̲f̲ and return in the - integer variable r̲e̲s̲u̲l̲t̲ either the number of characters read or the - constant YY_NULL (0 on UNIX systems) to indicate EOF. The default - YY_INPUT reads from the global file-pointer "yyin". - - A sample definition of YY_INPUT (in the definitions section of the - input file): - - %{ - #define YY_INPUT(buf,result,max_size) \ - { \ - int c = getchar(); \ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ - } - %} - - This definition will change the input processing to occur one char‐ - acter at a time. - - When the scanner receives an end-of-file indication from YY_INPUT, - it then checks the 𝘆𝘆𝘄𝗿𝗮𝗽() function. If 𝘆𝘆𝘄𝗿𝗮𝗽() returns false - (zero), then it is assumed that the function has gone ahead and set - up y̲y̲i̲n̲ to point to another input file, and scanning continues. If - it returns true (non-zero), then the scanner terminates, returning - 0 to its caller. Note that in either case, the start condition - remains unchanged; it does not revert to I̲N̲I̲T̲I̲A̲L̲. - - If you do not supply your own version of 𝘆𝘆𝘄𝗿𝗮𝗽(), then you must - either use “%option noyywrap” (in which case the scanner behaves as - though 𝘆𝘆𝘄𝗿𝗮𝗽() returned 1), or you must link with -𝗹𝗳𝗹 to obtain - the default version of the routine, which always returns 1. - - Three routines are available for scanning from in-memory buffers - rather than files: 𝘆𝘆_𝘀𝗰𝗮𝗻_𝘀𝘁𝗿𝗶𝗻𝗴(), 𝘆𝘆_𝘀𝗰𝗮𝗻_𝗯𝘆𝘁𝗲𝘀(), and - 𝘆𝘆_𝘀𝗰𝗮𝗻_𝗯𝘂𝗳𝗳𝗲𝗿(). See the discussion of them below in the section - M̲U̲L̲T̲I̲P̲L̲E̲ I̲N̲P̲U̲T̲ B̲U̲F̲F̲E̲R̲S̲. - - The scanner writes its E̲C̲H̲O̲ output to the y̲y̲o̲u̲t̲ global (default, - stdout), which may be redefined by the user simply by assigning it - to some other F̲I̲L̲E̲ pointer. - -𝐒𝐓𝐀𝐑𝐓 𝐂𝐎𝐍𝐃𝐈𝐓𝐈𝐎𝐍𝐒 - 𝗳𝗹𝗲𝘅 provides a mechanism for conditionally activating rules. Any - rule whose pattern is prefixed with "⟨sc⟩" will only be active when - the scanner is in the start condition named "sc". For example, - - [^"]* { /* eat up the string body ... */ - ... - } - - will be active only when the scanner is in the "STRING" start con‐ - dition, and - - \. { /* handle an escape ... */ - ... - } - - will be active only when the current start condition is either - "INITIAL", "STRING", or "QUOTE". - - Start conditions are declared in the definitions (first) section of - the input using unindented lines beginning with either ‘%s’ or ‘%x’ - followed by a list of names. The former declares i̲n̲c̲l̲u̲s̲i̲v̲e̲ start - conditions, the latter e̲x̲c̲l̲u̲s̲i̲v̲e̲ start conditions. A start condi‐ - tion is activated using the B̲E̲G̲I̲N̲ action. Until the next B̲E̲G̲I̲N̲ - action is executed, rules with the given start condition will be - active and rules with other start conditions will be inactive. If - the start condition is inclusive, then rules with no start condi‐ - tions at all will also be active. If it is exclusive, then only - rules qualified with the start condition will be active. A set of - rules contingent on the same exclusive start condition describe a - scanner which is independent of any of the other rules in the 𝗳𝗹𝗲𝘅 - input. Because of this, exclusive start conditions make it easy to - specify "mini-scanners" which scan portions of the input that are - syntactically different from the rest (e.g., comments). - - If the distinction between inclusive and exclusive start conditions - is still a little vague, here's a simple example illustrating the - connection between the two. The set of rules: - - %s example - %% - - foo do_something(); - - bar something_else(); - - is equivalent to - - %x example - %% - - foo do_something(); - - bar something_else(); - - Without the ⟨INITIAL,example⟩ qualifier, the “bar” pattern in the - second example wouldn't be active (i.e., couldn't match) when in - start condition “example”. If we just used ⟨example⟩ to qualify - “bar”, though, then it would only be active in “example” and not in - I̲N̲I̲T̲I̲A̲L̲, while in the first example it's active in both, because in - the first example the “example” start condition is an inclusive - (‘%s’) start condition. - - Also note that the special start-condition specifier ‘⟨*⟩’ matches - every start condition. Thus, the above example could also have - been written: - - %x example - %% - - foo do_something(); - - <*>bar something_else(); - - The default rule (to E̲C̲H̲O̲ any unmatched character) remains active - in start conditions. It is equivalent to: - - <*>.|\n ECHO; - - “BEGIN(0)” returns to the original state where only the rules with - no start conditions are active. This state can also be referred to - as the start-condition I̲N̲I̲T̲I̲A̲L̲, so “BEGIN(INITIAL)” is equivalent - to “BEGIN(0)”. (The parentheses around the start condition name - are not required but are considered good style.) - - B̲E̲G̲I̲N̲ actions can also be given as indented code at the beginning - of the rules section. For example, the following will cause the - scanner to enter the "SPECIAL" start condition whenever 𝘆𝘆𝗹𝗲𝘅() is - called and the global variable e̲n̲t̲e̲r̲_s̲p̲e̲c̲i̲a̲l̲ is true: - - int enter_special; - - %x SPECIAL - %% - if (enter_special) - BEGIN(SPECIAL); - - blahblahblah - ...more rules follow... - - To illustrate the uses of start conditions, here is a scanner which - provides two different interpretations of a string like "123.456". - By default it will treat it as three tokens: the integer "123", a - dot (‘.’), and the integer "456". But if the string is preceded - earlier in the line by the string "expect-floats" it will treat it - as a single token, the floating-point number 123.456: - - %{ - #include - %} - %s expect - - %% - expect-floats BEGIN(expect); - - [0-9]+"."[0-9]+ { - printf("found a float, = %f\n", - atof(yytext)); - } - \n { - /* - * That's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers. - */ - BEGIN(INITIAL); - } - - [0-9]+ { - printf("found an integer, = %d\n", - atoi(yytext)); - } - - "." printf("found a dot\n"); - - Here is a scanner which recognizes (and discards) C comments while - maintaining a count of the current input line: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" BEGIN(INITIAL); - - This scanner goes to a bit of trouble to match as much text as pos‐ - sible with each rule. In general, when attempting to write a high- - speed scanner try to match as much as possible in each rule, as - it's a big win. - - Note that start-condition names are really integer values and can - be stored as such. Thus, the above could be extended in the fol‐ - lowing fashion: - - %x comment foo - %% - int line_num = 1; - int comment_caller; - - "/*" { - comment_caller = INITIAL; - BEGIN(comment); - } - - ... - - "/*" { - comment_caller = foo; - BEGIN(comment); - } - - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" BEGIN(comment_caller); - - Furthermore, the current start condition can be accessed by using - the integer-valued YY_START macro. For example, the above assign‐ - ments to c̲o̲m̲m̲e̲n̲t̲_c̲a̲l̲l̲e̲r̲ could instead be written - - comment_caller = YY_START; - - Flex provides YYSTATE as an alias for YY_START (since that is - what's used by AT&T UNIX 𝗹𝗲𝘅). - - Note that start conditions do not have their own name-space; %s's - and %x's declare names in the same fashion as #define's. - - Finally, here's an example of how to match C-style quoted strings - using exclusive start conditions, including expanded escape - sequences (but not including checking for a string that's too - long): - - %x str - - %% - #define MAX_STR_CONST 1024 - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - - \" string_buf_ptr = string_buf; BEGIN(str); - - \" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\0'; - /* - * return string constant token type and - * value to parser - */ - } - - \n { - /* error - unterminated string constant */ - /* generate error message */ - } - - \\[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf(yytext + 1, "%o", &result); - - if (result > 0xff) { - /* error, constant is out-of-bounds */ - } else - *string_buf_ptr++ = result; - } - - \\[0-9]+ { - /* - * generate error - bad escape sequence; something - * like '\48' or '\0777777' - */ - } - - \\n *string_buf_ptr++ = '\n'; - \\t *string_buf_ptr++ = '\t'; - \\r *string_buf_ptr++ = '\r'; - \\b *string_buf_ptr++ = '\b'; - \\f *string_buf_ptr++ = '\f'; - - \\(.|\n) *string_buf_ptr++ = yytext[1]; - - [^\\\n\"]+ { - char *yptr = yytext; - - while (*yptr) - *string_buf_ptr++ = *yptr++; - } - - Often, such as in some of the examples above, a whole bunch of - rules are all preceded by the same start condition(s). 𝗳𝗹𝗲𝘅 makes - this a little easier and cleaner by introducing a notion of start - condition s̲c̲o̲p̲e̲. A start condition scope is begun with: - - { - - where “SCs” is a list of one or more start conditions. Inside the - start condition scope, every rule automatically has the prefix - ⟨SCs⟩ applied to it, until a ‘}’ which matches the initial ‘{’. - So, for example, - - { - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - } - - is equivalent to: - - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - - Start condition scopes may be nested. - - Three routines are available for manipulating stacks of start con‐ - ditions: - - void yy_push_state(int new_state) - Pushes the current start condition onto the top of the - start condition stack and switches to n̲e̲w̲_s̲t̲a̲t̲e̲ as though - “BEGIN new_state” had been used (recall that start - condition names are also integers). - - void yy_pop_state() - Pops the top of the stack and switches to it via B̲E̲G̲I̲N̲. - - int yy_top_state() - Returns the top of the stack without altering the stack's - contents. - - The start condition stack grows dynamically and so has no built-in - size limitation. If memory is exhausted, program execution aborts. - - To use start condition stacks, scanners must include a “%option - stack” directive (see O̲P̲T̲I̲O̲N̲S̲ below). - -𝐌𝐔𝐋𝐓𝐈𝐏𝐋𝐄 𝐈𝐍𝐏𝐔𝐓 𝐁𝐔𝐅𝐅𝐄𝐑𝐒 - Some scanners (such as those which support "include" files) require - reading from several input streams. As 𝗳𝗹𝗲𝘅 scanners do a large - amount of buffering, one cannot control where the next input will - be read from by simply writing a YY_INPUT which is sensitive to the - scanning context. YY_INPUT is only called when the scanner reaches - the end of its buffer, which may be a long time after scanning a - statement such as an "include" which requires switching the input - source. - - To negotiate these sorts of problems, 𝗳𝗹𝗲𝘅 provides a mechanism for - creating and switching between multiple input buffers. An input - buffer is created by using: - - YY_BUFFER_STATE yy_create_buffer(FILE *file, int size) - - which takes a F̲I̲L̲E̲ pointer and a s̲i̲z̲e̲ and creates a buffer associ‐ - ated with the given file and large enough to hold s̲i̲z̲e̲ characters - (when in doubt, use YY_BUF_SIZE for the size). It returns a - YY_BUFFER_STATE handle, which may then be passed to other routines - (see below). The YY_BUFFER_STATE type is a pointer to an opaque - “struct yy_buffer_state” structure, so YY_BUFFER_STATE variables - may be safely initialized to “((YY_BUFFER_STATE) 0)” if desired, - and the opaque structure can also be referred to in order to cor‐ - rectly declare input buffers in source files other than that of - scanners. Note that the F̲I̲L̲E̲ pointer in the call to - 𝘆𝘆_𝗰𝗿𝗲𝗮𝘁𝗲_𝗯𝘂𝗳𝗳𝗲𝗿() is only used as the value of y̲y̲i̲n̲ seen by - YY_INPUT; if YY_INPUT is redefined so that it no longer uses y̲y̲i̲n̲, - then a nil F̲I̲L̲E̲ pointer can safely be passed to 𝘆𝘆_𝗰𝗿𝗲𝗮𝘁𝗲_𝗯𝘂𝗳𝗳𝗲𝗿(). - To select a particular buffer to scan: - - void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) - - It switches the scanner's input buffer so subsequent tokens will - come from n̲e̲w̲_b̲u̲f̲f̲e̲r̲. Note that 𝘆𝘆_𝘀𝘄𝗶𝘁𝗰𝗵_𝘁𝗼_𝗯𝘂𝗳𝗳𝗲𝗿() may be used - by 𝘆𝘆𝘄𝗿𝗮𝗽() to set things up for continued scanning, instead of - opening a new file and pointing y̲y̲i̲n̲ at it. Note also that switch‐ - ing input sources via either 𝘆𝘆_𝘀𝘄𝗶𝘁𝗰𝗵_𝘁𝗼_𝗯𝘂𝗳𝗳𝗲𝗿() or 𝘆𝘆𝘄𝗿𝗮𝗽() does - not change the start condition. - - void yy_delete_buffer(YY_BUFFER_STATE buffer) - - is used to reclaim the storage associated with a buffer. (b̲u̲f̲f̲e̲r̲ - can be nil, in which case the routine does nothing.) To clear the - current contents of a buffer: - - void yy_flush_buffer(YY_BUFFER_STATE buffer) - - This function discards the buffer's contents, so the next time the - scanner attempts to match a token from the buffer, it will first - fill the buffer anew using YY_INPUT. - - 𝘆𝘆_𝗻𝗲𝘄_𝗯𝘂𝗳𝗳𝗲𝗿() is an alias for 𝘆𝘆_𝗰𝗿𝗲𝗮𝘁𝗲_𝗯𝘂𝗳𝗳𝗲𝗿(), provided for - compatibility with the C++ use of n̲e̲w̲ and d̲e̲l̲e̲t̲e̲ for creating and - destroying dynamic objects. - - Finally, the YY_CURRENT_BUFFER macro returns a YY_BUFFER_STATE han‐ - dle to the current buffer. - - Here is an example of using these features for writing a scanner - which expands include files (the ⟨⟨EOF⟩⟩ feature is discussed - below): - - /* - * the "incl" state is used for picking up the name - * of an include file - */ - %x incl - - %{ - #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include BEGIN(incl); - - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; - - [ \t]* /* eat the whitespace */ - [^ \t\n]+ { /* got the include file name */ - if (include_stack_ptr >= MAX_INCLUDE_DEPTH) - errx(1, "Includes nested too deeply"); - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen(yytext, "r"); - - if (yyin == NULL) - err(1, NULL); - - yy_switch_to_buffer( - yy_create_buffer(yyin, YY_BUF_SIZE)); - - BEGIN(INITIAL); - } - - <> { - if (--include_stack_ptr < 0) - yyterminate(); - else { - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer( - include_stack[include_stack_ptr]); - } - } - - Three routines are available for setting up input buffers for scan‐ - ning in-memory strings instead of files. All of them create a new - input buffer for scanning the string, and return a corresponding - YY_BUFFER_STATE handle (which should be deleted afterwards using - 𝘆𝘆_𝗱𝗲𝗹𝗲𝘁𝗲_𝗯𝘂𝗳𝗳𝗲𝗿()). They also switch to the new buffer using - 𝘆𝘆_𝘀𝘄𝗶𝘁𝗰𝗵_𝘁𝗼_𝗯𝘂𝗳𝗳𝗲𝗿(), so the next call to 𝘆𝘆𝗹𝗲𝘅() will start scan‐ - ning the string. - - yy_scan_string(const char *str) - Scans a NUL-terminated string. - - yy_scan_bytes(const char *bytes, int len) - Scans l̲e̲n̲ bytes (including possibly NUL's) starting at - location b̲y̲t̲e̲s̲. - - Note that both of these functions create and scan a copy of the - string or bytes. (This may be desirable, since 𝘆𝘆𝗹𝗲𝘅() modifies - the contents of the buffer it is scanning.) The copy can be - avoided by using: - - yy_scan_buffer(char *base, yy_size_t size) - Which scans the buffer starting at b̲a̲s̲e̲, consisting of s̲i̲z̲e̲ - bytes, the last two bytes of which must be - YY_END_OF_BUFFER_CHAR (ASCII NUL). These last two bytes - are not scanned; thus, scanning consists of base[0] through - base[size-2], inclusive. - - If b̲a̲s̲e̲ is not set up in this manner (i.e., forget the - final two YY_END_OF_BUFFER_CHAR bytes), then - 𝘆𝘆_𝘀𝗰𝗮𝗻_𝗯𝘂𝗳𝗳𝗲𝗿() returns a nil pointer instead of creating - a new input buffer. - - The type y̲y̲_s̲i̲z̲e̲_t̲ is an integral type which can be cast to - an integer expression reflecting the size of the buffer. - -𝐄𝐍𝐃-𝐎𝐅-𝐅𝐈𝐋𝐄 𝐑𝐔𝐋𝐄𝐒 - The special rule "⟨⟨EOF⟩⟩" indicates actions which are to be taken - when an end-of-file is encountered and 𝘆𝘆𝘄𝗿𝗮𝗽() returns non-zero - (i.e., indicates no further files to process). The action must - finish by doing one of four things: - - - Assigning y̲y̲i̲n̲ to a new input file (in previous versions of - 𝗳𝗹𝗲𝘅, after doing the assignment, it was necessary to call the - special action YY_NEW_FILE; this is no longer necessary). - - - Executing a r̲e̲t̲u̲r̲n̲ statement. - - - Executing the special 𝘆𝘆𝘁𝗲𝗿𝗺𝗶𝗻𝗮𝘁𝗲() action. - - - Switching to a new buffer using 𝘆𝘆_𝘀𝘄𝗶𝘁𝗰𝗵_𝘁𝗼_𝗯𝘂𝗳𝗳𝗲𝗿() as shown - in the example above. - - ⟨⟨EOF⟩⟩ rules may not be used with other patterns; they may only be - qualified with a list of start conditions. If an unqualified - ⟨⟨EOF⟩⟩ rule is given, it applies to all start conditions which do - not already have ⟨⟨EOF⟩⟩ actions. To specify an ⟨⟨EOF⟩⟩ rule for - only the initial start condition, use - - <> - - These rules are useful for catching things like unclosed comments. - An example: - - %x quote - %% - - ...other rules for dealing with quotes... - - <> { - error("unterminated quote"); - yyterminate(); - } - <> { - if (*++filelist) - yyin = fopen(*filelist, "r"); - else - yyterminate(); - } - -𝐌𝐈𝐒𝐂𝐄𝐋𝐋𝐀𝐍𝐄𝐎𝐔𝐒 𝐌𝐀𝐂𝐑𝐎𝐒 - The macro YY_USER_ACTION can be defined to provide an action which - is always executed prior to the matched rule's action. For exam‐ - ple, it could be #define'd to call a routine to convert yytext to - lower-case. When YY_USER_ACTION is invoked, the variable y̲y̲_a̲c̲t̲ - gives the number of the matched rule (rules are numbered starting - with 1). For example, to profile how often each rule is matched, - the following would do the trick: - - #define YY_USER_ACTION ++ctr[yy_act] - - where c̲t̲r̲ is an array to hold the counts for the different rules. - Note that the macro YY_NUM_RULES gives the total number of rules - (including the default rule, even if -𝘀 is used), so a correct dec‐ - laration for c̲t̲r̲ is: - - int ctr[YY_NUM_RULES]; - - The macro YY_USER_INIT may be defined to provide an action which is - always executed before the first scan (and before the scanner's - internal initializations are done). For example, it could be used - to call a routine to read in a data table or open a logging file. - - The macro yy_set_interactive(is_interactive) can be used to control - whether the current buffer is considered i̲n̲t̲e̲r̲a̲c̲t̲i̲v̲e̲. An interac‐ - tive buffer is processed more slowly, but must be used when the - scanner's input source is indeed interactive to avoid problems due - to waiting to fill buffers (see the discussion of the -𝐈 flag - below). A non-zero value in the macro invocation marks the buffer - as interactive, a zero value as non-interactive. Note that use of - this macro overrides “%option always-interactive” or “%option - never-interactive” (see O̲P̲T̲I̲O̲N̲S̲ below). 𝘆𝘆_𝘀𝗲𝘁_𝗶𝗻𝘁𝗲𝗿𝗮𝗰𝘁𝗶𝘃𝗲() must - be invoked prior to beginning to scan the buffer that is (or is - not) to be considered interactive. - - The macro yy_set_bol(at_bol) can be used to control whether the - current buffer's scanning context for the next token match is done - as though at the beginning of a line. A non-zero macro argument - makes rules anchored with ‘^’ active, while a zero argument makes - ‘^’ rules inactive. - - The macro YY_AT_BOL returns true if the next token scanned from the - current buffer will have ‘^’ rules active, false otherwise. - - In the generated scanner, the actions are all gathered in one large - switch statement and separated using YY_BREAK, which may be rede‐ - fined. By default, it is simply a "break", to separate each rule's - action from the following rules. Redefining YY_BREAK allows, for - example, C++ users to “#define YY_BREAK” to do nothing (while being - very careful that every rule ends with a "break" or a "return"!) - to avoid suffering from unreachable statement warnings where - because a rule's action ends with “return”, the YY_BREAK is inac‐ - cessible. - -𝐕𝐀𝐋𝐔𝐄𝐒 𝐀𝐕𝐀𝐈𝐋𝐀𝐁𝐋𝐄 𝐓𝐎 𝐓𝐇𝐄 𝐔𝐒𝐄𝐑 - This section summarizes the various values available to the user in - the rule actions. - - char *yytext - Holds the text of the current token. It may be modified - but not lengthened (characters cannot be appended to the - end). - - If the special directive “%array” appears in the first sec‐ - tion of the scanner description, then y̲y̲t̲e̲x̲t̲ is instead - declared “char yytext[YYLMAX]”, where YYLMAX is a macro - definition that can be redefined in the first section to - change the default value (generally 8KB). Using “%array” - results in somewhat slower scanners, but the value of - y̲y̲t̲e̲x̲t̲ becomes immune to calls to 𝗶𝗻𝗽𝘂𝘁() and 𝘂𝗻𝗽𝘂𝘁(), - which potentially destroy its value when y̲y̲t̲e̲x̲t̲ is a char‐ - acter pointer. The opposite of “%array” is “%pointer”, - which is the default. - - “%array” cannot be used when generating C++ scanner classes - (the -+ flag). - - int yyleng - Holds the length of the current token. - - FILE *yyin - Is the file which by default 𝗳𝗹𝗲𝘅 reads from. It may be - redefined, but doing so only makes sense before scanning - begins or after an EOF has been encountered. Changing it - in the midst of scanning will have unexpected results since - 𝗳𝗹𝗲𝘅 buffers its input; use 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() instead. Once - scanning terminates because an end-of-file has been seen, - y̲y̲i̲n̲ can be assigned as the new input file and the scanner - can be called again to continue scanning. - - void yyrestart(FILE *new_file) - May be called to point y̲y̲i̲n̲ at the new input file. The - switch-over to the new file is immediate (any previously - buffered-up input is lost). Note that calling 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() - with y̲y̲i̲n̲ as an argument thus throws away the current input - buffer and continues scanning the same input file. - - FILE *yyout - Is the file to which E̲C̲H̲O̲ actions are done. It can be - reassigned by the user. - - YY_CURRENT_BUFFER - Returns a YY_BUFFER_STATE handle to the current buffer. - - YY_START - Returns an integer value corresponding to the current start - condition. This value can subsequently be used with B̲E̲G̲I̲N̲ - to return to that start condition. - -𝐈𝐍𝐓𝐄𝐑𝐅𝐀𝐂𝐈𝐍𝐆 𝐖𝐈𝐓𝐇 𝐘𝐀𝐂𝐂 - One of the main uses of 𝗳𝗹𝗲𝘅 is as a companion to the yacc(1) - parser-generator. yacc parsers expect to call a routine named - 𝘆𝘆𝗹𝗲𝘅() to find the next input token. The routine is supposed to - return the type of the next token as well as putting any associated - value in the global y̲y̲l̲v̲a̲l̲, which is defined externally, and can be - a union or any other complex data structure. To use 𝗳𝗹𝗲𝘅 with - yacc, one specifies the -𝗱 option to yacc to instruct it to gener‐ - ate the file y̲.̲t̲a̲b̲.̲h̲ containing definitions of all the “%tokens” - appearing in the yacc input. This file is then included in the - 𝗳𝗹𝗲𝘅 scanner. For example, if one of the tokens is "TOK_NUMBER", - part of the scanner might look like: - - %{ - #include "y.tab.h" - %} - - %% - - [0-9]+ yylval = atoi(yytext); return TOK_NUMBER; - -𝐎𝐏𝐓𝐈𝐎𝐍𝐒 - 𝗳𝗹𝗲𝘅 has the following options: - - -𝟳 Instructs 𝗳𝗹𝗲𝘅 to generate a 7-bit scanner, i.e., one which - can only recognize 7-bit characters in its input. The - advantage of using -𝟳 is that the scanner's tables can be - up to half the size of those generated using the -𝟴 option - (see below). The disadvantage is that such scanners often - hang or crash if their input contains an 8-bit character. - - Note, however, that unless generating a scanner using the - -𝐂𝗳 or -𝐂𝐅 table compression options, use of -𝟳 will save - only a small amount of table space, and make the scanner - considerably less portable. 𝗳𝗹𝗲𝘅's default behavior is to - generate an 8-bit scanner unless -𝐂𝗳 or -𝐂𝐅 is specified, - in which case 𝗳𝗹𝗲𝘅 defaults to generating 7-bit scanners - unless it was configured to generate 8-bit scanners (as - will often be the case with non-USA sites). It is possible - tell whether 𝗳𝗹𝗲𝘅 generated a 7-bit or an 8-bit scanner by - inspecting the flag summary in the -𝘃 output as described - below. - - Note that if -𝐂𝗳𝗲 or -𝐂𝐅𝗲 are used (the table compression - options, but also using equivalence classes as discussed - below), 𝗳𝗹𝗲𝘅 still defaults to generating an 8-bit scanner, - since usually with these compression options full 8-bit - tables are not much more expensive than 7-bit tables. - - -𝟴 Instructs 𝗳𝗹𝗲𝘅 to generate an 8-bit scanner, i.e., one - which can recognize 8-bit characters. This flag is only - needed for scanners generated using -𝐂𝗳 or -𝐂𝐅, as other‐ - wise 𝗳𝗹𝗲𝘅 defaults to generating an 8-bit scanner anyway. - - See the discussion of -𝟳 above for 𝗳𝗹𝗲𝘅's default behavior - and the tradeoffs between 7-bit and 8-bit scanners. - - -𝐁 Instructs 𝗳𝗹𝗲𝘅 to generate a b̲a̲t̲c̲h̲ scanner, the opposite of - i̲n̲t̲e̲r̲a̲c̲t̲i̲v̲e̲ scanners generated by -𝐈 (see below). In gen‐ - eral, -𝐁 is used when the scanner will never be used inter‐ - actively, and you want to squeeze a little more performance - out of it. If the aim is instead to squeeze out a lot more - performance, use the -𝐂𝗳 or -𝐂𝐅 options (discussed below), - which turn on -𝐁 automatically anyway. - - -𝗯 Generate backing-up information to l̲e̲x̲.̲b̲a̲c̲k̲u̲p̲. This is a - list of scanner states which require backing up and the - input characters on which they do so. By adding rules one - can remove backing-up states. If all backing-up states are - eliminated and -𝐂𝗳 or -𝐂𝐅 is used, the generated scanner - will run faster (see the -𝗽 flag). Only users who wish to - squeeze every last cycle out of their scanners need worry - about this option. (See the section on P̲E̲R̲F̲O̲R̲M̲A̲N̲C̲E̲ - C̲O̲N̲S̲I̲D̲E̲R̲A̲T̲I̲O̲N̲S̲ below.) - - -𝐂[𝗮𝗲𝐅𝗳𝗺𝗿] - Controls the degree of table compression and, more gener‐ - ally, trade-offs between small scanners and fast scanners. - - -𝐂𝗮 Instructs 𝗳𝗹𝗲𝘅 to trade off larger tables in the - generated scanner for faster performance because - the elements of the tables are better aligned for - memory access and computation. On some RISC archi‐ - tectures, fetching and manipulating longwords is - more efficient than with smaller-sized units such - as shortwords. This option can double the size of - the tables used by the scanner. - - -𝐂𝗲 Directs 𝗳𝗹𝗲𝘅 to construct e̲q̲u̲i̲v̲a̲l̲e̲n̲c̲e̲ c̲l̲a̲s̲s̲e̲s̲, - i.e., sets of characters which have identical lexi‐ - cal properties (for example, if the only appearance - of digits in the 𝗳𝗹𝗲𝘅 input is in the character - class "[0-9]" then the digits ‘0’, ‘1’, ‘...’, ‘9’ - will all be put in the same equivalence class). - Equivalence classes usually give dramatic reduc‐ - tions in the final table/object file sizes - (typically a factor of 2-5) and are pretty cheap - performance-wise (one array look-up per character - scanned). - - -𝐂𝐅 Specifies that the alternate fast scanner represen‐ - tation (described below under the -𝐅 option) should - be used. This option cannot be used with -+. - - -𝐂𝗳 Specifies that the f̲u̲l̲l̲ scanner tables should be - generated - 𝗳𝗹𝗲𝘅 should not compress the tables by - taking advantage of similar transition functions - for different states. - - -𝐂𝗺 Directs 𝗳𝗹𝗲𝘅 to construct m̲e̲t̲a̲-̲e̲q̲u̲i̲v̲a̲l̲e̲n̲c̲e̲ c̲l̲a̲s̲s̲e̲s̲, - which are sets of equivalence classes (or charac‐ - ters, if equivalence classes are not being used) - that are commonly used together. Meta-equivalence - classes are often a big win when using compressed - tables, but they have a moderate performance impact - (one or two "if" tests and one array look-up per - character scanned). - - -𝐂𝗿 Causes the generated scanner to b̲y̲p̲a̲s̲s̲ use of the - standard I/O library (stdio) for input. Instead of - calling fread(3) or getc(3), the scanner will use - the read(2) system call, resulting in a performance - gain which varies from system to system, but in - general is probably negligible unless -𝐂𝗳 or -𝐂𝐅 - are being used. Using -𝐂𝗿 can cause strange behav‐ - ior if, for example, reading from y̲y̲i̲n̲ using stdio - prior to calling the scanner (because the scanner - will miss whatever text previous reads left in the - stdio input buffer). - - -𝐂𝗿 has no effect if YY_INPUT is defined (see T̲H̲E̲ - G̲E̲N̲E̲R̲A̲T̲E̲D̲ S̲C̲A̲N̲N̲E̲R̲ above). - - A lone -𝐂 specifies that the scanner tables should be com‐ - pressed but neither equivalence classes nor meta-equiva‐ - lence classes should be used. - - The options -𝐂𝗳 or -𝐂𝐅 and -𝐂𝗺 do not make sense together - - there is no opportunity for meta-equivalence classes if the - table is not being compressed. Otherwise the options may - be freely mixed, and are cumulative. - - The default setting is -𝐂𝗲𝗺 which specifies that 𝗳𝗹𝗲𝘅 - should generate equivalence classes and meta-equivalence - classes. This setting provides the highest degree of table - compression. It is possible to trade off faster-executing - scanners at the cost of larger tables with the following - generally being true: - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - - Note that scanners with the smallest tables are usually - generated and compiled the quickest, so during development - the default is usually best, maximal compression. - - -𝐂𝗳𝗲 is often a good compromise between speed and size for - production scanners. - - -𝗱 Makes the generated scanner run in debug mode. Whenever a - pattern is recognized and the global y̲y̲_f̲l̲e̲x̲_d̲e̲b̲u̲g̲ is non- - zero (which is the default), the scanner will write to - stderr a line of the form: - - --accepting rule at line 53 ("the matched text") - - The line number refers to the location of the rule in the - file defining the scanner (i.e., the file that was fed to - 𝗳𝗹𝗲𝘅). Messages are also generated when the scanner backs - up, accepts the default rule, reaches the end of its input - buffer (or encounters a NUL; at this point, the two look - the same as far as the scanner's concerned), or reaches an - end-of-file. - - -𝐅 Specifies that the fast scanner table representation should - be used (and stdio bypassed). This representation is about - as fast as the full table representation (-𝗳), and for some - sets of patterns will be considerably smaller (and for - others, larger). In general, if the pattern set contains - both "keywords" and a catch-all, "identifier" rule, such as - in the set: - - "case" return TOK_CASE; - "switch" return TOK_SWITCH; - ... - "default" return TOK_DEFAULT; - [a-z]+ return TOK_ID; - - then it's better to use the full table representation. If - only the "identifier" rule is present and a hash table or - some such is used to detect the keywords, it's better to - use -𝐅. - - This option is equivalent to -𝐂𝐅𝗿 (see above). It cannot - be used with -+. - - -𝗳 Specifies f̲a̲s̲t̲ s̲c̲a̲n̲n̲e̲r̲. No table compression is done and - stdio is bypassed. The result is large but fast. This - option is equivalent to -𝐂𝗳𝗿 (see above). - - -𝗵 Generates a help summary of 𝗳𝗹𝗲𝘅's options to stdout and - then exits. -? and --𝗵𝗲𝗹𝗽 are synonyms for -𝗵. - - -𝐈 Instructs 𝗳𝗹𝗲𝘅 to generate an i̲n̲t̲e̲r̲a̲c̲t̲i̲v̲e̲ scanner. An - interactive scanner is one that only looks ahead to decide - what token has been matched if it absolutely must. It - turns out that always looking one extra character ahead, - even if the scanner has already seen enough text to disam‐ - biguate the current token, is a bit faster than only look‐ - ing ahead when necessary. But scanners that always look - ahead give dreadful interactive performance; for example, - when a user types a newline, it is not recognized as a new‐ - line token until they enter a̲n̲o̲t̲h̲e̲r̲ token, which often - means typing in another whole line. - - 𝗳𝗹𝗲𝘅 scanners default to i̲n̲t̲e̲r̲a̲c̲t̲i̲v̲e̲ unless -𝐂𝗳 or -𝐂𝐅 ta‐ - ble-compression options are specified (see above). That's - because if high-performance is most important, one of these - options should be used, so if they weren't, 𝗳𝗹𝗲𝘅 assumes it - is preferable to trade off a bit of run-time performance - for intuitive interactive behavior. Note also that -𝐈 can‐ - not be used in conjunction with -𝐂𝗳 or -𝐂𝐅. Thus, this - option is not really needed; it is on by default for all - those cases in which it is allowed. - - A scanner can be forced to not be interactive by using -𝐁 - (see above). - - -𝗶 Instructs 𝗳𝗹𝗲𝘅 to generate a case-insensitive scanner. The - case of letters given in the 𝗳𝗹𝗲𝘅 input patterns will be - ignored, and tokens in the input will be matched regardless - of case. The matched text given in y̲y̲t̲e̲x̲t̲ will have the - preserved case (i.e., it will not be folded). - - -𝐋 Instructs 𝗳𝗹𝗲𝘅 not to generate “#line” directives. Without - this option, 𝗳𝗹𝗲𝘅 peppers the generated scanner with #line - directives so error messages in the actions will be cor‐ - rectly located with respect to either the original 𝗳𝗹𝗲𝘅 - input file (if the errors are due to code in the input - file), or l̲e̲x̲.̲y̲y̲.̲c̲ (if the errors are 𝗳𝗹𝗲𝘅's fault - these - sorts of errors should be reported to the email address - given below). - - -𝗹 Turns on maximum compatibility with the original AT&T UNIX - 𝗹𝗲𝘅 implementation. Note that this does not mean full com‐ - patibility. Use of this option costs a considerable amount - of performance, and it cannot be used with the -+, -𝗳, -𝐅, - -𝐂𝗳, or -𝐂𝐅 options. For details on the compatibilities it - provides, see the section I̲N̲C̲O̲M̲P̲A̲T̲I̲B̲I̲L̲I̲T̲I̲E̲S̲ W̲I̲T̲H̲ L̲E̲X̲ A̲N̲D̲ - P̲O̲S̲I̲X̲ below. This option also results in the name - YY_FLEX_LEX_COMPAT being #define'd in the generated scan‐ - ner. - - -𝗻 Another do-nothing, deprecated option included only for - POSIX compliance. - - -𝗼o̲u̲t̲p̲u̲t̲ - Directs 𝗳𝗹𝗲𝘅 to write the scanner to the file o̲u̲t̲p̲u̲t̲ - instead of l̲e̲x̲.̲y̲y̲.̲c̲. If -𝗼 is combined with the -𝘁 option, - then the scanner is written to stdout but its “#line” - directives (see the -𝐋 option above) refer to the file - o̲u̲t̲p̲u̲t̲. - - -𝐏p̲r̲e̲f̲i̲x̲ - Changes the default "yy" prefix used by 𝗳𝗹𝗲𝘅 for all glob‐ - ally visible variable and function names to instead be - p̲r̲e̲f̲i̲x̲. For example, -𝐏f̲o̲o̲ changes the name of y̲y̲t̲e̲x̲t̲ to - f̲o̲o̲t̲e̲x̲t̲. It also changes the name of the default output - file from l̲e̲x̲.̲y̲y̲.̲c̲ to l̲e̲x̲.̲f̲o̲o̲.̲c̲. Here are all of the names - affected: - - yy_create_buffer - yy_delete_buffer - yy_flex_debug - yy_init_buffer - yy_flush_buffer - yy_load_buffer_state - yy_switch_to_buffer - yyin - yyleng - yylex - yylineno - yyout - yyrestart - yytext - yywrap - - (If using a C++ scanner, then only y̲y̲w̲r̲a̲p̲ and y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ - are affected.) Within the scanner itself, it is still pos‐ - sible to refer to the global variables and functions using - either version of their name; but externally, they have the - modified name. - - This option allows multiple 𝗳𝗹𝗲𝘅 programs to be easily - linked together into the same executable. Note, though, - that using this option also renames 𝘆𝘆𝘄𝗿𝗮𝗽(), so now either - an (appropriately named) version of the routine for the - scanner must be supplied, or “%option noyywrap” must be - used, as linking with -𝗹𝗳𝗹 no longer provides one by - default. - - -𝗽 Generates a performance report to stderr. The report con‐ - sists of comments regarding features of the 𝗳𝗹𝗲𝘅 input file - which will cause a serious loss of performance in the - resulting scanner. If the flag is specified twice, com‐ - ments regarding features that lead to minor performance - losses will also be reported> - - Note that the use of R̲E̲J̲E̲C̲T̲, “%option yylineno”, and vari‐ - able trailing context (see the B̲U̲G̲S̲ section below) entails - a substantial performance penalty; use of 𝘆𝘆𝗺𝗼𝗿𝗲(), the ‘^’ - operator, and the -𝐈 flag entail minor performance penal‐ - ties. - - -𝐒s̲k̲e̲l̲e̲t̲o̲n̲ - Overrides the default skeleton file from which 𝗳𝗹𝗲𝘅 con‐ - structs its scanners. This option is needed only for 𝗳𝗹𝗲𝘅 - maintenance or development. - - -𝘀 Causes the default rule (that unmatched scanner input is - echoed to stdout) to be suppressed. If the scanner encoun‐ - ters input that does not match any of its rules, it aborts - with an error. This option is useful for finding holes in - a scanner's rule set. - - -𝐓 Makes 𝗳𝗹𝗲𝘅 run in t̲r̲a̲c̲e̲ mode. It will generate a lot of - messages to stderr concerning the form of the input and the - resultant non-deterministic and deterministic finite autom‐ - ata. This option is mostly for use in maintaining 𝗳𝗹𝗲𝘅. - - -𝘁 Instructs 𝗳𝗹𝗲𝘅 to write the scanner it generates to stan‐ - dard output instead of l̲e̲x̲.̲y̲y̲.̲c̲. - - -𝐕 Prints the version number to stdout and exits. --𝘃𝗲𝗿𝘀𝗶𝗼𝗻 - is a synonym for -𝐕. - - -𝘃 Specifies that 𝗳𝗹𝗲𝘅 should write to stderr a summary of - statistics regarding the scanner it generates. Most of the - statistics are meaningless to the casual 𝗳𝗹𝗲𝘅 user, but the - first line identifies the version of 𝗳𝗹𝗲𝘅 (same as reported - by -𝐕), and the next line the flags used when generating - the scanner, including those that are on by default. - - -𝘄 Suppresses warning messages. - - -+ Specifies that 𝗳𝗹𝗲𝘅 should generate a C++ scanner class. - See the section on G̲E̲N̲E̲R̲A̲T̲I̲N̲G̲ C̲+̲+̲ S̲C̲A̲N̲N̲E̲R̲S̲ below for - details. - - 𝗳𝗹𝗲𝘅 also provides a mechanism for controlling options within the - scanner specification itself, rather than from the 𝗳𝗹𝗲𝘅 command - line. This is done by including “%option” directives in the first - section of the scanner specification. Multiple options can be - specified with a single “%option” directive, and multiple direc‐ - tives in the first section of the 𝗳𝗹𝗲𝘅 input file. - - Most options are given simply as names, optionally preceded by the - word "no" (with no intervening whitespace) to negate their meaning. - A number are equivalent to 𝗳𝗹𝗲𝘅 flags or their negation: - - 7bit -7 option - 8bit -8 option - align -Ca option - backup -b option - batch -B option - c++ -+ option - - caseful or - case-sensitive opposite of -i (default) - - case-insensitive or - caseless -i option - - debug -d option - default opposite of -s option - ecs -Ce option - fast -F option - full -f option - interactive -I option - lex-compat -l option - meta-ecs -Cm option - perf-report -p option - read -Cr option - stdout -t option - verbose -v option - warn opposite of -w option - (use "%option nowarn" for -w) - - array equivalent to "%array" - pointer equivalent to "%pointer" (default) - - Some %option's provide features otherwise not available: - - always-interactive - Instructs 𝗳𝗹𝗲𝘅 to generate a scanner which always considers - its input "interactive". Normally, on each new input file - the scanner calls 𝗶𝘀𝗮𝘁𝘁𝘆() in an attempt to determine - whether the scanner's input source is interactive and thus - should be read a character at a time. When this option is - used, however, no such call is made. - - main Directs 𝗳𝗹𝗲𝘅 to provide a default 𝗺𝗮𝗶𝗻() program for the - scanner, which simply calls 𝘆𝘆𝗹𝗲𝘅(). This option implies - “noyywrap” (see below). - - never-interactive - Instructs 𝗳𝗹𝗲𝘅 to generate a scanner which never considers - its input "interactive" (again, no call made to 𝗶𝘀𝗮𝘁𝘁𝘆()). - This is the opposite of “always-interactive”. - - stack Enables the use of start condition stacks (see S̲T̲A̲R̲T̲ - C̲O̲N̲D̲I̲T̲I̲O̲N̲S̲ above). - - stdinit - If set (i.e., “%option stdinit”), initializes y̲y̲i̲n̲ and - y̲y̲o̲u̲t̲ to stdin and stdout, instead of the default of “nil”. - Some existing 𝗹𝗲𝘅 programs depend on this behavior, even - though it is not compliant with ANSI C, which does not - require stdin and stdout to be compile-time constant. - - yylineno - Directs 𝗳𝗹𝗲𝘅 to generate a scanner that maintains the num‐ - ber of the current line read from its input in the global - variable y̲y̲l̲i̲n̲e̲n̲o̲. This option is implied by “%option - lex-compat”. - - yywrap If unset (i.e., “%option noyywrap”), makes the scanner not - call 𝘆𝘆𝘄𝗿𝗮𝗽() upon an end-of-file, but simply assume that - there are no more files to scan (until the user points y̲y̲i̲n̲ - at a new file and calls 𝘆𝘆𝗹𝗲𝘅() again). - - 𝗳𝗹𝗲𝘅 scans rule actions to determine whether the R̲E̲J̲E̲C̲T̲ or 𝘆𝘆𝗺𝗼𝗿𝗲() - features are being used. The “reject” and “yymore” options are - available to override its decision as to whether to use the - options, either by setting them (e.g., “%option reject”) to indi‐ - cate the feature is indeed used, or unsetting them to indicate it - actually is not used (e.g., “%option noyymore”). - - Three options take string-delimited values, offset with ‘=’: - - %option outfile="ABC" - - is equivalent to -𝗼A̲B̲C̲, and - - %option prefix="XYZ" - - is equivalent to -𝐏X̲Y̲Z̲. Finally, - - %option yyclass="foo" - - only applies when generating a C++ scanner (-+ option). It informs - 𝗳𝗹𝗲𝘅 that “foo” has been derived as a subclass of yyFlexLexer, so - 𝗳𝗹𝗲𝘅 will place actions in the member function “foo::yylex()” - instead of “yyFlexLexer::yylex()”. It also generates a - “yyFlexLexer::yylex()” member function that emits a run-time error - (by invoking “yyFlexLexer::LexerError()”) if called. See - G̲E̲N̲E̲R̲A̲T̲I̲N̲G̲ C̲+̲+̲ S̲C̲A̲N̲N̲E̲R̲S̲, below, for additional information. - - A number of options are available for lint purists who want to sup‐ - press the appearance of unneeded routines in the generated scanner. - Each of the following, if unset (e.g., “%option nounput”), results - in the corresponding routine not appearing in the generated scan‐ - ner: - - input, unput - yy_push_state, yy_pop_state, yy_top_state - yy_scan_buffer, yy_scan_bytes, yy_scan_string - - (though 𝘆𝘆_𝗽𝘂𝘀𝗵_𝘀𝘁𝗮𝘁𝗲() and friends won't appear anyway unless - “%option stack” is being used). - -𝐏𝐄𝐑𝐅𝐎𝐑𝐌𝐀𝐍𝐂𝐄 𝐂𝐎𝐍𝐒𝐈𝐃𝐄𝐑𝐀𝐓𝐈𝐎𝐍𝐒 - The main design goal of 𝗳𝗹𝗲𝘅 is that it generate high-performance - scanners. It has been optimized for dealing well with large sets - of rules. Aside from the effects on scanner speed of the table - compression -𝐂 options outlined above, there are a number of - options/actions which degrade performance. These are, from most - expensive to least: - - REJECT - %option yylineno - arbitrary trailing context - - pattern sets that require backing up - %array - %option interactive - %option always-interactive - - '^' beginning-of-line operator - yymore() - - with the first three all being quite expensive and the last two - being quite cheap. Note also that 𝘂𝗻𝗽𝘂𝘁() is implemented as a rou‐ - tine call that potentially does quite a bit of work, while 𝘆𝘆𝗹𝗲𝘀𝘀() - is a quite-cheap macro; so if just putting back some excess text, - use 𝘆𝘆𝗹𝗲𝘀𝘀(). - - R̲E̲J̲E̲C̲T̲ should be avoided at all costs when performance is impor‐ - tant. It is a particularly expensive option. - - Getting rid of backing up is messy and often may be an enormous - amount of work for a complicated scanner. In principal, one begins - by using the -𝗯 flag to generate a l̲e̲x̲.̲b̲a̲c̲k̲u̲p̲ file. For example, - on the input - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - the file looks like: - - State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \001-n p-\177 ] - - State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \001-` b-\177 ] - - State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \001-q s-\177 ] - - Compressed tables always back up. - - The first few lines tell us that there's a scanner state in which - it can make a transition on an ‘o’ but not on any other character, - and that in that state the currently scanned text does not match - any rule. The state occurs when trying to match the rules found at - lines 2 and 3 in the input file. If the scanner is in that state - and then reads something other than an ‘o’, it will have to back up - to find a rule which is matched. With a bit of headscratching one - can see that this must be the state it's in when it has seen ‘fo’. - When this has happened, if anything other than another ‘o’ is seen, - the scanner will have to back up to simply match the ‘f’ (by the - default rule). - - The comment regarding State #8 indicates there's a problem when - "foob" has been scanned. Indeed, on any character other than an - ‘a’, the scanner will have to back up to accept "foo". Similarly, - the comment for State #9 concerns when "fooba" has been scanned and - an ‘r’ does not follow. - - The final comment reminds us that there's no point going to all the - trouble of removing backing up from the rules unless we're using - -𝐂𝗳 or -𝐂𝐅, since there's no performance gain doing so with com‐ - pressed scanners. - - The way to remove the backing up is to add "error" rules: - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } - - Eliminating backing up among a list of keywords can also be done - using a "catch-all" rule: - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - [a-z]+ return TOK_ID; - - This is usually the best solution when appropriate. - - Backing up messages tend to cascade. With a complicated set of - rules it's not uncommon to get hundreds of messages. If one can - decipher them, though, it often only takes a dozen or so rules to - eliminate the backing up (though it's easy to make a mistake and - have an error rule accidentally match a valid token; a possible - future 𝗳𝗹𝗲𝘅 feature will be to automatically add rules to eliminate - backing up). - - It's important to keep in mind that the benefits of eliminating - backing up are gained only if e̲v̲e̲r̲y̲ instance of backing up is elim‐ - inated. Leaving just one gains nothing. - - V̲a̲r̲i̲a̲b̲l̲e̲ trailing context (where both the leading and trailing - parts do not have a fixed length) entails almost the same perfor‐ - mance loss as R̲E̲J̲E̲C̲T̲ (i.e., substantial). So when possible a rule - like: - - %% - mouse|rat/(cat|dog) run(); - - is better written: - - %% - mouse/cat|dog run(); - rat/cat|dog run(); - - or as - - %% - mouse|rat/cat run(); - mouse|rat/dog run(); - - Note that here the special ‘|’ action does not provide any savings, - and can even make things worse (see B̲U̲G̲S̲ below). - - Another area where the user can increase a scanner's performance - (and one that's easier to implement) arises from the fact that the - longer the tokens matched, the faster the scanner will run. This - is because with long tokens the processing of most input characters - takes place in the (short) inner scanning loop, and does not often - have to go through the additional work of setting up the scanning - environment (e.g., y̲y̲t̲e̲x̲t̲) for the action. Recall the scanner for - C comments: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* - "*"+[^*/\n]* - \n ++line_num; - "*"+"/" BEGIN(INITIAL); - - This could be sped up by writing it as: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* - [^*\n]*\n ++line_num; - "*"+[^*/\n]* - "*"+[^*/\n]*\n ++line_num; - "*"+"/" BEGIN(INITIAL); - - Now instead of each newline requiring the processing of another - action, recognizing the newlines is "distributed" over the other - rules to keep the matched text as long as possible. Note that - adding rules does n̲o̲t̲ slow down the scanner! The speed of the - scanner is independent of the number of rules or (modulo the con‐ - siderations given at the beginning of this section) how complicated - the rules are with regard to operators such as ‘*’ and ‘|’. - - A final example in speeding up a scanner: scan through a file con‐ - taining identifiers and keywords, one per line and with no other - extraneous characters, and recognize all the keywords. A natural - first approach is: - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - .|\n /* it's not a keyword */ - - To eliminate the back-tracking, introduce a catch-all rule: - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - [a-z]+ | - .|\n /* it's not a keyword */ - - Now, if it's guaranteed that there's exactly one word per line, - then we can reduce the total number of matches by a half by merging - in the recognition of newlines with that of the other tokens: - - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ - - [a-z]+\n | - .|\n /* it's not a keyword */ - - One has to be careful here, as we have now reintroduced backing up - into the scanner. In particular, while we know that there will - never be any characters in the input stream other than letters or - newlines, 𝗳𝗹𝗲𝘅 can't figure this out, and it will plan for possibly - needing to back up when it has scanned a token like "auto" and then - the next character is something other than a newline or a letter. - Previously it would then just match the "auto" rule and be done, - but now it has no "auto" rule, only an "auto\n" rule. To eliminate - the possibility of backing up, we could either duplicate all rules - but without final newlines or, since we never expect to encounter - such an input and therefore don't how it's classified, we can - introduce one more catch-all rule, this one which doesn't include a - newline: - - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ - - [a-z]+\n | - [a-z]+ | - .|\n /* it's not a keyword */ - - Compiled with -𝐂𝗳, this is about as fast as one can get a 𝗳𝗹𝗲𝘅 - scanner to go for this particular problem. - - A final note: 𝗳𝗹𝗲𝘅 is slow when matching NUL's, particularly when a - token contains multiple NUL's. It's best to write rules which - match short amounts of text if it's anticipated that the text will - often include NUL's. - - Another final note regarding performance: as mentioned above in the - section H̲O̲W̲ T̲H̲E̲ I̲N̲P̲U̲T̲ I̲S̲ M̲A̲T̲C̲H̲E̲D̲, dynamically resizing y̲y̲t̲e̲x̲t̲ to - accommodate huge tokens is a slow process because it presently - requires that the (huge) token be rescanned from the beginning. - Thus if performance is vital, it is better to attempt to match - "large" quantities of text but not "huge" quantities, where the - cutoff between the two is at about 8K characters/token. - -𝐆𝐄𝐍𝐄𝐑𝐀𝐓𝐈𝐍𝐆 𝐂++ 𝐒𝐂𝐀𝐍𝐍𝐄𝐑𝐒 - 𝗳𝗹𝗲𝘅 provides two different ways to generate scanners for use with - C++. The first way is to simply compile a scanner generated by - 𝗳𝗹𝗲𝘅 using a C++ compiler instead of a C compiler. This should not - generate any compilation errors (please report any found to the - email address given in the A̲U̲T̲H̲O̲R̲S̲ section below). C++ code can - then be used in rule actions instead of C code. Note that the - default input source for scanners remains y̲y̲i̲n̲, and default echoing - is still done to y̲y̲o̲u̲t̲. Both of these remain F̲I̲L̲E̲ *̲ variables and - not C++ streams. - - 𝗳𝗹𝗲𝘅 can also be used to generate a C++ scanner class, using the -+ - option (or, equivalently, “%option c++”), which is automatically - specified if the name of the flex executable ends in a ‘+’, such as - 𝗳𝗹𝗲𝘅++. When using this option, 𝗳𝗹𝗲𝘅 defaults to generating the - scanner to the file l̲e̲x̲.̲y̲y̲.̲c̲c̲ instead of l̲e̲x̲.̲y̲y̲.̲c̲. The generated - scanner includes the header file , which defines - the interface to two C++ classes. - - The first class, F̲l̲e̲x̲L̲e̲x̲e̲r̲, provides an abstract base class defin‐ - ing the general scanner class interface. It provides the following - member functions: - - const char* YYText() - Returns the text of the most recently matched token, the - equivalent of y̲y̲t̲e̲x̲t̲. - - int YYLeng() - Returns the length of the most recently matched token, the - equivalent of y̲y̲l̲e̲n̲g̲. - - int lineno() const - Returns the current input line number (see “%option - yylineno”), or 1 if “%option yylineno” was not used. - - void set_debug(int flag) - Sets the debugging flag for the scanner, equivalent to - assigning to y̲y̲_f̲l̲e̲x̲_d̲e̲b̲u̲g̲ (see the O̲P̲T̲I̲O̲N̲S̲ section above). - Note that the scanner must be built using “%option debug” - to include debugging information in it. - - int debug() const - Returns the current setting of the debugging flag. - - Also provided are member functions equivalent to - 𝘆𝘆_𝘀𝘄𝗶𝘁𝗰𝗵_𝘁𝗼_𝗯𝘂𝗳𝗳𝗲𝗿(), 𝘆𝘆_𝗰𝗿𝗲𝗮𝘁𝗲_𝗯𝘂𝗳𝗳𝗲𝗿() (though the first argu‐ - ment is an s̲t̲d̲:̲:̲i̲s̲t̲r̲e̲a̲m̲*̲ object pointer and not a F̲I̲L̲E̲*̲), - 𝘆𝘆_𝗳𝗹𝘂𝘀𝗵_𝗯𝘂𝗳𝗳𝗲𝗿(), 𝘆𝘆_𝗱𝗲𝗹𝗲𝘁𝗲_𝗯𝘂𝗳𝗳𝗲𝗿(), and 𝘆𝘆𝗿𝗲𝘀𝘁𝗮𝗿𝘁() (again, the - first argument is an s̲t̲d̲:̲:̲i̲s̲t̲r̲e̲a̲m̲*̲ object pointer). - - The second class defined in is y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲, which - is derived from F̲l̲e̲x̲L̲e̲x̲e̲r̲. It defines the following additional - member functions: - - yyFlexLexer(std::istream* arg_yyin = 0, std::ostream* arg_yyout = - 0) - Constructs a y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ object using the given streams for - input and output. If not specified, the streams default to - c̲i̲n̲ and c̲o̲u̲t̲, respectively. - - virtual int yylex() - Performs the same role as 𝘆𝘆𝗹𝗲𝘅() does for ordinary flex - scanners: it scans the input stream, consuming tokens, - until a rule's action returns a value. If subclass ‘S’ is - derived from y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲, in order to access the member - functions and variables of ‘S’ inside 𝘆𝘆𝗹𝗲𝘅(), use “%option - yyclass="S"” to inform 𝗳𝗹𝗲𝘅 that the ‘S’ subclass will be - used instead of y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲. In this case, rather than - generating “yyFlexLexer::yylex()”, 𝗳𝗹𝗲𝘅 generates - “S::yylex()” (and also generates a dummy - “yyFlexLexer::yylex()” that calls - “yyFlexLexer::LexerError()” if called). - - virtual void switch_streams(std::istream* new_in = 0, std::ostream* - new_out = 0) - Reassigns y̲y̲i̲n̲ to n̲e̲w̲_i̲n̲ (if non-nil) and y̲y̲o̲u̲t̲ to n̲e̲w̲_o̲u̲t̲ - (ditto), deleting the previous input buffer if y̲y̲i̲n̲ is - reassigned. - - int yylex(std::istream* new_in, std::ostream* new_out = 0) - First switches the input streams via - “switch_streams(new_in, new_out)” and then returns the - value of 𝘆𝘆𝗹𝗲𝘅(). - - In addition, y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ defines the following protected virtual - functions which can be redefined in derived classes to tailor the - scanner: - - virtual int LexerInput(char* buf, int max_size) - Reads up to m̲a̲x̲_s̲i̲z̲e̲ characters into b̲u̲f̲ and returns the - number of characters read. To indicate end-of-input, - return 0 characters. Note that "interactive" scanners (see - the -𝐁 and -𝐈 flags) define the macro YY_INTERACTIVE. If - 𝐋𝗲𝘅𝗲𝗿𝐈𝗻𝗽𝘂𝘁() has been redefined, and it's necessary to take - different actions depending on whether or not the scanner - might be scanning an interactive input source, it's possi‐ - ble to test for the presence of this name via “#ifdef”. - - virtual void LexerOutput(const char* buf, int size) - Writes out s̲i̲z̲e̲ characters from the buffer b̲u̲f̲, which, - while NUL-terminated, may also contain "internal" NUL's if - the scanner's rules can match text with NUL's in them. - - virtual void LexerError(const char* msg) - Reports a fatal error message. The default version of this - function writes the message to the stream c̲e̲r̲r̲ and exits. - - Note that a y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ object contains its entire scanning state. - Thus such objects can be used to create reentrant scanners. Multi‐ - ple instances of the same y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ class can be instantiated, - and multiple C++ scanner classes can be combined in the same pro‐ - gram using the -𝐏 option discussed above. - - Finally, note that the “%array” feature is not available to C++ - scanner classes; “%pointer” must be used (the default). - - Here is an example of a simple C++ scanner: - - // An example of using the flex C++ scanner class. - - %{ - #include - int mylineno = 0; - %} - - string \"[^\n"]+\" - - ws [ \t]+ - - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])* - num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} - - %% - - {ws} /* skip blanks and tabs */ - - "/*" { - int c; - - while ((c = yyinput()) != 0) { - if(c == '\n') - ++mylineno; - else if(c == '*') { - if ((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - - {number} cout << "number " << YYText() << '\n'; - - \n mylineno++; - - {name} cout << "name " << YYText() << '\n'; - - {string} cout << "string " << YYText() << '\n'; - - %% - - int main(int /* argc */, char** /* argv */) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } - - To create multiple (different) lexer classes, use the -𝐏 flag (or - the “prefix=” option) to rename each y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ to some other - x̲x̲F̲l̲e̲x̲L̲e̲x̲e̲r̲. can then be included in other - sources once per lexer class, first renaming y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲ as fol‐ - lows: - - #undef yyFlexLexer - #define yyFlexLexer xxFlexLexer - #include - - #undef yyFlexLexer - #define yyFlexLexer zzFlexLexer - #include - - If, for example, “%option prefix="xx"” is used for one scanner and - “%option prefix="zz"” is used for the other. - - 𝐈𝐌𝐏𝐎𝐑𝐓𝐀𝐍𝐓: the present form of the scanning class is experimental - and may change considerably between major releases. - -𝐈𝐍𝐂𝐎𝐌𝐏𝐀𝐓𝐈𝐁𝐈𝐋𝐈𝐓𝐈𝐄𝐒 𝐖𝐈𝐓𝐇 𝐋𝐄𝐗 𝐀𝐍𝐃 𝐏𝐎𝐒𝐈𝐗 - 𝗳𝗹𝗲𝘅 is a rewrite of the AT&T UNIX 𝗹𝗲𝘅 tool (the two implementa‐ - tions do not share any code, though), with some extensions and - incompatibilities, both of which are of concern to those who wish - to write scanners acceptable to either implementation. 𝗳𝗹𝗲𝘅 is - fully compliant with the POSIX 𝗹𝗲𝘅 specification, except that when - using “%pointer” (the default), a call to 𝘂𝗻𝗽𝘂𝘁() destroys the con‐ - tents of y̲y̲t̲e̲x̲t̲, which is counter to the POSIX specification. - - In this section we discuss all of the known areas of incompatibil‐ - ity between 𝗳𝗹𝗲𝘅, AT&T UNIX 𝗹𝗲𝘅, and the POSIX specification. - - 𝗳𝗹𝗲𝘅's -𝗹 option turns on maximum compatibility with the original - AT&T UNIX 𝗹𝗲𝘅 implementation, at the cost of a major loss in the - generated scanner's performance. We note below which incompatibil‐ - ities can be overcome using the -𝗹 option. - - 𝗳𝗹𝗲𝘅 is fully compatible with 𝗹𝗲𝘅 with the following exceptions: - - - The undocumented 𝗹𝗲𝘅 scanner internal variable y̲y̲l̲i̲n̲e̲n̲o̲ is not - supported unless -𝗹 or “%option yylineno” is used. - - y̲y̲l̲i̲n̲e̲n̲o̲ should be maintained on a per-buffer basis, rather - than a per-scanner (single global variable) basis. - - y̲y̲l̲i̲n̲e̲n̲o̲ is not part of the POSIX specification. - - - The 𝗶𝗻𝗽𝘂𝘁() routine is not redefinable, though it may be called - to read characters following whatever has been matched by a - rule. If 𝗶𝗻𝗽𝘂𝘁() encounters an end-of-file, the normal - 𝘆𝘆𝘄𝗿𝗮𝗽() processing is done. A “real” end-of-file is returned - by 𝗶𝗻𝗽𝘂𝘁() as EOF. - - Input is instead controlled by defining the YY_INPUT macro. - - The 𝗳𝗹𝗲𝘅 restriction that 𝗶𝗻𝗽𝘂𝘁() cannot be redefined is in - accordance with the POSIX specification, which simply does not - specify any way of controlling the scanner's input other than - by making an initial assignment to y̲y̲i̲n̲. - - - The 𝘂𝗻𝗽𝘂𝘁() routine is not redefinable. This restriction is in - accordance with POSIX. - - - 𝗳𝗹𝗲𝘅 scanners are not as reentrant as 𝗹𝗲𝘅 scanners. In partic‐ - ular, if a scanner is interactive and an interrupt handler - long-jumps out of the scanner, and the scanner is subsequently - called again, the following error message may be displayed: - - fatal flex scanner internal error--end of buffer missed - - To reenter the scanner, first use - - yyrestart(yyin); - - Note that this call will throw away any buffered input; usually - this isn't a problem with an interactive scanner. - - Also note that flex C++ scanner classes are reentrant, so if - using C++ is an option , they should be used instead. See - G̲E̲N̲E̲R̲A̲T̲I̲N̲G̲ C̲+̲+̲ S̲C̲A̲N̲N̲E̲R̲S̲ above for details. - - - 𝗼𝘂𝘁𝗽𝘂𝘁() is not supported. Output from the E̲C̲H̲O̲ macro is done - to the file-pointer y̲y̲o̲u̲t̲ (default stdout). - - 𝗼𝘂𝘁𝗽𝘂𝘁() is not part of the POSIX specification. - - - 𝗹𝗲𝘅 does not support exclusive start conditions (%x), though - they are in the POSIX specification. - - - When definitions are expanded, 𝗳𝗹𝗲𝘅 encloses them in parenthe‐ - ses. With 𝗹𝗲𝘅, the following: - - NAME [A-Z][A-Z0-9]* - %% - foo{NAME}? printf("Found it\n"); - %% - - will not match the string "foo" because when the macro is - expanded the rule is equivalent to "foo[A-Z][A-Z0-9]*?" and the - precedence is such that the ‘?’ is associated with "[A-Z0-9]*". - With 𝗳𝗹𝗲𝘅, the rule will be expanded to "foo([A-Z][A-Z0-9]*)?" - and so the string "foo" will match. - - Note that if the definition begins with ‘^’ or ends with ‘$’ - then it is not expanded with parentheses, to allow these opera‐ - tors to appear in definitions without losing their special - meanings. But the ‘⟨s⟩’, ‘/’, and ⟨⟨EOF⟩⟩ operators cannot be - used in a 𝗳𝗹𝗲𝘅 definition. - - Using -𝗹 results in the 𝗹𝗲𝘅 behavior of no parentheses around - the definition. - - The POSIX specification is that the definition be enclosed in - parentheses. - - - Some implementations of 𝗹𝗲𝘅 allow a rule's action to begin on a - separate line, if the rule's pattern has trailing whitespace: - - %% - foo|bar - { foobar_action(); } - - 𝗳𝗹𝗲𝘅 does not support this feature. - - - The 𝗹𝗲𝘅 ‘%r’ (generate a Ratfor scanner) option is not sup‐ - ported. It is not part of the POSIX specification. - - - After a call to 𝘂𝗻𝗽𝘂𝘁(), y̲y̲t̲e̲x̲t̲ is undefined until the next - token is matched, unless the scanner was built using “%array”. - This is not the case with 𝗹𝗲𝘅 or the POSIX specification. The - -𝗹 option does away with this incompatibility. - - - The precedence of the ‘{}’ (numeric range) operator is differ‐ - ent. 𝗹𝗲𝘅 interprets "abc{1,3}" as match one, two, or three - occurrences of ‘abc’, whereas 𝗳𝗹𝗲𝘅 interprets it as match ‘ab’ - followed by one, two, or three occurrences of ‘c’. The latter - is in agreement with the POSIX specification. - - - The precedence of the ‘^’ operator is different. 𝗹𝗲𝘅 inter‐ - prets "^foo|bar" as match either ‘foo’ at the beginning of a - line, or ‘bar’ anywhere, whereas 𝗳𝗹𝗲𝘅 interprets it as match - either ‘foo’ or ‘bar’ if they come at the beginning of a line. - The latter is in agreement with the POSIX specification. - - - The special table-size declarations such as ‘%a’ supported by - 𝗹𝗲𝘅 are not required by 𝗳𝗹𝗲𝘅 scanners; 𝗳𝗹𝗲𝘅 ignores them. - - - The name FLEX_SCANNER is #define'd so scanners may be written - for use with either 𝗳𝗹𝗲𝘅 or 𝗹𝗲𝘅. Scanners also include - YY_FLEX_MAJOR_VERSION and YY_FLEX_MINOR_VERSION indicating - which version of 𝗳𝗹𝗲𝘅 generated the scanner (for example, for - the 2.5 release, these defines would be 2 and 5, respectively). - - The following 𝗳𝗹𝗲𝘅 features are not included in 𝗹𝗲𝘅 or the POSIX - specification: - - C++ scanners - %option - start condition scopes - start condition stacks - interactive/non-interactive scanners - yy_scan_string() and friends - yyterminate() - yy_set_interactive() - yy_set_bol() - YY_AT_BOL() - <> - <*> - YY_DECL - YY_START - YY_USER_ACTION - YY_USER_INIT - #line directives - %{}'s around actions - multiple actions on a line - - plus almost all of the 𝗳𝗹𝗲𝘅 flags. The last feature in the list - refers to the fact that with 𝗳𝗹𝗲𝘅 multiple actions can be placed on - the same line, separated with semi-colons, while with 𝗹𝗲𝘅, the fol‐ - lowing - - foo handle_foo(); ++num_foos_seen; - - is (rather surprisingly) truncated to - - foo handle_foo(); - - 𝗳𝗹𝗲𝘅 does not truncate the action. Actions that are not enclosed - in braces are simply terminated at the end of the line. - -𝐅𝐈𝐋𝐄𝐒 - flex.skl Skeleton scanner. This file is only used when - building flex, not when 𝗳𝗹𝗲𝘅 executes. - - lex.backup Backing-up information for the -𝗯 flag (called - l̲e̲x̲.̲b̲c̲k̲ on some systems). - - lex.yy.c Generated scanner (called l̲e̲x̲y̲y̲.̲c̲ on some sys‐ - tems). - - lex.yy.cc Generated C++ scanner class, when using -+. - - Header file defining the C++ scanner base class, - F̲l̲e̲x̲L̲e̲x̲e̲r̲, and its derived class, y̲y̲F̲l̲e̲x̲L̲e̲x̲e̲r̲. - - /usr/lib/libl.* 𝗳𝗹𝗲𝘅 libraries. The /̲u̲s̲r̲/̲l̲i̲b̲/̲l̲i̲b̲f̲l̲.̲*̲ libraries - are links to these. Scanners must be linked - using either -𝗹𝗹 or -𝗹𝗳𝗹. - -𝐄𝐗𝐈𝐓 𝐒𝐓𝐀𝐓𝐔𝐒 - The 𝗳𝗹𝗲𝘅 utility exits 0 on success, and >0 if an error occurs. - -𝐃𝐈𝐀𝐆𝐍𝐎𝐒𝐓𝐈𝐂𝐒 - 𝘄𝗮𝗿𝗻𝗶𝗻𝗴, 𝗿𝘂𝗹𝗲 𝗰𝗮𝗻𝗻𝗼𝘁 𝗯𝗲 𝗺𝗮𝘁𝗰𝗵𝗲𝗱 Indicates that the given rule can‐ - not be matched because it follows other rules that will always - match the same text as it. For example, in the following “foo” - cannot be matched because it comes after an identifier "catch-all" - rule: - - [a-z]+ got_identifier(); - foo got_foo(); - - Using R̲E̲J̲E̲C̲T̲ in a scanner suppresses this warning. - - 𝘄𝗮𝗿𝗻𝗶𝗻𝗴, -𝘀 𝗼𝗽𝘁𝗶𝗼𝗻 𝗴𝗶𝘃𝗲𝗻 𝗯𝘂𝘁 𝗱𝗲𝗳𝗮𝘂𝗹𝘁 𝗿𝘂𝗹𝗲 𝗰𝗮𝗻 𝗯𝗲 𝗺𝗮𝘁𝗰𝗵𝗲𝗱 Means - that it is possible (perhaps only in a particular start condition) - that the default rule (match any single character) is the only one - that will match a particular input. Since -𝘀 was given, presumably - this is not intended. - - 𝗿𝗲𝗷𝗲𝗰𝘁_𝘂𝘀𝗲𝗱_𝗯𝘂𝘁_𝗻𝗼𝘁_𝗱𝗲𝘁𝗲𝗰𝘁𝗲𝗱 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱 - 𝘆𝘆𝗺𝗼𝗿𝗲_𝘂𝘀𝗲𝗱_𝗯𝘂𝘁_𝗻𝗼𝘁_𝗱𝗲𝘁𝗲𝗰𝘁𝗲𝗱 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱 These errors can occur at - compile time. They indicate that the scanner uses R̲E̲J̲E̲C̲T̲ or - 𝘆𝘆𝗺𝗼𝗿𝗲() but that 𝗳𝗹𝗲𝘅 failed to notice the fact, meaning that 𝗳𝗹𝗲𝘅 - scanned the first two sections looking for occurrences of these - actions and failed to find any, but somehow they snuck in (via an - #include file, for example). Use “%option reject” or “%option - yymore” to indicate to 𝗳𝗹𝗲𝘅 that these features are really needed. - - 𝗳𝗹𝗲𝘅 𝘀𝗰𝗮𝗻𝗻𝗲𝗿 𝗷𝗮𝗺𝗺𝗲𝗱 A scanner compiled with -𝘀 has encountered an - input string which wasn't matched by any of its rules. This error - can also occur due to internal problems. - - 𝘁𝗼𝗸𝗲𝗻 𝘁𝗼𝗼 𝗹𝗮𝗿𝗴𝗲, 𝗲𝘅𝗰𝗲𝗲𝗱𝘀 𝐘𝐘𝐋𝐌𝐀𝐗 The scanner uses “%array” and one - of its rules matched a string longer than the YYLMAX constant (8K - bytes by default). The value can be increased by #define'ing - YYLMAX in the definitions section of 𝗳𝗹𝗲𝘅 input. - - 𝘀𝗰𝗮𝗻𝗻𝗲𝗿 𝗿𝗲𝗾𝘂𝗶𝗿𝗲𝘀 -𝟴 𝗳𝗹𝗮𝗴 𝘁𝗼 𝘂𝘀𝗲 𝘁𝗵𝗲 𝗰𝗵𝗮𝗿𝗮𝗰𝘁𝗲𝗿 '𝘅' The scanner - specification includes recognizing the 8-bit character ‘x’ and the - -𝟴 flag was not specified, and defaulted to 7-bit because the -𝐂𝗳 - or -𝐂𝐅 table compression options were used. See the discussion of - the -𝟳 flag for details. - - 𝗳𝗹𝗲𝘅 𝘀𝗰𝗮𝗻𝗻𝗲𝗿 𝗽𝘂𝘀𝗵-𝗯𝗮𝗰𝗸 𝗼𝘃𝗲𝗿𝗳𝗹𝗼𝘄 unput() was used to push back so - much text that the scanner's buffer could not hold both the pushed- - back text and the current token in y̲y̲t̲e̲x̲t̲. Ideally the scanner - should dynamically resize the buffer in this case, but at present - it does not. - - 𝗶𝗻𝗽𝘂𝘁 𝗯𝘂𝗳𝗳𝗲𝗿 𝗼𝘃𝗲𝗿𝗳𝗹𝗼𝘄, 𝗰𝗮𝗻'𝘁 𝗲𝗻𝗹𝗮𝗿𝗴𝗲 𝗯𝘂𝗳𝗳𝗲𝗿 𝗯𝗲𝗰𝗮𝘂𝘀𝗲 𝘀𝗰𝗮𝗻𝗻𝗲𝗿 𝘂𝘀𝗲𝘀 - 𝐑𝐄𝐉𝐄𝐂𝐓 The scanner was working on matching an extremely large - token and needed to expand the input buffer. This doesn't work - with scanners that use R̲E̲J̲E̲C̲T̲. - - 𝗳𝗮𝘁𝗮𝗹 𝗳𝗹𝗲𝘅 𝘀𝗰𝗮𝗻𝗻𝗲𝗿 𝗶𝗻𝘁𝗲𝗿𝗻𝗮𝗹 𝗲𝗿𝗿𝗼𝗿--𝗲𝗻𝗱 𝗼𝗳 𝗯𝘂𝗳𝗳𝗲𝗿 𝗺𝗶𝘀𝘀𝗲𝗱 This can - occur in an scanner which is reentered after a long-jump has jumped - out (or over) the scanner's activation frame. Before reentering - the scanner, use: - - yyrestart(yyin); - - or, as noted above, switch to using the C++ scanner class. - - 𝘁𝗼𝗼 𝗺𝗮𝗻𝘆 𝘀𝘁𝗮𝗿𝘁 𝗰𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀 𝗶𝗻 <> 𝗰𝗼𝗻𝘀𝘁𝗿𝘂𝗰𝘁! More start conditions - than exist were listed in a <> construct (so at least one of them - must have been listed twice). - -𝐒𝐄𝐄 𝐀𝐋𝐒𝐎 - awk(1), sed(1), yacc(1) - - John Levine, Tony Mason, and Doug Brown, L̲e̲x̲ &̲ Y̲a̲c̲c̲, O̲'̲R̲e̲i̲l̲l̲y̲ a̲n̲d̲ - A̲s̲s̲o̲c̲i̲a̲t̲e̲s̲, 2nd edition. - - Alfred Aho, Ravi Sethi, and Jeffrey Ullman, C̲o̲m̲p̲i̲l̲e̲r̲s̲:̲ P̲r̲i̲n̲c̲i̲p̲l̲e̲s̲,̲ - T̲e̲c̲h̲n̲i̲q̲u̲e̲s̲ a̲n̲d̲ T̲o̲o̲l̲s̲, A̲d̲d̲i̲s̲o̲n̲-̲W̲e̲s̲l̲e̲y̲, 1986, Describes the pattern- - matching techniques used by flex (deterministic finite automata). - -𝐒𝐓𝐀𝐍𝐃𝐀𝐑𝐃𝐒 - The 𝗹𝗲𝘅 utility is compliant with the IEEE Std 1003.1-2008 - (“POSIX.1”) specification, though its presence is optional. - - The flags [-𝟳𝟴𝐁𝗯𝐂𝗱𝐅𝗳𝗵𝐈𝗶𝐋𝗹𝗼𝐏𝗽𝐒𝘀𝐓𝐕𝘄+?], [--𝗵𝗲𝗹𝗽], and [--𝘃𝗲𝗿𝘀𝗶𝗼𝗻] are - extensions to that specification. - - See also the I̲N̲C̲O̲M̲P̲A̲T̲I̲B̲I̲L̲I̲T̲I̲E̲S̲ W̲I̲T̲H̲ L̲E̲X̲ A̲N̲D̲ P̲O̲S̲I̲X̲ section, above. - -𝐀𝐔𝐓𝐇𝐎𝐑𝐒 - Vern Paxson, with the help of many ideas and much inspiration from - Van Jacobson. Original version by Jef Poskanzer. The fast table - representation is a partial implementation of a design done by Van - Jacobson. The implementation was done by Kevin Gong and Vern Pax‐ - son. - - Thanks to the many 𝗳𝗹𝗲𝘅 beta-testers, feedbackers, and contribu‐ - tors, especially Francois Pinard, Casey Leedom, Robert Abramovitz, - Stan Adermann, Terry Allen, David Barker-Plummer, John Basrai, Neal - Becker, Nelson H.F. Beebe, b̲e̲n̲s̲o̲n̲@̲o̲d̲i̲.̲c̲o̲m̲, Karl Berry, Peter A. - Bigot, Simon Blanchard, Keith Bostic, Frederic Brehm, Ian Brock‐ - bank, Kin Cho, Nick Christopher, Brian Clapper, J.T. Conklin, Jason - Coughlin, Bill Cox, Nick Cropper, Dave Curtis, Scott David Daniels, - Chris G. Demetriou, Theo de Raadt, Mike Donahue, Chuck Doucette, - Tom Epperly, Leo Eskin, Chris Faylor, Chris Flatters, Jon Forrest, - Jeffrey Friedl, Joe Gayda, Kaveh R. Ghazi, Wolfgang Glunz, Eric - Goldman, Christopher M. Gould, Ulrich Grepel, Peer Griebel, Jan - Hajic, Charles Hemphill, NORO Hideo, Jarkko Hietaniemi, Scott Hof‐ - mann, Jeff Honig, Dana Hudes, Eric Hughes, John Interrante, Ceriel - Jacobs, Michal Jaegermann, Sakari Jalovaara, Jeffrey R. Jones, - Henry Juengst, Klaus Kaempf, Jonathan I. Kamens, Terrence O Kane, - Amir Katz, k̲e̲n̲@̲k̲e̲n̲.̲h̲i̲l̲c̲o̲.̲c̲o̲m̲, Kevin B. Kenny, Steve Kirsch, Win‐ - fried Koenig, Marq Kole, Ronald Lamprecht, Greg Lee, Rohan Lenard, - Craig Leres, John Levine, Steve Liddle, David Loffredo, Mike Long, - Mohamed el Lozy, Brian Madsen, Malte, Joe Marshall, Bengt Martens‐ - son, Chris Metcalf, Luke Mewburn, Jim Meyering, R. Alexander - Milowski, Erik Naggum, G.T. Nicol, Landon Noll, James Nordby, Marc - Nozell, Richard Ohnemus, Karsten Pahnke, Sven Panne, Roland Pesch, - Walter Pelissero, Gaumond Pierre, Esmond Pitt, Jef Poskanzer, Joe - Rahmeh, Jarmo Raiha, Frederic Raimbault, Pat Rankin, Rick Richard‐ - son, Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, Alberto Santini, - Andreas Scherer, Darrell Schiebel, Raf Schietekat, Doug Schmidt, - Philippe Schnoebelen, Andreas Schwab, Larry Schwimmer, Alex Siegel, - Eckehard Stolz, Jan-Erik Strvmquist, Mike Stump, Paul Stuart, Dave - Tallman, Ian Lance Taylor, Chris Thewalt, Richard M. Timoney, Jodi - Tsai, Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, - Kent Williams, Ken Yap, Ron Zellar, Nathan Zelle, David Zuhn, and - those whose names have slipped my marginal mail-archiving skills - but whose contributions are appreciated all the same. - - Thanks to Keith Bostic, Jon Forrest, Noah Friedman, John Gilmore, - Craig Leres, John Levine, Bob Mulcahy, G.T. Nicol, Francois - Pinard, Rich Salz, and Richard Stallman for help with various dis‐ - tribution headaches. - - Thanks to Esmond Pitt and Earle Horton for 8-bit character support; - to Benson Margulies and Fred Burke for C++ support; to Kent - Williams and Tom Epperly for C++ class support; to Ove Ewerlid for - support of NUL's; and to Eric Hughes for support of multiple buf‐ - fers. - - This work was primarily done when I was with the Real Time Systems - Group at the Lawrence Berkeley Laboratory in Berkeley, CA. Many - thanks to all there for the support I received. - - Send comments to ⟨v̲e̲r̲n̲@̲e̲e̲.̲l̲b̲l̲.̲g̲o̲v̲⟩. - -𝐁𝐔𝐆𝐒 - Some trailing context patterns cannot be properly matched and gen‐ - erate warning messages (dangerous trailing context). These are - patterns where the ending of the first part of the rule matches the - beginning of the second part, such as "zx*/xy*", where the ‘x*’ - matches the ‘x’ at the beginning of the trailing context. (Note - that the POSIX draft states that the text matched by such patterns - is undefined.) - - For some trailing context rules, parts which are actually fixed- - length are not recognized as such, leading to the above mentioned - performance loss. In particular, parts using ‘|’ or ‘{n}’ (such as - "foo{3}") are always considered variable-length. - - Combining trailing context with the special ‘|’ action can result - in fixed trailing context being turned into the more expensive - variable trailing context. For example, in the following: - - %% - abc | - xyz/def - - Use of 𝘂𝗻𝗽𝘂𝘁() invalidates yytext and yyleng, unless the “%array” - directive or the -𝗹 option has been used. - - Pattern-matching of NUL's is substantially slower than matching - other characters. - - Dynamic resizing of the input buffer is slow, as it entails rescan‐ - ning all the text matched so far by the current (generally huge) - token. - - Due to both buffering of input and read-ahead, it is not possible - to intermix calls to routines, such as, for example, - 𝗴𝗲𝘁𝗰𝗵𝗮𝗿(), with 𝗳𝗹𝗲𝘅 rules and expect it to work. Call 𝗶𝗻𝗽𝘂𝘁() - instead. - - The total table entries listed by the -𝘃 flag excludes the number - of table entries needed to determine what rule has been matched. - The number of entries is equal to the number of DFA states if the - scanner does not use R̲E̲J̲E̲C̲T̲, and somewhat greater than the number - of states if it does. - - R̲E̲J̲E̲C̲T̲ cannot be used with the -𝗳 or -𝐅 options. - - The 𝗳𝗹𝗲𝘅 internal algorithms need documentation. - -COSMOPOLITAN September 21, 2015 BSD diff --git a/third_party/lex/buf.c b/third_party/lex/buf.c deleted file mode 100644 index c2ed76c8..00000000 --- a/third_party/lex/buf.c +++ /dev/null @@ -1,286 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ -/* clang-format off */ -/* $OpenBSD: buf.c,v 1.7 2015/11/20 18:54:49 tedu Exp $ */ - -/* flex - tool to generate fast lexical analyzers */ - -/* 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. */ - - -#include "libc/str/str.h" -#include "libc/mem/mem.h" -#include "libc/fmt/fmt.h" -#include "libc/math.h" -#include "libc/fmt/conv.h" -#include "flexdef.h" - -/* Take note: The buffer object is sometimes used as a String buffer (one - * continuous string), and sometimes used as a list of strings, usually line by - * line. - * - * The type is specified in buf_init by the elt_size. If the elt_size is - * sizeof(char), then the buffer should be treated as string buffer. If the - * elt_size is sizeof(char*), then the buffer should be treated as a list of - * strings. - * - * Certain functions are only appropriate for one type or the other. - */ - -/* global buffers. */ -struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */ -struct Buf defs_buf; /**< for #define's autogenerated. List of strings. */ -struct Buf yydmap_buf; /**< string buffer to hold yydmap elements */ -struct Buf m4defs_buf; /**< m4 definitions. List of strings. */ -struct Buf top_buf; /**< contains %top code. String buffer. */ - -struct Buf * -buf_print_strings(struct Buf * buf, FILE * out) -{ - int i; - - if (!buf || !out) - return buf; - - for (i = 0; i < buf->nelts; i++) { - const char *s = ((char **) buf->elts)[i]; - if (s) - fprintf(out, "%s", s); - } - return buf; -} - -/* Append a "%s" formatted string to a string buffer */ -struct Buf * -buf_prints(struct Buf * buf, const char *fmt, const char *s) -{ - char *t; - size_t tsz; - - tsz = strlen(fmt) + strlen(s) + 1; - t = malloc(tsz); - if (!t) - flexfatal(_("Allocation of buffer to print string failed")); - snprintf(t, tsz, fmt, s); - buf = buf_strappend(buf, t); - free(t); - return buf; -} - -/** Append a line directive to the string buffer. - * @param buf A string buffer. - * @param filename file name - * @param lineno line number - * @return buf - */ -struct Buf * -buf_linedir(struct Buf * buf, const char *filename, int lineno) -{ - const char *src; - char *dst, *t; - size_t tsz; - - tsz = strlen("#line \"\"\n") + /* constant parts */ - 2 * strlen(filename) + /* filename with possibly all backslashes escaped */ - (int) (1 + log10(abs(lineno))) + /* line number */ - 1; /* NUL */ - t = malloc(tsz); - if (!t) - flexfatal(_("Allocation of buffer for line directive failed")); - dst = t + snprintf(t, tsz, "#line %d \"", lineno); - for (src = filename; *src; *dst++ = *src++) - if (*src == '\\') /* escape backslashes */ - *dst++ = '\\'; - *dst++ = '"'; - *dst++ = '\n'; - *dst = '\0'; - buf = buf_strappend(buf, t); - free(t); - return buf; -} - - -/** Append the contents of @a src to @a dest. - * @param @a dest the destination buffer - * @param @a dest the source buffer - * @return @a dest - */ -struct Buf * -buf_concat(struct Buf * dest, const struct Buf * src) -{ - buf_append(dest, src->elts, src->nelts); - return dest; -} - - -/* Appends n characters in str to buf. */ -struct Buf * -buf_strnappend(struct Buf *buf, const char *str, int n) -{ - buf_append(buf, str, n + 1); - - /* "undo" the '\0' character that buf_append() already copied. */ - buf->nelts--; - - return buf; -} - -/* Appends characters in str to buf. */ -struct Buf * -buf_strappend(struct Buf *buf, const char *str) -{ - return buf_strnappend(buf, str, strlen(str)); -} - -/* appends "#define str def\n" */ -struct Buf * -buf_strdefine(struct Buf *buf, const char *str, const char *def2) -{ - buf_strappend(buf, "#define "); - buf_strappend(buf, " "); - buf_strappend(buf, str); - buf_strappend(buf, " "); - buf_strappend(buf, def2); - buf_strappend(buf, "\n"); - return buf; -} - -/** Pushes "m4_define( [[def]], [[val]])m4_dnl" to end of buffer. - * @param buf A buffer as a list of strings. - * @param def The m4 symbol to define. - * @param val The definition; may be NULL. - * @return buf - */ -struct Buf * -buf_m4_define(struct Buf * buf, const char *def2, const char *val) -{ - const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n"; - char *str; - size_t strsz; - - val = val ? val : ""; - strsz = strlen(fmt) + strlen(def2) + strlen(val) + 2; - str = malloc(strsz); - if (!str) - flexfatal(_("Allocation of buffer for m4 def failed")); - - snprintf(str, strsz, fmt, def2, val); - buf_append(buf, &str, 1); - return buf; -} - -/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer. - * @param buf A buffer as a list of strings. - * @param def The m4 symbol to undefine. - * @return buf - */ -struct Buf * -buf_m4_undefine(struct Buf * buf, const char *def2) -{ - const char *fmt = "m4_undefine( [[%s]])m4_dnl\n"; - char *str; - size_t strsz; - - strsz = strlen(fmt) + strlen(def2) + 2; - str = malloc(strsz); - if (!str) - flexfatal(_("Allocation of buffer for m4 undef failed")); - - snprintf(str, strsz, fmt, def2); - buf_append(buf, &str, 1); - return buf; -} - -/* create buf with 0 elements, each of size elem_size. */ -void -buf_init(struct Buf *buf, size_t elem_size) -{ - buf->elts = NULL; - buf->nelts = 0; - buf->elt_size = elem_size; - buf->nmax = 0; -} - -/* frees memory */ -void -buf_destroy(struct Buf *buf) -{ - free(buf->elts); - buf->elts = NULL; -} - - -/* appends ptr[] to buf, grow if necessary. - * n_elem is number of elements in ptr[], NOT bytes. - * returns buf. - * We grow by mod(512) boundaries. - */ - -struct Buf * -buf_append(struct Buf *buf, const void *ptr, int n_elem) -{ - int n_alloc = 0; - - if (!ptr || n_elem == 0) - return buf; - - /* May need to alloc more. */ - if (n_elem + buf->nelts > buf->nmax) { - - /* exact amount needed... */ - n_alloc = (n_elem + buf->nelts) * buf->elt_size; - - /* ...plus some extra */ - if (((n_alloc * buf->elt_size) % 512) != 0 - && buf->elt_size < 512) - n_alloc += - (512 - - ((n_alloc * buf->elt_size) % 512)) / - buf->elt_size; - - if (!buf->elts) - buf->elts = - allocate_array(n_alloc, buf->elt_size); - else - buf->elts = - reallocate_array(buf->elts, n_alloc, - buf->elt_size); - - buf->nmax = n_alloc; - } - memcpy((char *) buf->elts + buf->nelts * buf->elt_size, ptr, - n_elem * buf->elt_size); - buf->nelts += n_elem; - - return buf; -} diff --git a/third_party/lex/ccl.c b/third_party/lex/ccl.c deleted file mode 100644 index e7d69d05..00000000 --- a/third_party/lex/ccl.c +++ /dev/null @@ -1,325 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ -/* clang-format off */ -/* $OpenBSD: ccl.c,v 1.8 2015/11/19 22:55:13 tedu Exp $ */ - -/* ccl - routines for character classes */ - -/* 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. */ - -#include "libc/str/str.h" -#include "flexdef.h" - -/* return true if the chr is in the ccl. Takes negation into account. */ -static bool -ccl_contains(const int cclp, const int ch) -{ - int ind, len, i; - - len = ccllen[cclp]; - ind = cclmap[cclp]; - - for (i = 0; i < len; ++i) - if (ccltbl[ind + i] == ch) - return !cclng[cclp]; - - return cclng[cclp]; -} - - -/* ccladd - add a single character to a ccl */ - -void -ccladd(cclp, ch) - int cclp; - int ch; -{ - int ind, len, newpos, i; - - check_char(ch); - - len = ccllen[cclp]; - ind = cclmap[cclp]; - - /* check to see if the character is already in the ccl */ - - for (i = 0; i < len; ++i) - if (ccltbl[ind + i] == ch) - return; - - /* mark newlines */ - if (ch == nlch) - ccl_has_nl[cclp] = true; - - newpos = ind + len; - - if (newpos >= current_max_ccl_tbl_size) { - current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT; - - ++num_reallocs; - - ccltbl = reallocate_Character_array(ccltbl, - current_max_ccl_tbl_size); - } - ccllen[cclp] = len + 1; - ccltbl[newpos] = ch; -} - -/* dump_cclp - same thing as list_character_set, but for cclps. */ - -static void -dump_cclp(FILE * file, int cclp) -{ - int i; - - putc('[', file); - - for (i = 0; i < csize; ++i) { - if (ccl_contains(cclp, i)) { - int start_char = i; - - putc(' ', file); - - fputs(readable_form(i), file); - - while (++i < csize && ccl_contains(cclp, i)); - - if (i - 1 > start_char) - /* this was a run */ - fprintf(file, "-%s", - readable_form(i - 1)); - - putc(' ', file); - } - } - - putc(']', file); -} - - - -/* ccl_set_diff - create a new ccl as the set difference of the two given ccls. */ -int -ccl_set_diff(int a, int b) -{ - int d, ch; - - /* create new class */ - d = cclinit(); - - /* - * In order to handle negation, we spin through all possible chars, - * addding each char in a that is not in b. (This could be O(n^2), - * but n is small and bounded.) - */ - for (ch = 0; ch < csize; ++ch) - if (ccl_contains(a, ch) && !ccl_contains(b, ch)) - ccladd(d, ch); - - /* debug */ - if (0) { - fprintf(stderr, "ccl_set_diff ("); - fprintf(stderr, "\n "); - dump_cclp(stderr, a); - fprintf(stderr, "\n "); - dump_cclp(stderr, b); - fprintf(stderr, "\n "); - dump_cclp(stderr, d); - fprintf(stderr, "\n)\n"); - } - return d; -} - -/* ccl_set_union - create a new ccl as the set union of the two given ccls. */ -int -ccl_set_union(int a, int b) -{ - int d, i; - - /* create new class */ - d = cclinit(); - - /* Add all of a */ - for (i = 0; i < ccllen[a]; ++i) - ccladd(d, ccltbl[cclmap[a] + i]); - - /* Add all of b */ - for (i = 0; i < ccllen[b]; ++i) - ccladd(d, ccltbl[cclmap[b] + i]); - - /* debug */ - if (0) { - fprintf(stderr, "ccl_set_union (%d + %d = %d", a, b, d); - fprintf(stderr, "\n "); - dump_cclp(stderr, a); - fprintf(stderr, "\n "); - dump_cclp(stderr, b); - fprintf(stderr, "\n "); - dump_cclp(stderr, d); - fprintf(stderr, "\n)\n"); - } - return d; -} - - -/* cclinit - return an empty ccl */ - -int -cclinit() -{ - if (++lastccl >= current_maxccls) { - current_maxccls += MAX_CCLS_INCREMENT; - - ++num_reallocs; - - cclmap = - reallocate_integer_array(cclmap, current_maxccls); - ccllen = - reallocate_integer_array(ccllen, current_maxccls); - cclng = reallocate_integer_array(cclng, current_maxccls); - ccl_has_nl = - reallocate_bool_array(ccl_has_nl, - current_maxccls); - } - if (lastccl == 1) - /* we're making the first ccl */ - cclmap[lastccl] = 0; - - else - /* - * The new pointer is just past the end of the last ccl. - * Since the cclmap points to the \first/ character of a ccl, - * adding the length of the ccl to the cclmap pointer will - * produce a cursor to the first free space. - */ - cclmap[lastccl] = - cclmap[lastccl - 1] + ccllen[lastccl - 1]; - - ccllen[lastccl] = 0; - cclng[lastccl] = 0; /* ccl's start out life un-negated */ - ccl_has_nl[lastccl] = false; - - return lastccl; -} - - -/* cclnegate - negate the given ccl */ - -void -cclnegate(cclp) - int cclp; -{ - cclng[cclp] = 1; - ccl_has_nl[cclp] = !ccl_has_nl[cclp]; -} - - -/* list_character_set - list the members of a set of characters in CCL form - * - * Writes to the given file a character-class representation of those - * characters present in the given CCL. A character is present if it - * has a non-zero value in the cset array. - */ - -void -list_character_set(file, cset) - FILE *file; - int cset[]; -{ - int i; - - putc('[', file); - - for (i = 0; i < csize; ++i) { - if (cset[i]) { - int start_char = i; - - putc(' ', file); - - fputs(readable_form(i), file); - - while (++i < csize && cset[i]); - - if (i - 1 > start_char) - /* this was a run */ - fprintf(file, "-%s", - readable_form(i - 1)); - - putc(' ', file); - } - } - - putc(']', file); -} - -/** Determines if the range [c1-c2] is unambiguous in a case-insensitive - * scanner. Specifically, if a lowercase or uppercase character, x, is in the - * range [c1-c2], then we require that UPPERCASE(x) and LOWERCASE(x) must also - * be in the range. If not, then this range is ambiguous, and the function - * returns false. For example, [@-_] spans [a-z] but not [A-Z]. Beware that - * [a-z] will be labeled ambiguous because it does not include [A-Z]. - * - * @param c1 the lower end of the range - * @param c2 the upper end of the range - * @return true if [c1-c2] is not ambiguous for a caseless scanner. - */ -bool -range_covers_case(int c1, int c2) -{ - int i, o; - - for (i = c1; i <= c2; i++) { - if (has_case(i)) { - o = reverse_case(i); - if (o < c1 || c2 < o) - return false; - } - } - return true; -} - -/** Reverse the case of a character, if possible. - * @return c if case-reversal does not apply. - */ -int -reverse_case(int c) -{ - return isupper(c) ? tolower(c) : (islower(c) ? toupper(c) : c); -} - -/** Return true if c is uppercase or lowercase. */ -bool -has_case(int c) -{ - return (isupper(c) || islower(c)) ? true : false; -} diff --git a/third_party/lex/config.h b/third_party/lex/config.h deleted file mode 100644 index 0b3f42da..00000000 --- a/third_party/lex/config.h +++ /dev/null @@ -1,207 +0,0 @@ -/* $OpenBSD: config.h,v 1.5 2015/11/19 23:48:06 tedu Exp $ */ - -/* config.h. Generated from conf.in by configure. */ -/* conf.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -/* #undef HAVE_CFLOCALECOPYCURRENT */ - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ - -/* Define if the GNU dcgettext() function is already present or preinstalled. - */ -/* #undef HAVE_DCGETTEXT */ - -/* Define to 1 if you have the header file. */ -/* #define HAVE_DLFCN_H 1 */ - -/* Define to 1 if you have the `dup2' function. */ -#define HAVE_DUP2 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - -/* Define if the GNU gettext() function is already present or preinstalled. */ -/* #undef HAVE_GETTEXT */ - -/* Define if you have the iconv() function and it works. */ -#define HAVE_ICONV 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `isascii' function. */ -#define HAVE_ISASCII 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBINTL_H */ - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* pthread library */ -#define HAVE_LIBPTHREAD 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -/* #define HAVE_LOCALE_H 1 */ - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the header file. */ -/* #define HAVE_NETINET_IN_H 1 */ - -/* Define to 1 if you have the `pow' function. */ -#define HAVE_POW 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_PTHREAD_H 1 - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#define HAVE_REALLOC 1 - -/* Define to 1 if you have the `regcomp' function. */ -#define HAVE_REGCOMP 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_REGEX_H 1 - -/* Define to 1 if you have the `setlocale' function. */ -/* #define HAVE_SETLOCALE 1 */ - -/* Define to 1 if stdbool.h conforms to C99. */ -#define HAVE_STDBOOL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `vfork' function. */ -#define HAVE_VFORK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VFORK_H */ - -/* Define to 1 if `fork' works. */ -#define HAVE_WORKING_FORK 1 - -/* Define to 1 if `vfork' works. */ -#define HAVE_WORKING_VFORK 1 - -/* Define to 1 if the system has the type `_Bool'. */ -#define HAVE__BOOL 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Define to the m4 executable name. */ -#define M4 "o/$(MODE)/third_party/m4/m4.com.dbg" - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Name of package */ -#define PACKAGE "flex" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "flex-help@lists.sourceforge.net" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "the fast lexical analyser generator" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "the fast lexical analyser generator 2.5.39" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "flex" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "2.5.39" - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "2.5.39" - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#define YYTEXT_POINTER 1 - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to rpl_malloc if the replacement function should be used. */ -/* #undef malloc */ - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Define to rpl_realloc if the replacement function should be used. */ -/* #undef realloc */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define as `fork' if `vfork' does not work. */ -/* #undef vfork */ - -#define HAVE_ASSERT_H diff --git a/third_party/lex/dfa.c b/third_party/lex/dfa.c deleted file mode 100644 index 8ca6b5ce..00000000 --- a/third_party/lex/dfa.c +++ /dev/null @@ -1,1105 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -/* $OpenBSD: dfa.c,v 1.8 2015/11/19 23:20:34 tedu Exp $ */ - -/* dfa - DFA construction routines */ - -/* 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. */ - -/* 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. */ - -#include "flexdef.h" -#include "libc/alg/alg.h" -#include "libc/mem/mem.h" -#include "tables.h" - -/* declare functions that have forward references */ - -void dump_associated_rules PROTO ((FILE *, int)); -void dump_transitions PROTO ((FILE *, int[])); -void sympartition PROTO ((int[], int, int[], int[])); -int symfollowset PROTO ((int[], int, int, int[])); - - -/* check_for_backing_up - check a DFA state for backing up - * - * synopsis - * void check_for_backing_up( int ds, int state[numecs] ); - * - * ds is the number of the state to check and state[] is its out-transitions, - * indexed by equivalence class. - */ - -void check_for_backing_up (ds, state) - int ds; - int state[]; -{ - if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */ - ++num_backing_up; - - if (backing_up_report) { - fprintf (backing_up_file, - _("State #%d is non-accepting -\n"), ds); - - /* identify the state */ - dump_associated_rules (backing_up_file, ds); - - /* Now identify it further using the out- and - * jam-transitions. - */ - dump_transitions (backing_up_file, state); - - putc ('\n', backing_up_file); - } - } -} - - -/* check_trailing_context - check to see if NFA state set constitutes - * "dangerous" trailing context - * - * synopsis - * void check_trailing_context( int nfa_states[num_states+1], int num_states, - * int accset[nacc+1], int nacc ); - * - * NOTES - * Trailing context is "dangerous" if both the head and the trailing - * part are of variable size \and/ there's a DFA state which contains - * both an accepting state for the head part of the rule and NFA states - * which occur after the beginning of the trailing context. - * - * When such a rule is matched, it's impossible to tell if having been - * in the DFA state indicates the beginning of the trailing context or - * further-along scanning of the pattern. In these cases, a warning - * message is issued. - * - * nfa_states[1 .. num_states] is the list of NFA states in the DFA. - * accset[1 .. nacc] is the list of accepting numbers for the DFA state. - */ - -void check_trailing_context (nfa_states, num_states, accset, nacc) - int *nfa_states, num_states; - int *accset; - int nacc; -{ - int i, j; - - for (i = 1; i <= num_states; ++i) { - int ns = nfa_states[i]; - int type = state_type[ns]; - int ar = assoc_rule[ns]; - - if (type == STATE_NORMAL || rule_type[ar] != RULE_VARIABLE) { /* do nothing */ - } - - else if (type == STATE_TRAILING_CONTEXT) { - /* Potential trouble. Scan set of accepting numbers - * for the one marking the end of the "head". We - * assume that this looping will be fairly cheap - * since it's rare that an accepting number set - * is large. - */ - for (j = 1; j <= nacc; ++j) - if (accset[j] & YY_TRAILING_HEAD_MASK) { - line_warning (_ - ("dangerous trailing context"), - rule_linenum[ar]); - return; - } - } - } -} - - -/* dump_associated_rules - list the rules associated with a DFA state - * - * Goes through the set of NFA states associated with the DFA and - * extracts the first MAX_ASSOC_RULES unique rules, sorts them, - * and writes a report to the given file. - */ - -void dump_associated_rules (file, ds) - FILE *file; - int ds; -{ - int i, j; - int num_associated_rules = 0; - int rule_set[MAX_ASSOC_RULES + 1]; - int *dset = dss[ds]; - int size = dfasiz[ds]; - - for (i = 1; i <= size; ++i) { - int rule_num = rule_linenum[assoc_rule[dset[i]]]; - - for (j = 1; j <= num_associated_rules; ++j) - if (rule_num == rule_set[j]) - break; - - if (j > num_associated_rules) { /* new rule */ - if (num_associated_rules < MAX_ASSOC_RULES) - rule_set[++num_associated_rules] = - rule_num; - } - } - - qsort (&rule_set [1], num_associated_rules, sizeof (rule_set [1]), intcmp); - - fprintf (file, _(" associated rule line numbers:")); - - for (i = 1; i <= num_associated_rules; ++i) { - if (i % 8 == 1) - putc ('\n', file); - - fprintf (file, "\t%d", rule_set[i]); - } - - putc ('\n', file); -} - - -/* dump_transitions - list the transitions associated with a DFA state - * - * synopsis - * dump_transitions( FILE *file, int state[numecs] ); - * - * Goes through the set of out-transitions and lists them in human-readable - * form (i.e., not as equivalence classes); also lists jam transitions - * (i.e., all those which are not out-transitions, plus EOF). The dump - * is done to the given file. - */ - -void dump_transitions (file, state) - FILE *file; - int state[]; -{ - int i, ec; - int out_char_set[CSIZE]; - - for (i = 0; i < csize; ++i) { - ec = ABS (ecgroup[i]); - out_char_set[i] = state[ec]; - } - - fprintf (file, _(" out-transitions: ")); - - list_character_set (file, out_char_set); - - /* now invert the members of the set to get the jam transitions */ - for (i = 0; i < csize; ++i) - out_char_set[i] = !out_char_set[i]; - - fprintf (file, _("\n jam-transitions: EOF ")); - - list_character_set (file, out_char_set); - - putc ('\n', file); -} - - -/* epsclosure - construct the epsilon closure of a set of ndfa states - * - * synopsis - * int *epsclosure( int t[num_states], int *numstates_addr, - * int accset[num_rules+1], int *nacc_addr, - * int *hashval_addr ); - * - * NOTES - * The epsilon closure is the set of all states reachable by an arbitrary - * number of epsilon transitions, which themselves do not have epsilon - * transitions going out, unioned with the set of states which have non-null - * accepting numbers. t is an array of size numstates of nfa state numbers. - * Upon return, t holds the epsilon closure and *numstates_addr is updated. - * accset holds a list of the accepting numbers, and the size of accset is - * given by *nacc_addr. t may be subjected to reallocation if it is not - * large enough to hold the epsilon closure. - * - * hashval is the hash value for the dfa corresponding to the state set. - */ - -int *epsclosure (t, ns_addr, accset, nacc_addr, hv_addr) - int *t, *ns_addr, accset[], *nacc_addr, *hv_addr; -{ - int stkpos, ns, tsp; - int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum; - int stkend, nstate; - static int did_stk_init = false, *stk; - -#define MARK_STATE(state) \ -do{ trans1[state] = trans1[state] - MARKER_DIFFERENCE;} while(0) - -#define IS_MARKED(state) (trans1[state] < 0) - -#define UNMARK_STATE(state) \ -do{ trans1[state] = trans1[state] + MARKER_DIFFERENCE;} while(0) - -#define CHECK_ACCEPT(state) \ -do{ \ -nfaccnum = accptnum[state]; \ -if ( nfaccnum != NIL ) \ -accset[++nacc] = nfaccnum; \ -}while(0) - -#define DO_REALLOCATION() \ -do { \ -current_max_dfa_size += MAX_DFA_SIZE_INCREMENT; \ -++num_reallocs; \ -t = reallocate_integer_array( t, current_max_dfa_size ); \ -stk = reallocate_integer_array( stk, current_max_dfa_size ); \ -}while(0) \ - -#define PUT_ON_STACK(state) \ -do { \ -if ( ++stkend >= current_max_dfa_size ) \ -DO_REALLOCATION(); \ -stk[stkend] = state; \ -MARK_STATE(state); \ -}while(0) - -#define ADD_STATE(state) \ -do { \ -if ( ++numstates >= current_max_dfa_size ) \ -DO_REALLOCATION(); \ -t[numstates] = state; \ -hashval += state; \ -}while(0) - -#define STACK_STATE(state) \ -do { \ -PUT_ON_STACK(state); \ -CHECK_ACCEPT(state); \ -if ( nfaccnum != NIL || transchar[state] != SYM_EPSILON ) \ -ADD_STATE(state); \ -}while(0) - - - if (!did_stk_init) { - stk = allocate_integer_array (current_max_dfa_size); - did_stk_init = true; - } - - nacc = stkend = hashval = 0; - - for (nstate = 1; nstate <= numstates; ++nstate) { - ns = t[nstate]; - - /* The state could be marked if we've already pushed it onto - * the stack. - */ - if (!IS_MARKED (ns)) { - PUT_ON_STACK (ns); - CHECK_ACCEPT (ns); - hashval += ns; - } - } - - for (stkpos = 1; stkpos <= stkend; ++stkpos) { - ns = stk[stkpos]; - transsym = transchar[ns]; - - if (transsym == SYM_EPSILON) { - tsp = trans1[ns] + MARKER_DIFFERENCE; - - if (tsp != NO_TRANSITION) { - if (!IS_MARKED (tsp)) - STACK_STATE (tsp); - - tsp = trans2[ns]; - - if (tsp != NO_TRANSITION - && !IS_MARKED (tsp)) - STACK_STATE (tsp); - } - } - } - - /* Clear out "visit" markers. */ - - for (stkpos = 1; stkpos <= stkend; ++stkpos) { - if (IS_MARKED (stk[stkpos])) - UNMARK_STATE (stk[stkpos]); - else - flexfatal (_ - ("consistency check failed in epsclosure()")); - } - - *ns_addr = numstates; - *hv_addr = hashval; - *nacc_addr = nacc; - - return t; -} - - -/* increase_max_dfas - increase the maximum number of DFAs */ - -void increase_max_dfas () -{ - current_max_dfas += MAX_DFAS_INCREMENT; - - ++num_reallocs; - - base = reallocate_integer_array (base, current_max_dfas); - def = reallocate_integer_array (def, current_max_dfas); - dfasiz = reallocate_integer_array (dfasiz, current_max_dfas); - accsiz = reallocate_integer_array (accsiz, current_max_dfas); - dhash = reallocate_integer_array (dhash, current_max_dfas); - dss = reallocate_int_ptr_array (dss, current_max_dfas); - dfaacc = reallocate_dfaacc_union (dfaacc, current_max_dfas); - - if (nultrans) - nultrans = - reallocate_integer_array (nultrans, - current_max_dfas); -} - - -/* ntod - convert an ndfa to a dfa - * - * Creates the dfa corresponding to the ndfa we've constructed. The - * dfa starts out in state #1. - */ - -void ntod () -{ - int *accset, ds, nacc, newds; - int sym, hashval, numstates, dsize; - int num_full_table_rows=0; /* used only for -f */ - int *nset, *dset; - int targptr, totaltrans, i, comstate, comfreq, targ; - int symlist[CSIZE + 1]; - int num_start_states; - int todo_head, todo_next; - - struct yytbl_data *yynxt_tbl = 0; - flex_int32_t *yynxt_data = 0, yynxt_curr = 0; - - /* Note that the following are indexed by *equivalence classes* - * and not by characters. Since equivalence classes are indexed - * beginning with 1, even if the scanner accepts NUL's, this - * means that (since every character is potentially in its own - * equivalence class) these arrays must have room for indices - * from 1 to CSIZE, so their size must be CSIZE + 1. - */ - int duplist[CSIZE + 1], state[CSIZE + 1]; - int targfreq[CSIZE + 1], targstate[CSIZE + 1]; - - /* accset needs to be large enough to hold all of the rules present - * in the input, *plus* their YY_TRAILING_HEAD_MASK variants. - */ - accset = allocate_integer_array ((num_rules + 1) * 2); - nset = allocate_integer_array (current_max_dfa_size); - - /* The "todo" queue is represented by the head, which is the DFA - * state currently being processed, and the "next", which is the - * next DFA state number available (not in use). We depend on the - * fact that snstods() returns DFA's \in increasing order/, and thus - * need only know the bounds of the dfas to be processed. - */ - todo_head = todo_next = 0; - - for (i = 0; i <= csize; ++i) { - duplist[i] = NIL; - symlist[i] = false; - } - - for (i = 0; i <= num_rules; ++i) - accset[i] = NIL; - - if (trace) { - dumpnfa (scset[1]); - fputs (_("\n\nDFA Dump:\n\n"), stderr); - } - - inittbl (); - - /* Check to see whether we should build a separate table for - * transitions on NUL characters. We don't do this for full-speed - * (-F) scanners, since for them we don't have a simple state - * number lying around with which to index the table. We also - * don't bother doing it for scanners unless (1) NUL is in its own - * equivalence class (indicated by a positive value of - * ecgroup[NUL]), (2) NUL's equivalence class is the last - * equivalence class, and (3) the number of equivalence classes is - * the same as the number of characters. This latter case comes - * about when useecs is false or when it's true but every character - * still manages to land in its own class (unlikely, but it's - * cheap to check for). If all these things are true then the - * character code needed to represent NUL's equivalence class for - * indexing the tables is going to take one more bit than the - * number of characters, and therefore we won't be assured of - * being able to fit it into a YY_CHAR variable. This rules out - * storing the transitions in a compressed table, since the code - * for interpreting them uses a YY_CHAR variable (perhaps it - * should just use an integer, though; this is worth pondering ... - * ###). - * - * Finally, for full tables, we want the number of entries in the - * table to be a power of two so the array references go fast (it - * will just take a shift to compute the major index). If - * encoding NUL's transitions in the table will spoil this, we - * give it its own table (note that this will be the case if we're - * not using equivalence classes). - */ - - /* Note that the test for ecgroup[0] == numecs below accomplishes - * both (1) and (2) above - */ - if (!fullspd && ecgroup[0] == numecs) { - /* NUL is alone in its equivalence class, which is the - * last one. - */ - int use_NUL_table = (numecs == csize); - - if (fulltbl && !use_NUL_table) { - /* We still may want to use the table if numecs - * is a power of 2. - */ - int power_of_two; - - for (power_of_two = 1; power_of_two <= csize; - power_of_two *= 2) - if (numecs == power_of_two) { - use_NUL_table = true; - break; - } - } - - if (use_NUL_table) - nultrans = - allocate_integer_array (current_max_dfas); - - /* From now on, nultrans != nil indicates that we're - * saving null transitions for later, separate encoding. - */ - } - - - if (fullspd) { - for (i = 0; i <= numecs; ++i) - state[i] = 0; - - place_state (state, 0, 0); - dfaacc[0].dfaacc_state = 0; - } - - else if (fulltbl) { - if (nultrans) - /* We won't be including NUL's transitions in the - * table, so build it for entries from 0 .. numecs - 1. - */ - num_full_table_rows = numecs; - - else - /* Take into account the fact that we'll be including - * the NUL entries in the transition table. Build it - * from 0 .. numecs. - */ - num_full_table_rows = numecs + 1; - - /* Begin generating yy_nxt[][] - * This spans the entire LONG function. - * This table is tricky because we don't know how big it will be. - * So we'll have to realloc() on the way... - * we'll wait until we can calculate yynxt_tbl->td_hilen. - */ - yynxt_tbl = - (struct yytbl_data *) calloc (1, - sizeof (struct - yytbl_data)); - yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); - yynxt_tbl->td_hilen = 1; - yynxt_tbl->td_lolen = num_full_table_rows; - yynxt_tbl->td_data = yynxt_data = - (flex_int32_t *) calloc (yynxt_tbl->td_lolen * - yynxt_tbl->td_hilen, - sizeof (flex_int32_t)); - yynxt_curr = 0; - - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - - /* Unless -Ca, declare it "short" because it's a real - * long-shot that that won't be large enough. - */ - if (gentables) - out_str_dec - ("static yyconst %s yy_nxt[][%d] =\n {\n", - long_align ? "flex_int32_t" : "flex_int16_t", - num_full_table_rows); - else { - out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); - out_str ("static yyconst %s *yy_nxt =0;\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - } - - - if (gentables) - outn (" {"); - - /* Generate 0 entries for state #0. */ - for (i = 0; i < num_full_table_rows; ++i) { - mk2data (0); - yynxt_data[yynxt_curr++] = 0; - } - - dataflush (); - if (gentables) - outn (" },\n"); - } - - /* Create the first states. */ - - num_start_states = lastsc * 2; - - for (i = 1; i <= num_start_states; ++i) { - numstates = 1; - - /* For each start condition, make one state for the case when - * we're at the beginning of the line (the '^' operator) and - * one for the case when we're not. - */ - if (i % 2 == 1) - nset[numstates] = scset[(i / 2) + 1]; - else - nset[numstates] = - mkbranch (scbol[i / 2], scset[i / 2]); - - nset = epsclosure (nset, &numstates, accset, &nacc, - &hashval); - - if (snstods (nset, numstates, accset, nacc, hashval, &ds)) { - numas += nacc; - totnst += numstates; - ++todo_next; - - if (variable_trailing_context_rules && nacc > 0) - check_trailing_context (nset, numstates, - accset, nacc); - } - } - - if (!fullspd) { - if (!snstods (nset, 0, accset, 0, 0, &end_of_buffer_state)) - flexfatal (_ - ("could not create unique end-of-buffer state")); - - ++numas; - ++num_start_states; - ++todo_next; - } - - - while (todo_head < todo_next) { - targptr = 0; - totaltrans = 0; - - for (i = 1; i <= numecs; ++i) - state[i] = 0; - - ds = ++todo_head; - - dset = dss[ds]; - dsize = dfasiz[ds]; - - if (trace) - fprintf (stderr, _("state # %d:\n"), ds); - - sympartition (dset, dsize, symlist, duplist); - - for (sym = 1; sym <= numecs; ++sym) { - if (symlist[sym]) { - symlist[sym] = 0; - - if (duplist[sym] == NIL) { - /* Symbol has unique out-transitions. */ - numstates = - symfollowset (dset, dsize, - sym, nset); - nset = epsclosure (nset, - &numstates, - accset, &nacc, - &hashval); - - if (snstods - (nset, numstates, accset, nacc, - hashval, &newds)) { - totnst = totnst + - numstates; - ++todo_next; - numas += nacc; - - if (variable_trailing_context_rules && nacc > 0) - check_trailing_context - (nset, - numstates, - accset, - nacc); - } - - state[sym] = newds; - - if (trace) - fprintf (stderr, - "\t%d\t%d\n", sym, - newds); - - targfreq[++targptr] = 1; - targstate[targptr] = newds; - ++numuniq; - } - - else { - /* sym's equivalence class has the same - * transitions as duplist(sym)'s - * equivalence class. - */ - targ = state[duplist[sym]]; - state[sym] = targ; - - if (trace) - fprintf (stderr, - "\t%d\t%d\n", sym, - targ); - - /* Update frequency count for - * destination state. - */ - - i = 0; - while (targstate[++i] != targ) ; - - ++targfreq[i]; - ++numdup; - } - - ++totaltrans; - duplist[sym] = NIL; - } - } - - - numsnpairs += totaltrans; - - if (ds > num_start_states) - check_for_backing_up (ds, state); - - if (nultrans) { - nultrans[ds] = state[NUL_ec]; - state[NUL_ec] = 0; /* remove transition */ - } - - if (fulltbl) { - - /* Each time we hit here, it's another td_hilen, so we realloc. */ - yynxt_tbl->td_hilen++; - yynxt_tbl->td_data = yynxt_data = - (flex_int32_t *) realloc (yynxt_data, - yynxt_tbl->td_hilen * - yynxt_tbl->td_lolen * - sizeof (flex_int32_t)); - - - if (gentables) - outn (" {"); - - /* Supply array's 0-element. */ - if (ds == end_of_buffer_state) { - mk2data (-end_of_buffer_state); - yynxt_data[yynxt_curr++] = - -end_of_buffer_state; - } - else { - mk2data (end_of_buffer_state); - yynxt_data[yynxt_curr++] = - end_of_buffer_state; - } - - for (i = 1; i < num_full_table_rows; ++i) { - /* Jams are marked by negative of state - * number. - */ - mk2data (state[i] ? state[i] : -ds); - yynxt_data[yynxt_curr++] = - state[i] ? state[i] : -ds; - } - - dataflush (); - if (gentables) - outn (" },\n"); - } - - else if (fullspd) - place_state (state, ds, totaltrans); - - else if (ds == end_of_buffer_state) - /* Special case this state to make sure it does what - * it's supposed to, i.e., jam on end-of-buffer. - */ - stack1 (ds, 0, 0, JAMSTATE); - - else { /* normal, compressed state */ - - /* Determine which destination state is the most - * common, and how many transitions to it there are. - */ - - comfreq = 0; - comstate = 0; - - for (i = 1; i <= targptr; ++i) - if (targfreq[i] > comfreq) { - comfreq = targfreq[i]; - comstate = targstate[i]; - } - - bldtbl (state, ds, totaltrans, comstate, comfreq); - } - } - - if (fulltbl) { - dataend (); - if (tablesext) { - yytbl_data_compress (yynxt_tbl); - if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0) - flexerror (_ - ("Could not write yynxt_tbl[][]")); - } - if (yynxt_tbl) { - yytbl_data_destroy (yynxt_tbl); - yynxt_tbl = 0; - } - } - - else if (!fullspd) { - cmptmps (); /* create compressed template entries */ - - /* Create tables for all the states with only one - * out-transition. - */ - while (onesp > 0) { - mk1tbl (onestate[onesp], onesym[onesp], - onenext[onesp], onedef[onesp]); - --onesp; - } - - mkdeftbl (); - } - - free ((void *) accset); - free ((void *) nset); -} - - -/* snstods - converts a set of ndfa states into a dfa state - * - * synopsis - * is_new_state = snstods( int sns[numstates], int numstates, - * int accset[num_rules+1], int nacc, - * int hashval, int *newds_addr ); - * - * On return, the dfa state number is in newds. - */ - -int snstods (sns, numstates, accset, nacc, hashval, newds_addr) - int sns[], numstates, accset[], nacc, hashval, *newds_addr; -{ - int didsort = 0; - int i, j; - int newds, *oldsns; - - for (i = 1; i <= lastdfa; ++i) - if (hashval == dhash[i]) { - if (numstates == dfasiz[i]) { - oldsns = dss[i]; - - if (!didsort) { - /* We sort the states in sns so we - * can compare it to oldsns quickly. - */ - qsort (&sns [1], numstates, sizeof (sns [1]), intcmp); - didsort = 1; - } - - for (j = 1; j <= numstates; ++j) - if (sns[j] != oldsns[j]) - break; - - if (j > numstates) { - ++dfaeql; - *newds_addr = i; - return 0; - } - - ++hshcol; - } - - else - ++hshsave; - } - - /* Make a new dfa. */ - - if (++lastdfa >= current_max_dfas) - increase_max_dfas (); - - newds = lastdfa; - - dss[newds] = allocate_integer_array (numstates + 1); - - /* If we haven't already sorted the states in sns, we do so now, - * so that future comparisons with it can be made quickly. - */ - - if (!didsort) - qsort (&sns [1], numstates, sizeof (sns [1]), intcmp); - - for (i = 1; i <= numstates; ++i) - dss[newds][i] = sns[i]; - - dfasiz[newds] = numstates; - dhash[newds] = hashval; - - if (nacc == 0) { - if (reject) - dfaacc[newds].dfaacc_set = (int *) 0; - else - dfaacc[newds].dfaacc_state = 0; - - accsiz[newds] = 0; - } - - else if (reject) { - /* We sort the accepting set in increasing order so the - * disambiguating rule that the first rule listed is considered - * match in the event of ties will work. - */ - - qsort (&accset [1], nacc, sizeof (accset [1]), intcmp); - - dfaacc[newds].dfaacc_set = - allocate_integer_array (nacc + 1); - - /* Save the accepting set for later */ - for (i = 1; i <= nacc; ++i) { - dfaacc[newds].dfaacc_set[i] = accset[i]; - - if (accset[i] <= num_rules) - /* Who knows, perhaps a REJECT can yield - * this rule. - */ - rule_useful[accset[i]] = true; - } - - accsiz[newds] = nacc; - } - - else { - /* Find lowest numbered rule so the disambiguating rule - * will work. - */ - j = num_rules + 1; - - for (i = 1; i <= nacc; ++i) - if (accset[i] < j) - j = accset[i]; - - dfaacc[newds].dfaacc_state = j; - - if (j <= num_rules) - rule_useful[j] = true; - } - - *newds_addr = newds; - - return 1; -} - - -/* symfollowset - follow the symbol transitions one step - * - * synopsis - * numstates = symfollowset( int ds[current_max_dfa_size], int dsize, - * int transsym, int nset[current_max_dfa_size] ); - */ - -int symfollowset (ds, dsize, transsym, nset) - int ds[], dsize, transsym, nset[]; -{ - int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist; - - numstates = 0; - - for (i = 1; i <= dsize; ++i) { /* for each nfa state ns in the state set of ds */ - ns = ds[i]; - sym = transchar[ns]; - tsp = trans1[ns]; - - if (sym < 0) { /* it's a character class */ - sym = -sym; - ccllist = cclmap[sym]; - lenccl = ccllen[sym]; - - if (cclng[sym]) { - for (j = 0; j < lenccl; ++j) { - /* Loop through negated character - * class. - */ - ch = ccltbl[ccllist + j]; - - if (ch == 0) - ch = NUL_ec; - - if (ch > transsym) - /* Transsym isn't in negated - * ccl. - */ - break; - - else if (ch == transsym) - /* next 2 */ - goto bottom; - } - - /* Didn't find transsym in ccl. */ - nset[++numstates] = tsp; - } - - else - for (j = 0; j < lenccl; ++j) { - ch = ccltbl[ccllist + j]; - - if (ch == 0) - ch = NUL_ec; - - if (ch > transsym) - break; - else if (ch == transsym) { - nset[++numstates] = tsp; - break; - } - } - } - - else if (sym == SYM_EPSILON) { /* do nothing */ - } - - else if (ABS (ecgroup[sym]) == transsym) - nset[++numstates] = tsp; - - bottom:; - } - - return numstates; -} - - -/* sympartition - partition characters with same out-transitions - * - * synopsis - * sympartition( int ds[current_max_dfa_size], int numstates, - * int symlist[numecs], int duplist[numecs] ); - */ - -void sympartition (ds, numstates, symlist, duplist) - int ds[], numstates; - int symlist[], duplist[]; -{ - int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich; - - /* Partitioning is done by creating equivalence classes for those - * characters which have out-transitions from the given state. Thus - * we are really creating equivalence classes of equivalence classes. - */ - - for (i = 1; i <= numecs; ++i) { /* initialize equivalence class list */ - duplist[i] = i - 1; - dupfwd[i] = i + 1; - } - - duplist[1] = NIL; - dupfwd[numecs] = NIL; - - for (i = 1; i <= numstates; ++i) { - ns = ds[i]; - tch = transchar[ns]; - - if (tch != SYM_EPSILON) { - if (tch < -lastccl || tch >= csize) { - flexfatal (_ - ("bad transition character detected in sympartition()")); - } - - if (tch >= 0) { /* character transition */ - int ec = ecgroup[tch]; - - mkechar (ec, dupfwd, duplist); - symlist[ec] = 1; - } - - else { /* character class */ - tch = -tch; - - lenccl = ccllen[tch]; - cclp = cclmap[tch]; - mkeccl (ccltbl + cclp, lenccl, dupfwd, - duplist, numecs, NUL_ec); - - if (cclng[tch]) { - j = 0; - - for (k = 0; k < lenccl; ++k) { - ich = ccltbl[cclp + k]; - - if (ich == 0) - ich = NUL_ec; - - for (++j; j < ich; ++j) - symlist[j] = 1; - } - - for (++j; j <= numecs; ++j) - symlist[j] = 1; - } - - else - for (k = 0; k < lenccl; ++k) { - ich = ccltbl[cclp + k]; - - if (ich == 0) - ich = NUL_ec; - - symlist[ich] = 1; - } - } - } - } -} diff --git a/third_party/lex/ecs.c b/third_party/lex/ecs.c deleted file mode 100644 index 450329a6..00000000 --- a/third_party/lex/ecs.c +++ /dev/null @@ -1,230 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -/* $OpenBSD: ecs.c,v 1.9 2015/11/20 18:54:49 tedu Exp $ */ - -/* ecs - equivalence class routines */ - -/* 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. */ - - -#include "flexdef.h" - -/* ccl2ecl - convert character classes to set of equivalence classes */ - -void -ccl2ecl(void) -{ - int i, ich, newlen, cclp, ccls, cclmec; - - for (i = 1; i <= lastccl; ++i) { - /* - * We loop through each character class, and for each - * character in the class, add the character's equivalence - * class to the new "character" class we are creating. Thus - * when we are all done, character classes will really - * consist of collections of equivalence classes - */ - - newlen = 0; - cclp = cclmap[i]; - - for (ccls = 0; ccls < ccllen[i]; ++ccls) { - ich = ccltbl[cclp + ccls]; - cclmec = ecgroup[ich]; - - if (cclmec > 0) { - ccltbl[cclp + newlen] = cclmec; - ++newlen; - } - } - - ccllen[i] = newlen; - } -} - - -/* cre8ecs - associate equivalence class numbers with class members - * - * fwd is the forward linked-list of equivalence class members. bck - * is the backward linked-list, and num is the number of class members. - * - * Returned is the number of classes. - */ - -int -cre8ecs(int *fwd, int *bck, int num) -{ - int i, j, numcl; - - numcl = 0; - - /* - * Create equivalence class numbers. From now on, ABS( bck(x) ) is - * the equivalence class number for object x. If bck(x) is positive, - * then x is the representative of its equivalence class. - */ - for (i = 1; i <= num; ++i) - if (bck[i] == NIL) { - bck[i] = ++numcl; - for (j = fwd[i]; j != NIL; j = fwd[j]) - bck[j] = -numcl; - } - return numcl; -} - - -/* mkeccl - update equivalence classes based on character class xtions - * - * synopsis - * u_char ccls[]; - * int lenccl, fwd[llsiz], bck[llsiz], llsiz, NUL_mapping; - * void mkeccl( u_char ccls[], int lenccl, int fwd[llsiz], int bck[llsiz], - * int llsiz, int NUL_mapping ); - * - * ccls contains the elements of the character class, lenccl is the - * number of elements in the ccl, fwd is the forward link-list of equivalent - * characters, bck is the backward link-list, and llsiz size of the link-list. - * - * NUL_mapping is the value which NUL (0) should be mapped to. - */ - -void -mkeccl(u_char *ccls, int lenccl, int *fwd, int *bck, int llsiz, int NUL_mapping) -{ - int cclp, oldec, newec; - int cclm, i, j; - static unsigned char cclflags[CSIZE]; /* initialized to all '\0' */ - - /* - * Note that it doesn't matter whether or not the character class is - * negated. The same results will be obtained in either case. - */ - - cclp = 0; - - while (cclp < lenccl) { - cclm = ccls[cclp]; - - if (NUL_mapping && cclm == 0) - cclm = NUL_mapping; - - oldec = bck[cclm]; - newec = cclm; - - j = cclp + 1; - - for (i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i]) { - /* look for the symbol in the character class */ - for (; j < lenccl; ++j) { - int ccl_char; - - if (NUL_mapping && ccls[j] == 0) - ccl_char = NUL_mapping; - else - ccl_char = ccls[j]; - - if (ccl_char > i) - break; - - if (ccl_char == i && !cclflags[j]) { - /* - * We found an old companion of cclm - * in the ccl. Link it into the new - * equivalence class and flag it as - * having been processed. - */ - - bck[i] = newec; - fwd[newec] = i; - newec = i; - /* Set flag so we don't reprocess. */ - cclflags[j] = 1; - - /* Get next equivalence class member. */ - /* continue 2 */ - goto next_pt; - } - } - - /* - * Symbol isn't in character class. Put it in the - * old equivalence class. - */ - - bck[i] = oldec; - - if (oldec != NIL) - fwd[oldec] = i; - - oldec = i; - - next_pt: ; - } - - if (bck[cclm] != NIL || oldec != bck[cclm]) { - bck[cclm] = NIL; - fwd[oldec] = NIL; - } - fwd[newec] = NIL; - - /* Find next ccl member to process. */ - - for (++cclp; cclflags[cclp] && cclp < lenccl; ++cclp) { - /* Reset "doesn't need processing" flag. */ - cclflags[cclp] = 0; - } - } -} - - -/* mkechar - create equivalence class for single character */ - -void -mkechar(int tch, int *fwd, int *bck) -{ - /* - * If until now the character has been a proper subset of an - * equivalence class, break it away to create a new ec - */ - - if (fwd[tch] != NIL) - bck[fwd[tch]] = bck[tch]; - - if (bck[tch] != NIL) - fwd[bck[tch]] = fwd[tch]; - - fwd[tch] = NIL; - bck[tch] = NIL; -} diff --git a/third_party/lex/filter.c b/third_party/lex/filter.c deleted file mode 100644 index f60300fe..00000000 --- a/third_party/lex/filter.c +++ /dev/null @@ -1,452 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ -/* clang-format off */ -/* $OpenBSD: filter.c,v 1.9 2017/08/30 02:54:07 lteo Exp $ */ - -/* filter - postprocessing of flex output through filters */ - -/* 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. */ - -#include "libc/mem/mem.h" -#include "libc/calls/calls.h" -#include "libc/calls/calls.h" -#include "libc/str/str.h" -#include "libc/fmt/fmt.h" -#include "libc/calls/calls.h" -#include "libc/runtime/runtime.h" -#include "libc/log/log.h" -#include "flexdef.h" - -const char *check_4_gnu_m4 = -"m4_dnl ifdef(`__gnu__', ," -"`errprint(Flex requires GNU M4. Set the PATH or set the M4 environment variable to its path name.)" -" m4exit(2)')\n"; - - -/** global chain. */ -struct filter *output_chain = NULL; - -/* Allocate and initialize an external filter. - * @param chain the current chain or NULL for new chain - * @param cmd the command to execute. - * @param ... a NULL terminated list of (const char*) arguments to command, - * not including argv[0]. - * @return newest filter in chain - */ -struct filter * -filter_create_ext(struct filter * chain, const char *cmd, - ...) -{ - struct filter *f; - int max_args; - const char *s; - va_list ap; - - /* allocate and initialize new filter */ - f = calloc(sizeof(struct filter), 1); - if (!f) - flexerror(_("calloc failed (f) in filter_create_ext")); - f->filter_func = NULL; - f->extra = NULL; - f->next = NULL; - f->argc = 0; - - if (chain != NULL) { - /* append f to end of chain */ - while (chain->next) - chain = chain->next; - chain->next = f; - } - /* allocate argv, and populate it with the argument list. */ - max_args = 8; - f->argv = malloc(sizeof(char *) * (max_args + 1)); - if (!f->argv) - flexerror(_("malloc failed (f->argv) in filter_create_ext")); - f->argv[f->argc++] = cmd; - - va_start(ap, cmd); - while ((s = va_arg(ap, const char *)) != NULL) { - if (f->argc >= max_args) { - max_args += 8; - f->argv = realloc(f->argv, - sizeof(char *) * (max_args + 1)); - } - f->argv[f->argc++] = s; - } - f->argv[f->argc] = NULL; - - va_end(ap); - return f; -} - -/* Allocate and initialize an internal filter. - * @param chain the current chain or NULL for new chain - * @param filter_func The function that will perform the filtering. - * filter_func should return 0 if successful, and -1 - * if an error occurs -- or it can simply exit(). - * @param extra optional user-defined data to pass to the filter. - * @return newest filter in chain - */ -struct filter * -filter_create_int(struct filter * chain, - int (*filter_func) (struct filter *), - void *extra) -{ - struct filter *f; - - /* allocate and initialize new filter */ - f = calloc(sizeof(struct filter), 1); - if (!f) - flexerror(_("calloc failed in filter_create_int")); - f->next = NULL; - f->argc = 0; - f->argv = NULL; - - f->filter_func = filter_func; - f->extra = extra; - - if (chain != NULL) { - /* append f to end of chain */ - while (chain->next) - chain = chain->next; - chain->next = f; - } - return f; -} - -/** Fork and exec entire filter chain. - * @param chain The head of the chain. - * @return true on success. - */ -bool -filter_apply_chain(struct filter * chain) -{ - int pid; - int pipes[2]; - - /* - * Tricky recursion, since we want to begin the chain at the END. - * Why? Because we need all the forked processes to be children of - * the main flex process. - */ - if (chain) - filter_apply_chain(chain->next); - else - return true; - - /* - * Now we are the right-most unprocessed link in the chain. - */ - - fflush(stdout); - fflush(stderr); - - - if (pipe(pipes) == -1) - flexerror(_("pipe failed")); - - if ((pid = fork()) == -1) - flexerror(_("fork failed")); - - if (pid == 0) { - /* child */ - - /* - * We need stdin (the FILE* stdin) to connect to this new - * pipe. There is no portable way to set stdin to a new file - * descriptor, as stdin is not an lvalue on some systems - * (BSD). So we dup the new pipe onto the stdin descriptor - * and use a no-op fseek to sync the stream. This is a Hail - * Mary situation. It seems to work. - */ - close(pipes[1]); - clearerr(stdin); - if (dup2(pipes[0], fileno(stdin)) == -1) - flexfatal(_("dup2(pipes[0],0)")); - close(pipes[0]); - fseek(stdin, 0, SEEK_CUR); - - /* run as a filter, either internally or by exec */ - if (chain->filter_func) { - if (chain->filter_func(chain) == -1) - flexfatal(_("filter_func failed")); - exit(0); - } else { - execvp(chain->argv[0], - (char **const) (chain->argv)); - lerrsf_fatal(_("exec of %s failed"), - chain->argv[0]); - } - - exit(1); - } - /* Parent */ - close(pipes[0]); - if (dup2(pipes[1], fileno(stdout)) == -1) - flexfatal(_("dup2(pipes[1],1)")); - close(pipes[1]); - fseek(stdout, 0, SEEK_CUR); - - return true; -} - -/** Truncate the chain to max_len number of filters. - * @param chain the current chain. - * @param max_len the maximum length of the chain. - * @return the resulting length of the chain. - */ -int -filter_truncate(struct filter * chain, int max_len) -{ - int len = 1; - - if (!chain) - return 0; - - while (chain->next && len < max_len) { - chain = chain->next; - ++len; - } - - chain->next = NULL; - return len; -} - -/** Splits the chain in order to write to a header file. - * Similar in spirit to the 'tee' program. - * The header file name is in extra. - * @return 0 (zero) on success, and -1 on failure. - */ -int -filter_tee_header(struct filter * chain) -{ - /* - * This function reads from stdin and writes to both the C file and - * the header file at the same time. - */ - - const int readsz = 512; - char *buf; - int to_cfd = -1; - FILE *to_c = NULL, *to_h = NULL; - bool write_header; - - write_header = (chain->extra != NULL); - - /* - * Store a copy of the stdout pipe, which is already piped to C file - * through the running chain. Then create a new pipe to the H file as - * stdout, and fork the rest of the chain again. - */ - - if ((to_cfd = dup(1)) == -1) - flexfatal(_("dup(1) failed")); - to_c = fdopen(to_cfd, "w"); - - if (write_header) { - if (freopen((char *) chain->extra, "w", stdout) == NULL) - flexfatal(_("freopen(headerfilename) failed")); - - filter_apply_chain(chain->next); - to_h = stdout; - } - /* - * Now to_c is a pipe to the C branch, and to_h is a pipe to the H - * branch. - */ - - if (write_header) { - /* fputs(check_4_gnu_m4, to_h); */ - fputs("m4_changecom`'m4_dnl\n", to_h); - fputs("m4_changequote`'m4_dnl\n", to_h); - fputs("m4_changequote([[,]])[[]]m4_dnl\n", to_h); - fputs("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); - fputs("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", - to_h); - fprintf(to_h, "#ifndef %sHEADER_H\n", prefix); - fprintf(to_h, "#define %sHEADER_H 1\n", prefix); - fprintf(to_h, "#define %sIN_HEADER 1\n\n", prefix); - fprintf(to_h, - "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", - headerfilename ? headerfilename : ""); - - } - /* fputs(check_4_gnu_m4, to_c); */ - fputs("m4_changecom`'m4_dnl\n", to_c); - fputs("m4_changequote`'m4_dnl\n", to_c); - fputs("m4_changequote([[,]])[[]]m4_dnl\n", to_c); - fputs("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_c); - fprintf(to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", - outfilename ? outfilename : ""); - - buf = malloc(readsz); - if (!buf) - flexerror(_("malloc failed in filter_tee_header")); - while (fgets(buf, readsz, stdin)) { - fputs(buf, to_c); - if (write_header) - fputs(buf, to_h); - } - - if (write_header) { - fprintf(to_h, "\n"); - - /* - * write a fake line number. It will get fixed by the linedir - * filter. - */ - fprintf(to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n"); - - fprintf(to_h, "#undef %sIN_HEADER\n", prefix); - fprintf(to_h, "#endif /* %sHEADER_H */\n", prefix); - fputs("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h); - - fflush(to_h); - if (ferror(to_h)) - lerrsf(_("error writing output file %s"), - (char *) chain->extra); - - else if (fclose(to_h)) - lerrsf(_("error closing output file %s"), - (char *) chain->extra); - } - fflush(to_c); - if (ferror(to_c)) - lerrsf(_("error writing output file %s"), - outfilename ? outfilename : ""); - - else if (fclose(to_c)) - lerrsf(_("error closing output file %s"), - outfilename ? outfilename : ""); - - while (wait(0) > 0); - - exit(0); - return 0; -} - -/** Adjust the line numbers in the #line directives of the generated scanner. - * After the m4 expansion, the line numbers are incorrect since the m4 macros - * can add or remove lines. This only adjusts line numbers for generated code, - * not user code. This also happens to be a good place to squeeze multiple - * blank lines into a single blank line. - */ -int -filter_fix_linedirs(struct filter * chain) -{ - char *buf; - const int readsz = 512 + MAXLINE; - int lineno = 1; - bool in_gen = true; /* in generated code */ - bool last_was_blank = false; - - if (!chain) - return 0; - - buf = malloc(readsz); - if (!buf) - flexerror(_("malloc failed in filter_fix_linedirs")); - - while (fgets(buf, readsz, stdin)) { - - regmatch_t m[10]; - - /* Check for #line directive. */ - if (buf[0] == '#' - && regexec(®ex_linedir, buf, 3, m, 0) == 0) { - - int num; - char *fname; - - /* extract the line number and filename */ - num = regmatch_strtol(&m[1], buf, NULL, 0); - fname = regmatch_dup(&m[2], buf); - - /* TODO(jart): Why isn't num being used? */ - (void)num; - - if (strcmp(fname, - outfilename ? outfilename : "") == 0 || - strcmp(fname, headerfilename ? headerfilename : - "") == 0) { - - char *s1, *s2; - char filename[MAXLINE]; - - s1 = fname; - s2 = filename; - - while ((s2 - filename) < (MAXLINE - 1) && *s1) { - /* Escape the backslash */ - if (*s1 == '\\') - *s2++ = '\\'; - /* Escape the double quote */ - if (*s1 == '\"') - *s2++ = '\\'; - /* Copy the character as usual */ - *s2++ = *s1++; - } - - *s2 = '\0'; - - /* Adjust the line directives. */ - in_gen = true; - snprintf(buf, readsz, "#line %d \"%s\"\n", - lineno + 1, filename); - } else { - /* - * it's a #line directive for code we didn't - * write - */ - in_gen = false; - } - - free(fname); - last_was_blank = false; - } - /* squeeze blank lines from generated code */ - else if (in_gen && - regexec(®ex_blank_line, buf, 0, NULL, 0) == 0) { - if (last_was_blank) - continue; - else - last_was_blank = true; - } else { - /* it's a line of normal, non-empty code. */ - last_was_blank = false; - } - - fputs(buf, stdout); - lineno++; - } - fflush(stdout); - if (ferror(stdout)) - lerrsf(_("error writing output file %s"), - outfilename ? outfilename : ""); - - else if (fclose(stdout)) - lerrsf(_("error closing output file %s"), - outfilename ? outfilename : ""); - - return 0; -} diff --git a/third_party/lex/flex.1 b/third_party/lex/flex.1 deleted file mode 100644 index 138765cb..00000000 --- a/third_party/lex/flex.1 +++ /dev/null @@ -1,4438 +0,0 @@ -.\" $OpenBSD: flex.1,v 1.43 2015/09/21 10:03:46 jmc Exp $ -.\" -.\" 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. -.\" -.\" 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. -.\" -.Dd $Mdocdate: September 21 2015 $ -.Dt FLEX 1 -.Os -.Sh NAME -.Nm flex , -.Nm flex++ , -.Nm lex -.Nd fast lexical analyzer generator -.Sh SYNOPSIS -.Nm -.Bk -words -.Op Fl 78BbdFfhIiLlnpsTtVvw+? -.Op Fl C Ns Op Cm aeFfmr -.Op Fl Fl help -.Op Fl Fl version -.Op Fl o Ns Ar output -.Op Fl P Ns Ar prefix -.Op Fl S Ns Ar skeleton -.Op Ar -.Ek -.Sh DESCRIPTION -.Nm -is a tool for generating -.Em scanners : -programs which recognize lexical patterns in text. -.Nm -reads the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. -The description is in the form of pairs of regular expressions and C code, -called -.Em rules . -.Nm -generates as output a C source file, -.Pa lex.yy.c , -which defines a routine -.Fn yylex . -This file is compiled and linked with the -.Fl lfl -library to produce an executable. -When the executable is run, it analyzes its input for occurrences -of the regular expressions. -Whenever it finds one, it executes the corresponding C code. -.Pp -.Nm lex -is a synonym for -.Nm flex . -.Nm flex++ -is a synonym for -.Nm -.Fl + . -.Pp -The manual includes both tutorial and reference sections: -.Bl -ohang -.It Sy Some Simple Examples -.It Sy Format of the Input File -.It Sy Patterns -The extended regular expressions used by -.Nm . -.It Sy How the Input is Matched -The rules for determining what has been matched. -.It Sy Actions -How to specify what to do when a pattern is matched. -.It Sy The Generated Scanner -Details regarding the scanner that -.Nm -produces; -how to control the input source. -.It Sy Start Conditions -Introducing context into scanners, and managing -.Qq mini-scanners . -.It Sy Multiple Input Buffers -How to manipulate multiple input sources; -how to scan from strings instead of files. -.It Sy End-of-File Rules -Special rules for matching the end of the input. -.It Sy Miscellaneous Macros -A summary of macros available to the actions. -.It Sy Values Available to the User -A summary of values available to the actions. -.It Sy Interfacing with Yacc -Connecting flex scanners together with -.Xr yacc 1 -parsers. -.It Sy Options -.Nm -command-line options, and the -.Dq %option -directive. -.It Sy Performance Considerations -How to make scanners go as fast as possible. -.It Sy Generating C++ Scanners -The -.Pq experimental -facility for generating C++ scanner classes. -.It Sy Incompatibilities with Lex and POSIX -How -.Nm -differs from -.At -.Nm lex -and the -.Tn POSIX -.Nm lex -standard. -.It Sy Files -Files used by -.Nm . -.It Sy Diagnostics -Those error messages produced by -.Nm -.Pq or scanners it generates -whose meanings might not be apparent. -.It Sy See Also -Other documentation, related tools. -.It Sy Authors -Includes contact information. -.It Sy Bugs -Known problems with -.Nm . -.El -.Sh SOME SIMPLE EXAMPLES -First some simple examples to get the flavor of how one uses -.Nm . -The following -.Nm -input specifies a scanner which whenever it encounters the string -.Qq username -will replace it with the user's login name: -.Bd -literal -offset indent -%% -username printf("%s", getlogin()); -.Ed -.Pp -By default, any text not matched by a -.Nm -scanner is copied to the output, so the net effect of this scanner is -to copy its input file to its output with each occurrence of -.Qq username -expanded. -In this input, there is just one rule. -.Qq username -is the -.Em pattern -and the -.Qq printf -is the -.Em action . -The -.Qq %% -marks the beginning of the rules. -.Pp -Here's another simple example: -.Bd -literal -offset indent -%{ -int num_lines = 0, num_chars = 0; -%} - -%% -\en ++num_lines; ++num_chars; -\&. ++num_chars; - -%% -main() -{ - yylex(); - printf("# of lines = %d, # of chars = %d\en", - num_lines, num_chars); -} -.Ed -.Pp -This scanner counts the number of characters and the number -of lines in its input -(it produces no output other than the final report on the counts). -The first line declares two globals, -.Qq num_lines -and -.Qq num_chars , -which are accessible both inside -.Fn yylex -and in the -.Fn main -routine declared after the second -.Qq %% . -There are two rules, one which matches a newline -.Pq \&"\en\&" -and increments both the line count and the character count, -and one which matches any character other than a newline -(indicated by the -.Qq \&. -regular expression). -.Pp -A somewhat more complicated example: -.Bd -literal -offset indent -/* scanner for a toy Pascal-like language */ - -%{ -/* need this for the call to atof() below */ -#include -%} - -DIGIT [0-9] -ID [a-z][a-z0-9]* - -%% - -{DIGIT}+ { - printf("An integer: %s (%d)\en", yytext, - atoi(yytext)); -} - -{DIGIT}+"."{DIGIT}* { - printf("A float: %s (%g)\en", yytext, - atof(yytext)); -} - -if|then|begin|end|procedure|function { - printf("A keyword: %s\en", yytext); -} - -{ID} printf("An identifier: %s\en", yytext); - -"+"|"-"|"*"|"/" printf("An operator: %s\en", yytext); - -"{"[^}\en]*"}" /* eat up one-line comments */ - -[ \et\en]+ /* eat up whitespace */ - -\&. printf("Unrecognized character: %s\en", yytext); - -%% - -main(int argc, char *argv[]) -{ - ++argv; --argc; /* skip over program name */ - if (argc > 0) - yyin = fopen(argv[0], "r"); - else - yyin = stdin; - - yylex(); -} -.Ed -.Pp -This is the beginnings of a simple scanner for a language like Pascal. -It identifies different types of -.Em tokens -and reports on what it has seen. -.Pp -The details of this example will be explained in the following sections. -.Sh FORMAT OF THE INPUT FILE -The -.Nm -input file consists of three sections, separated by a line with just -.Qq %% -in it: -.Bd -unfilled -offset indent -definitions -%% -rules -%% -user code -.Ed -.Pp -The -.Em definitions -section contains declarations of simple -.Em name -definitions to simplify the scanner specification, and declarations of -.Em start conditions , -which are explained in a later section. -.Pp -Name definitions have the form: -.Pp -.D1 name definition -.Pp -The -.Qq name -is a word beginning with a letter or an underscore -.Pq Sq _ -followed by zero or more letters, digits, -.Sq _ , -or -.Sq - -.Pq dash . -The definition is taken to begin at the first non-whitespace character -following the name and continuing to the end of the line. -The definition can subsequently be referred to using -.Qq {name} , -which will expand to -.Qq (definition) . -For example: -.Bd -literal -offset indent -DIGIT [0-9] -ID [a-z][a-z0-9]* -.Ed -.Pp -This defines -.Qq DIGIT -to be a regular expression which matches a single digit, and -.Qq ID -to be a regular expression which matches a letter -followed by zero-or-more letters-or-digits. -A subsequent reference to -.Pp -.Dl {DIGIT}+"."{DIGIT}* -.Pp -is identical to -.Pp -.Dl ([0-9])+"."([0-9])* -.Pp -and matches one-or-more digits followed by a -.Sq .\& -followed by zero-or-more digits. -.Pp -The -.Em rules -section of the -.Nm -input contains a series of rules of the form: -.Pp -.Dl pattern action -.Pp -The pattern must be unindented and the action must begin -on the same line. -.Pp -See below for a further description of patterns and actions. -.Pp -Finally, the user code section is simply copied to -.Pa lex.yy.c -verbatim. -It is used for companion routines which call or are called by the scanner. -The presence of this section is optional; -if it is missing, the second -.Qq %% -in the input file may be skipped too. -.Pp -In the definitions and rules sections, any indented text or text enclosed in -.Sq %{ -and -.Sq %} -is copied verbatim to the output -.Pq with the %{}'s removed . -The %{}'s must appear unindented on lines by themselves. -.Pp -In the rules section, -any indented or %{} text appearing before the first rule may be used to -declare variables which are local to the scanning routine and -.Pq after the declarations -code which is to be executed whenever the scanning routine is entered. -Other indented or %{} text in the rule section is still copied to the output, -but its meaning is not well-defined and it may well cause compile-time -errors (this feature is present for -.Tn POSIX -compliance; see below for other such features). -.Pp -In the definitions section -.Pq but not in the rules section , -an unindented comment -(i.e., a line beginning with -.Qq /* ) -is also copied verbatim to the output up to the next -.Qq */ . -.Sh PATTERNS -The patterns in the input are written using an extended set of regular -expressions. -These are: -.Bl -tag -width "XXXXXXXX" -.It x -Match the character -.Sq x . -.It .\& -Any character -.Pq byte -except newline. -.It [xyz] -A -.Qq character class ; -in this case, the pattern matches either an -.Sq x , -a -.Sq y , -or a -.Sq z . -.It [abj-oZ] -A -.Qq character class -with a range in it; matches an -.Sq a , -a -.Sq b , -any letter from -.Sq j -through -.Sq o , -or a -.Sq Z . -.It [^A-Z] -A -.Qq negated character class , -i.e., any character but those in the class. -In this case, any character EXCEPT an uppercase letter. -.It [^A-Z\en] -Any character EXCEPT an uppercase letter or a newline. -.It r* -Zero or more r's, where -.Sq r -is any regular expression. -.It r+ -One or more r's. -.It r? -Zero or one r's (that is, -.Qq an optional r ) . -.It r{2,5} -Anywhere from two to five r's. -.It r{2,} -Two or more r's. -.It r{4} -Exactly 4 r's. -.It {name} -The expansion of the -.Qq name -definition -.Pq see above . -.It \&"[xyz]\e\&"foo\&" -The literal string: [xyz]"foo. -.It \eX -If -.Sq X -is an -.Sq a , -.Sq b , -.Sq f , -.Sq n , -.Sq r , -.Sq t , -or -.Sq v , -then the ANSI-C interpretation of -.Sq \eX . -Otherwise, a literal -.Sq X -(used to escape operators such as -.Sq * ) . -.It \e0 -A NUL character -.Pq ASCII code 0 . -.It \e123 -The character with octal value 123. -.It \ex2a -The character with hexadecimal value 2a. -.It (r) -Match an -.Sq r ; -parentheses are used to override precedence -.Pq see below . -.It rs -The regular expression -.Sq r -followed by the regular expression -.Sq s ; -called -.Qq concatenation . -.It r|s -Either an -.Sq r -or an -.Sq s . -.It r/s -An -.Sq r , -but only if it is followed by an -.Sq s . -The text matched by -.Sq s -is included when determining whether this rule is the -.Qq longest match , -but is then returned to the input before the action is executed. -So the action only sees the text matched by -.Sq r . -This type of pattern is called -.Qq trailing context . -(There are some combinations of r/s that -.Nm -cannot match correctly; see notes in the -.Sx BUGS -section below regarding -.Qq dangerous trailing context . ) -.It ^r -An -.Sq r , -but only at the beginning of a line -(i.e., just starting to scan, or right after a newline has been scanned). -.It r$ -An -.Sq r , -but only at the end of a line -.Pq i.e., just before a newline . -Equivalent to -.Qq r/\en . -.Pp -Note that -.Nm flex Ns 's -notion of -.Qq newline -is exactly whatever the C compiler used to compile -.Nm -interprets -.Sq \en -as. -.\" In particular, on some DOS systems you must either filter out \er's in the -.\" input yourself, or explicitly use r/\er\en for -.\" .Qq r$ . -.It r -An -.Sq r , -but only in start condition -.Sq s -.Pq see below for discussion of start conditions . -.It r -The same, but in any of start conditions s1, s2, or s3. -.It <*>r -An -.Sq r -in any start condition, even an exclusive one. -.It <> -An end-of-file. -.It <> -An end-of-file when in start condition s1 or s2. -.El -.Pp -Note that inside of a character class, all regular expression operators -lose their special meaning except escape -.Pq Sq \e -and the character class operators, -.Sq - , -.Sq ]\& , -and, at the beginning of the class, -.Sq ^ . -.Pp -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. -For example, -.Pp -.D1 foo|bar* -.Pp -is the same as -.Pp -.D1 (foo)|(ba(r*)) -.Pp -since the -.Sq * -operator has higher precedence than concatenation, -and concatenation higher than alternation -.Pq Sq |\& . -This pattern therefore matches -.Em either -the string -.Qq foo -.Em or -the string -.Qq ba -followed by zero-or-more r's. -To match -.Qq foo -or zero-or-more "bar"'s, -use: -.Pp -.D1 foo|(bar)* -.Pp -and to match zero-or-more "foo"'s-or-"bar"'s: -.Pp -.D1 (foo|bar)* -.Pp -In addition to characters and ranges of characters, character classes -can also contain character class -.Em expressions . -These are expressions enclosed inside -.Sq [: -and -.Sq :] -delimiters (which themselves must appear between the -.Sq \&[ -and -.Sq ]\& -of the -character class; other elements may occur inside the character class, too). -The valid expressions are: -.Bd -unfilled -offset indent -[:alnum:] [:alpha:] [:blank:] -[:cntrl:] [:digit:] [:graph:] -[:lower:] [:print:] [:punct:] -[:space:] [:upper:] [:xdigit:] -.Ed -.Pp -These expressions all designate a set of characters equivalent to -the corresponding standard C -.Fn isXXX -function. -For example, [:alnum:] designates those characters for which -.Xr isalnum 3 -returns true \- i.e., any alphabetic or numeric. -Some systems don't provide -.Xr isblank 3 , -so -.Nm -defines [:blank:] as a blank or a tab. -.Pp -For example, the following character classes are all equivalent: -.Bd -unfilled -offset indent -[[:alnum:]] -[[:alpha:][:digit:]] -[[:alpha:]0-9] -[a-zA-Z0-9] -.Ed -.Pp -If the scanner is case-insensitive (the -.Fl i -flag), then [:upper:] and [:lower:] are equivalent to [:alpha:]. -.Pp -Some notes on patterns: -.Bl -dash -.It -A negated character class such as the example -.Qq [^A-Z] -above will match a newline unless "\en" -.Pq or an equivalent escape sequence -is one of the characters explicitly present in the negated character class -(e.g., -.Qq [^A-Z\en] ) . -This is unlike how many other regular expression tools treat negated character -classes, but unfortunately the inconsistency is historically entrenched. -Matching newlines means that a pattern like -.Qq [^"]* -can match the entire input unless there's another quote in the input. -.It -A rule can have at most one instance of trailing context -(the -.Sq / -operator or the -.Sq $ -operator). -The start condition, -.Sq ^ , -and -.Qq <> -patterns can only occur at the beginning of a pattern and, as well as with -.Sq / -and -.Sq $ , -cannot be grouped inside parentheses. -A -.Sq ^ -which does not occur at the beginning of a rule or a -.Sq $ -which does not occur at the end of a rule loses its special properties -and is treated as a normal character. -.It -The following are illegal: -.Bd -unfilled -offset indent -foo/bar$ -foobar -.Ed -.Pp -Note that the first of these, can be written -.Qq foo/bar\en . -.It -The following will result in -.Sq $ -or -.Sq ^ -being treated as a normal character: -.Bd -unfilled -offset indent -foo|(bar$) -foo|^bar -.Ed -.Pp -If what's wanted is a -.Qq foo -or a bar-followed-by-a-newline, the following could be used -(the special -.Sq |\& -action is explained below): -.Bd -unfilled -offset indent -foo | -bar$ /* action goes here */ -.Ed -.Pp -A similar trick will work for matching a foo or a -bar-at-the-beginning-of-a-line. -.El -.Sh HOW THE INPUT IS MATCHED -When the generated scanner is run, -it analyzes its input looking for strings which match any of its patterns. -If it finds more than one match, -it takes the one matching the most text -(for trailing context rules, this includes the length of the trailing part, -even though it will then be returned to the input). -If it finds two or more matches of the same length, -the rule listed first in the -.Nm -input file is chosen. -.Pp -Once the match is determined, the text corresponding to the match -(called the -.Em token ) -is made available in the global character pointer -.Fa yytext , -and its length in the global integer -.Fa yyleng . -The -.Em action -corresponding to the matched pattern is then executed -.Pq a more detailed description of actions follows , -and then the remaining input is scanned for another match. -.Pp -If no match is found, then the default rule is executed: -the next character in the input is considered matched and -copied to the standard output. -Thus, the simplest legal -.Nm -input is: -.Pp -.D1 %% -.Pp -which generates a scanner that simply copies its input -.Pq one character at a time -to its output. -.Pp -Note that -.Fa yytext -can be defined in two different ways: -either as a character pointer or as a character array. -Which definition -.Nm -uses can be controlled by including one of the special directives -.Dq %pointer -or -.Dq %array -in the first -.Pq definitions -section of flex input. -The default is -.Dq %pointer , -unless the -.Fl l -.Nm lex -compatibility option is used, in which case -.Fa yytext -will be an array. -The advantage of using -.Dq %pointer -is substantially faster scanning and no buffer overflow when matching -very large tokens -.Pq unless not enough dynamic memory is available . -The disadvantage is that actions are restricted in how they can modify -.Fa yytext -.Pq see the next section , -and calls to the -.Fn unput -function destroy the present contents of -.Fa yytext , -which can be a considerable porting headache when moving between different -.Nm lex -versions. -.Pp -The advantage of -.Dq %array -is that -.Fa yytext -can be modified as much as wanted, and calls to -.Fn unput -do not destroy -.Fa yytext -.Pq see below . -Furthermore, existing -.Nm lex -programs sometimes access -.Fa yytext -externally using declarations of the form: -.Pp -.D1 extern char yytext[]; -.Pp -This definition is erroneous when used with -.Dq %pointer , -but correct for -.Dq %array . -.Pp -.Dq %array -defines -.Fa yytext -to be an array of -.Dv YYLMAX -characters, which defaults to a fairly large value. -The size can be changed by simply #define'ing -.Dv YYLMAX -to a different value in the first section of -.Nm -input. -As mentioned above, with -.Dq %pointer -yytext grows dynamically to accommodate large tokens. -While this means a -.Dq %pointer -scanner can accommodate very large tokens -.Pq such as matching entire blocks of comments , -bear in mind that each time the scanner must resize -.Fa yytext -it also must rescan the entire token from the beginning, so matching such -tokens can prove slow. -.Fa yytext -presently does not dynamically grow if a call to -.Fn unput -results in too much text being pushed back; instead, a run-time error results. -.Pp -Also note that -.Dq %array -cannot be used with C++ scanner classes -.Pq the c++ option; see below . -.Sh ACTIONS -Each pattern in a rule has a corresponding action, -which can be any arbitrary C statement. -The pattern ends at the first non-escaped whitespace character; -the remainder of the line is its action. -If the action is empty, -then when the pattern is matched the input token is simply discarded. -For example, here is the specification for a program -which deletes all occurrences of -.Qq zap me -from its input: -.Bd -literal -offset indent -%% -"zap me" -.Ed -.Pp -(It will copy all other characters in the input to the output since -they will be matched by the default rule.) -.Pp -Here is a program which compresses multiple blanks and tabs down to -a single blank, and throws away whitespace found at the end of a line: -.Bd -literal -offset indent -%% -[ \et]+ putchar(' '); -[ \et]+$ /* ignore this token */ -.Ed -.Pp -If the action contains a -.Sq { , -then the action spans till the balancing -.Sq } -is found, and the action may cross multiple lines. -.Nm -knows about C strings and comments and won't be fooled by braces found -within them, but also allows actions to begin with -.Sq %{ -and will consider the action to be all the text up to the next -.Sq %} -.Pq regardless of ordinary braces inside the action . -.Pp -An action consisting solely of a vertical bar -.Pq Sq |\& -means -.Qq same as the action for the next rule . -See below for an illustration. -.Pp -Actions can include arbitrary C code, -including return statements to return a value to whatever routine called -.Fn yylex . -Each time -.Fn yylex -is called, it continues processing tokens from where it last left off -until it either reaches the end of the file or executes a return. -.Pp -Actions are free to modify -.Fa yytext -except for lengthening it -(adding characters to its end \- these will overwrite later characters in the -input stream). -This, however, does not apply when using -.Dq %array -.Pq see above ; -in that case, -.Fa yytext -may be freely modified in any way. -.Pp -Actions are free to modify -.Fa yyleng -except they should not do so if the action also includes use of -.Fn yymore -.Pq see below . -.Pp -There are a number of special directives which can be included within -an action: -.Bl -tag -width Ds -.It ECHO -Copies -.Fa yytext -to the scanner's output. -.It BEGIN -Followed by the name of a start condition, places the scanner in the -corresponding start condition -.Pq see below . -.It REJECT -Directs the scanner to proceed on to the -.Qq second best -rule which matched the input -.Pq or a prefix of the input . -The rule is chosen as described above in -.Sx HOW THE INPUT IS MATCHED , -and -.Fa yytext -and -.Fa yyleng -set up appropriately. -It may either be one which matched as much text -as the originally chosen rule but came later in the -.Nm -input file, or one which matched less text. -For example, the following will both count the -words in the input and call the routine -.Fn special -whenever -.Qq frob -is seen: -.Bd -literal -offset indent -int word_count = 0; -%% - -frob special(); REJECT; -[^ \et\en]+ ++word_count; -.Ed -.Pp -Without the -.Em REJECT , -any "frob"'s in the input would not be counted as words, -since the scanner normally executes only one action per token. -Multiple -.Em REJECT Ns 's -are allowed, -each one finding the next best choice to the currently active rule. -For example, when the following scanner scans the token -.Qq abcd , -it will write -.Qq abcdabcaba -to the output: -.Bd -literal -offset indent -%% -a | -ab | -abc | -abcd ECHO; REJECT; -\&.|\en /* eat up any unmatched character */ -.Ed -.Pp -(The first three rules share the fourth's action since they use -the special -.Sq |\& -action.) -.Em REJECT -is a particularly expensive feature in terms of scanner performance; -if it is used in any of the scanner's actions it will slow down -all of the scanner's matching. -Furthermore, -.Em REJECT -cannot be used with the -.Fl Cf -or -.Fl CF -options -.Pq see below . -.Pp -Note also that unlike the other special actions, -.Em REJECT -is a -.Em branch ; -code immediately following it in the action will not be executed. -.It yymore() -Tells the scanner that the next time it matches a rule, the corresponding -token should be appended onto the current value of -.Fa yytext -rather than replacing it. -For example, given the input -.Qq mega-kludge -the following will write -.Qq mega-mega-kludge -to the output: -.Bd -literal -offset indent -%% -mega- ECHO; yymore(); -kludge ECHO; -.Ed -.Pp -First -.Qq mega- -is matched and echoed to the output. -Then -.Qq kludge -is matched, but the previous -.Qq mega- -is still hanging around at the beginning of -.Fa yytext -so the -.Em ECHO -for the -.Qq kludge -rule will actually write -.Qq mega-kludge . -.Pp -Two notes regarding use of -.Fn yymore : -First, -.Fn yymore -depends on the value of -.Fa yyleng -correctly reflecting the size of the current token, so -.Fa yyleng -must not be modified when using -.Fn yymore . -Second, the presence of -.Fn yymore -in the scanner's action entails a minor performance penalty in the -scanner's matching speed. -.It yyless(n) -Returns all but the first -.Ar n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.Fa yytext -and -.Fa yyleng -are adjusted appropriately (e.g., -.Fa yyleng -will now be equal to -.Ar n ) . -For example, on the input -.Qq foobar -the following will write out -.Qq foobarbar : -.Bd -literal -offset indent -%% -foobar ECHO; yyless(3); -[a-z]+ ECHO; -.Ed -.Pp -An argument of 0 to -.Fa yyless -will cause the entire current input string to be scanned again. -Unless how the scanner will subsequently process its input has been changed -(using -.Em BEGIN , -for example), -this will result in an endless loop. -.Pp -Note that -.Fa yyless -is a macro and can only be used in the -.Nm -input file, not from other source files. -.It unput(c) -Puts the character -.Ar c -back into the input stream. -It will be the next character scanned. -The following action will take the current token and cause it -to be rescanned enclosed in parentheses. -.Bd -literal -offset indent -{ - int i; - char *yycopy; - - /* Copy yytext because unput() trashes yytext */ - if ((yycopy = strdup(yytext)) == NULL) - err(1, NULL); - unput(')'); - for (i = yyleng - 1; i >= 0; --i) - unput(yycopy[i]); - unput('('); - free(yycopy); -} -.Ed -.Pp -Note that since each -.Fn unput -puts the given character back at the beginning of the input stream, -pushing back strings must be done back-to-front. -.Pp -An important potential problem when using -.Fn unput -is that if using -.Dq %pointer -.Pq the default , -a call to -.Fn unput -destroys the contents of -.Fa yytext , -starting with its rightmost character and devouring one character to -the left with each call. -If the value of -.Fa yytext -should be preserved after a call to -.Fn unput -.Pq as in the above example , -it must either first be copied elsewhere, or the scanner must be built using -.Dq %array -instead (see -.Sx HOW THE INPUT IS MATCHED ) . -.Pp -Finally, note that EOF cannot be put back -to attempt to mark the input stream with an end-of-file. -.It input() -Reads the next character from the input stream. -For example, the following is one way to eat up C comments: -.Bd -literal -offset indent -%% -"/*" { - int c; - - for (;;) { - while ((c = input()) != '*' && c != EOF) - ; /* eat up text of comment */ - - if (c == '*') { - while ((c = input()) == '*') - ; - if (c == '/') - break; /* found the end */ - } - - if (c == EOF) { - errx(1, "EOF in comment"); - break; - } - } -} -.Ed -.Pp -(Note that if the scanner is compiled using C++, then -.Fn input -is instead referred to as -.Fn yyinput , -in order to avoid a name clash with the C++ stream by the name of input.) -.It YY_FLUSH_BUFFER -Flushes the scanner's internal buffer -so that the next time the scanner attempts to match a token, -it will first refill the buffer using -.Dv YY_INPUT -(see -.Sx THE GENERATED SCANNER , -below). -This action is a special case of the more general -.Fn yy_flush_buffer -function, described below in the section -.Sx MULTIPLE INPUT BUFFERS . -.It yyterminate() -Can be used in lieu of a return statement in an action. -It terminates the scanner and returns a 0 to the scanner's caller, indicating -.Qq all done . -By default, -.Fn yyterminate -is also called when an end-of-file is encountered. -It is a macro and may be redefined. -.El -.Sh THE GENERATED SCANNER -The output of -.Nm -is the file -.Pa lex.yy.c , -which contains the scanning routine -.Fn yylex , -a number of tables used by it for matching tokens, -and a number of auxiliary routines and macros. -By default, -.Fn yylex -is declared as follows: -.Bd -unfilled -offset indent -int yylex() -{ - ... various definitions and the actions in here ... -} -.Ed -.Pp -(If the environment supports function prototypes, then it will -be "int yylex(void)".) -This definition may be changed by defining the -.Dv YY_DECL -macro. -For example: -.Bd -literal -offset indent -#define YY_DECL float lexscan(a, b) float a, b; -.Ed -.Pp -would give the scanning routine the name -.Em lexscan , -returning a float, and taking two floats as arguments. -Note that if arguments are given to the scanning routine using a -K&R-style/non-prototyped function declaration, -the definition must be terminated with a semi-colon -.Pq Sq ;\& . -.Pp -Whenever -.Fn yylex -is called, it scans tokens from the global input file -.Pa yyin -.Pq which defaults to stdin . -It continues until it either reaches an end-of-file -.Pq at which point it returns the value 0 -or one of its actions executes a -.Em return -statement. -.Pp -If the scanner reaches an end-of-file, subsequent calls are undefined -unless either -.Em yyin -is pointed at a new input file -.Pq in which case scanning continues from that file , -or -.Fn yyrestart -is called. -.Fn yyrestart -takes one argument, a -.Fa FILE * -pointer (which can be nil, if -.Dv YY_INPUT -has been set up to scan from a source other than -.Em yyin ) , -and initializes -.Em yyin -for scanning from that file. -Essentially there is no difference between just assigning -.Em yyin -to a new input file or using -.Fn yyrestart -to do so; the latter is available for compatibility with previous versions of -.Nm , -and because it can be used to switch input files in the middle of scanning. -It can also be used to throw away the current input buffer, -by calling it with an argument of -.Em yyin ; -but better is to use -.Dv YY_FLUSH_BUFFER -.Pq see above . -Note that -.Fn yyrestart -does not reset the start condition to -.Em INITIAL -(see -.Sx START CONDITIONS , -below). -.Pp -If -.Fn yylex -stops scanning due to executing a -.Em return -statement in one of the actions, the scanner may then be called again and it -will resume scanning where it left off. -.Pp -By default -.Pq and for purposes of efficiency , -the scanner uses block-reads rather than simple -.Xr getc 3 -calls to read characters from -.Em yyin . -The nature of how it gets its input can be controlled by defining the -.Dv YY_INPUT -macro. -.Dv YY_INPUT Ns 's -calling sequence is -.Qq YY_INPUT(buf,result,max_size) . -Its action is to place up to -.Dv max_size -characters in the character array -.Em buf -and return in the integer variable -.Em result -either the number of characters read or the constant -.Dv YY_NULL -(0 on -.Ux -systems) -to indicate -.Dv EOF . -The default -.Dv YY_INPUT -reads from the global file-pointer -.Qq yyin . -.Pp -A sample definition of -.Dv YY_INPUT -.Pq in the definitions section of the input file : -.Bd -unfilled -offset indent -%{ -#define YY_INPUT(buf,result,max_size) \e -{ \e - int c = getchar(); \e - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \e -} -%} -.Ed -.Pp -This definition will change the input processing to occur -one character at a time. -.Pp -When the scanner receives an end-of-file indication from -.Dv YY_INPUT , -it then checks the -.Fn yywrap -function. -If -.Fn yywrap -returns false -.Pq zero , -then it is assumed that the function has gone ahead and set up -.Em yyin -to point to another input file, and scanning continues. -If it returns true -.Pq non-zero , -then the scanner terminates, returning 0 to its caller. -Note that in either case, the start condition remains unchanged; -it does not revert to -.Em INITIAL . -.Pp -If you do not supply your own version of -.Fn yywrap , -then you must either use -.Dq %option noyywrap -(in which case the scanner behaves as though -.Fn yywrap -returned 1), or you must link with -.Fl lfl -to obtain the default version of the routine, which always returns 1. -.Pp -Three routines are available for scanning from in-memory buffers rather -than files: -.Fn yy_scan_string , -.Fn yy_scan_bytes , -and -.Fn yy_scan_buffer . -See the discussion of them below in the section -.Sx MULTIPLE INPUT BUFFERS . -.Pp -The scanner writes its -.Em ECHO -output to the -.Em yyout -global -.Pq default, stdout , -which may be redefined by the user simply by assigning it to some other -.Va FILE -pointer. -.Sh START CONDITIONS -.Nm -provides a mechanism for conditionally activating rules. -Any rule whose pattern is prefixed with -.Qq Aq sc -will only be active when the scanner is in the start condition named -.Qq sc . -For example, -.Bd -literal -offset indent -[^"]* { /* eat up the string body ... */ - ... -} -.Ed -.Pp -will be active only when the scanner is in the -.Qq STRING -start condition, and -.Bd -literal -offset indent -\e. { /* handle an escape ... */ - ... -} -.Ed -.Pp -will be active only when the current start condition is either -.Qq INITIAL , -.Qq STRING , -or -.Qq QUOTE . -.Pp -Start conditions are declared in the definitions -.Pq first -section of the input using unindented lines beginning with either -.Sq %s -or -.Sq %x -followed by a list of names. -The former declares -.Em inclusive -start conditions, the latter -.Em exclusive -start conditions. -A start condition is activated using the -.Em BEGIN -action. -Until the next -.Em BEGIN -action is executed, rules with the given start condition will be active and -rules with other start conditions will be inactive. -If the start condition is inclusive, -then rules with no start conditions at all will also be active. -If it is exclusive, -then only rules qualified with the start condition will be active. -A set of rules contingent on the same exclusive start condition -describe a scanner which is independent of any of the other rules in the -.Nm -input. -Because of this, exclusive start conditions make it easy to specify -.Qq mini-scanners -which scan portions of the input that are syntactically different -from the rest -.Pq e.g., comments . -.Pp -If the distinction between inclusive and exclusive start conditions -is still a little vague, here's a simple example illustrating the -connection between the two. -The set of rules: -.Bd -literal -offset indent -%s example -%% - -foo do_something(); - -bar something_else(); -.Ed -.Pp -is equivalent to -.Bd -literal -offset indent -%x example -%% - -foo do_something(); - -bar something_else(); -.Ed -.Pp -Without the -.Aq INITIAL,example -qualifier, the -.Dq bar -pattern in the second example wouldn't be active -.Pq i.e., couldn't match -when in start condition -.Dq example . -If we just used -.Aq example -to qualify -.Dq bar , -though, then it would only be active in -.Dq example -and not in -.Em INITIAL , -while in the first example it's active in both, -because in the first example the -.Dq example -start condition is an inclusive -.Pq Sq %s -start condition. -.Pp -Also note that the special start-condition specifier -.Sq Aq * -matches every start condition. -Thus, the above example could also have been written: -.Bd -literal -offset indent -%x example -%% - -foo do_something(); - -<*>bar something_else(); -.Ed -.Pp -The default rule (to -.Em ECHO -any unmatched character) remains active in start conditions. -It is equivalent to: -.Bd -literal -offset indent -<*>.|\en ECHO; -.Ed -.Pp -.Dq BEGIN(0) -returns to the original state where only the rules with -no start conditions are active. -This state can also be referred to as the start-condition -.Em INITIAL , -so -.Dq BEGIN(INITIAL) -is equivalent to -.Dq BEGIN(0) . -(The parentheses around the start condition name are not required but -are considered good style.) -.Pp -.Em BEGIN -actions can also be given as indented code at the beginning -of the rules section. -For example, the following will cause the scanner to enter the -.Qq SPECIAL -start condition whenever -.Fn yylex -is called and the global variable -.Fa enter_special -is true: -.Bd -literal -offset indent -int enter_special; - -%x SPECIAL -%% - if (enter_special) - BEGIN(SPECIAL); - -blahblahblah -\&...more rules follow... -.Ed -.Pp -To illustrate the uses of start conditions, -here is a scanner which provides two different interpretations -of a string like -.Qq 123.456 . -By default it will treat it as three tokens: the integer -.Qq 123 , -a dot -.Pq Sq .\& , -and the integer -.Qq 456 . -But if the string is preceded earlier in the line by the string -.Qq expect-floats -it will treat it as a single token, the floating-point number 123.456: -.Bd -literal -offset indent -%{ -#include -%} -%s expect - -%% -expect-floats BEGIN(expect); - -[0-9]+"."[0-9]+ { - printf("found a float, = %f\en", - atof(yytext)); -} -\en { - /* - * That's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers. - */ - BEGIN(INITIAL); -} - -[0-9]+ { - printf("found an integer, = %d\en", - atoi(yytext)); -} - -"." printf("found a dot\en"); -.Ed -.Pp -Here is a scanner which recognizes -.Pq and discards -C comments while maintaining a count of the current input line: -.Bd -literal -offset indent -%x comment -%% -int line_num = 1; - -"/*" BEGIN(comment); - -[^*\en]* /* eat anything that's not a '*' */ -"*"+[^*/\en]* /* eat up '*'s not followed by '/'s */ -\en ++line_num; -"*"+"/" BEGIN(INITIAL); -.Ed -.Pp -This scanner goes to a bit of trouble to match as much -text as possible with each rule. -In general, when attempting to write a high-speed scanner -try to match as much as possible in each rule, as it's a big win. -.Pp -Note that start-condition names are really integer values and -can be stored as such. -Thus, the above could be extended in the following fashion: -.Bd -literal -offset indent -%x comment foo -%% -int line_num = 1; -int comment_caller; - -"/*" { - comment_caller = INITIAL; - BEGIN(comment); -} - -\&... - -"/*" { - comment_caller = foo; - BEGIN(comment); -} - -[^*\en]* /* eat anything that's not a '*' */ -"*"+[^*/\en]* /* eat up '*'s not followed by '/'s */ -\en ++line_num; -"*"+"/" BEGIN(comment_caller); -.Ed -.Pp -Furthermore, the current start condition can be accessed by using -the integer-valued -.Dv YY_START -macro. -For example, the above assignments to -.Em comment_caller -could instead be written -.Pp -.Dl comment_caller = YY_START; -.Pp -Flex provides -.Dv YYSTATE -as an alias for -.Dv YY_START -(since that is what's used by -.At -.Nm lex ) . -.Pp -Note that start conditions do not have their own name-space; -%s's and %x's declare names in the same fashion as #define's. -.Pp -Finally, here's an example of how to match C-style quoted strings using -exclusive start conditions, including expanded escape sequences -(but not including checking for a string that's too long): -.Bd -literal -offset indent -%x str - -%% -#define MAX_STR_CONST 1024 -char string_buf[MAX_STR_CONST]; -char *string_buf_ptr; - -\e" string_buf_ptr = string_buf; BEGIN(str); - -\e" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\e0'; - /* - * return string constant token type and - * value to parser - */ -} - -\en { - /* error - unterminated string constant */ - /* generate error message */ -} - -\e\e[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf(yytext + 1, "%o", &result); - - if (result > 0xff) { - /* error, constant is out-of-bounds */ - } else - *string_buf_ptr++ = result; -} - -\e\e[0-9]+ { - /* - * generate error - bad escape sequence; something - * like '\e48' or '\e0777777' - */ -} - -\e\en *string_buf_ptr++ = '\en'; -\e\et *string_buf_ptr++ = '\et'; -\e\er *string_buf_ptr++ = '\er'; -\e\eb *string_buf_ptr++ = '\eb'; -\e\ef *string_buf_ptr++ = '\ef'; - -\e\e(.|\en) *string_buf_ptr++ = yytext[1]; - -[^\e\e\en\e"]+ { - char *yptr = yytext; - - while (*yptr) - *string_buf_ptr++ = *yptr++; -} -.Ed -.Pp -Often, such as in some of the examples above, -a whole bunch of rules are all preceded by the same start condition(s). -.Nm -makes this a little easier and cleaner by introducing a notion of -start condition -.Em scope . -A start condition scope is begun with: -.Pp -.Dl { -.Pp -where -.Dq SCs -is a list of one or more start conditions. -Inside the start condition scope, every rule automatically has the prefix -.Aq SCs -applied to it, until a -.Sq } -which matches the initial -.Sq { . -So, for example, -.Bd -literal -offset indent -{ - "\e\en" return '\en'; - "\e\er" return '\er'; - "\e\ef" return '\ef'; - "\e\e0" return '\e0'; -} -.Ed -.Pp -is equivalent to: -.Bd -literal -offset indent -"\e\en" return '\en'; -"\e\er" return '\er'; -"\e\ef" return '\ef'; -"\e\e0" return '\e0'; -.Ed -.Pp -Start condition scopes may be nested. -.Pp -Three routines are available for manipulating stacks of start conditions: -.Bl -tag -width Ds -.It void yy_push_state(int new_state) -Pushes the current start condition onto the top of the start condition -stack and switches to -.Fa new_state -as though -.Dq BEGIN new_state -had been used -.Pq recall that start condition names are also integers . -.It void yy_pop_state() -Pops the top of the stack and switches to it via -.Em BEGIN . -.It int yy_top_state() -Returns the top of the stack without altering the stack's contents. -.El -.Pp -The start condition stack grows dynamically and so has no built-in -size limitation. -If memory is exhausted, program execution aborts. -.Pp -To use start condition stacks, scanners must include a -.Dq %option stack -directive (see -.Sx OPTIONS -below). -.Sh MULTIPLE INPUT BUFFERS -Some scanners -(such as those which support -.Qq include -files) -require reading from several input streams. -As -.Nm -scanners do a large amount of buffering, one cannot control -where the next input will be read from by simply writing a -.Dv YY_INPUT -which is sensitive to the scanning context. -.Dv YY_INPUT -is only called when the scanner reaches the end of its buffer, which -may be a long time after scanning a statement such as an -.Qq include -which requires switching the input source. -.Pp -To negotiate these sorts of problems, -.Nm -provides a mechanism for creating and switching between multiple -input buffers. -An input buffer is created by using: -.Pp -.D1 YY_BUFFER_STATE yy_create_buffer(FILE *file, int size) -.Pp -which takes a -.Fa FILE -pointer and a -.Fa size -and creates a buffer associated with the given file and large enough to hold -.Fa size -characters (when in doubt, use -.Dv YY_BUF_SIZE -for the size). -It returns a -.Dv YY_BUFFER_STATE -handle, which may then be passed to other routines -.Pq see below . -The -.Dv YY_BUFFER_STATE -type is a pointer to an opaque -.Dq struct yy_buffer_state -structure, so -.Dv YY_BUFFER_STATE -variables may be safely initialized to -.Dq ((YY_BUFFER_STATE) 0) -if desired, and the opaque structure can also be referred to in order to -correctly declare input buffers in source files other than that of scanners. -Note that the -.Fa FILE -pointer in the call to -.Fn yy_create_buffer -is only used as the value of -.Fa yyin -seen by -.Dv YY_INPUT ; -if -.Dv YY_INPUT -is redefined so that it no longer uses -.Fa yyin , -then a nil -.Fa FILE -pointer can safely be passed to -.Fn yy_create_buffer . -To select a particular buffer to scan: -.Pp -.D1 void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) -.Pp -It switches the scanner's input buffer so subsequent tokens will -come from -.Fa new_buffer . -Note that -.Fn yy_switch_to_buffer -may be used by -.Fn yywrap -to set things up for continued scanning, -instead of opening a new file and pointing -.Fa yyin -at it. -Note also that switching input sources via either -.Fn yy_switch_to_buffer -or -.Fn yywrap -does not change the start condition. -.Pp -.D1 void yy_delete_buffer(YY_BUFFER_STATE buffer) -.Pp -is used to reclaim the storage associated with a buffer. -.Pf ( Fa buffer -can be nil, in which case the routine does nothing.) -To clear the current contents of a buffer: -.Pp -.D1 void yy_flush_buffer(YY_BUFFER_STATE buffer) -.Pp -This function discards the buffer's contents, -so the next time the scanner attempts to match a token from the buffer, -it will first fill the buffer anew using -.Dv YY_INPUT . -.Pp -.Fn yy_new_buffer -is an alias for -.Fn yy_create_buffer , -provided for compatibility with the C++ use of -.Em new -and -.Em delete -for creating and destroying dynamic objects. -.Pp -Finally, the -.Dv YY_CURRENT_BUFFER -macro returns a -.Dv YY_BUFFER_STATE -handle to the current buffer. -.Pp -Here is an example of using these features for writing a scanner -which expands include files (the -.Aq Aq EOF -feature is discussed below): -.Bd -literal -offset indent -/* - * the "incl" state is used for picking up the name - * of an include file - */ -%x incl - -%{ -#define MAX_INCLUDE_DEPTH 10 -YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; -int include_stack_ptr = 0; -%} - -%% -include BEGIN(incl); - -[a-z]+ ECHO; -[^a-z\en]*\en? ECHO; - -[ \et]* /* eat the whitespace */ -[^ \et\en]+ { /* got the include file name */ - if (include_stack_ptr >= MAX_INCLUDE_DEPTH) - errx(1, "Includes nested too deeply"); - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen(yytext, "r"); - - if (yyin == NULL) - err(1, NULL); - - yy_switch_to_buffer( - yy_create_buffer(yyin, YY_BUF_SIZE)); - - BEGIN(INITIAL); -} - -<> { - if (--include_stack_ptr < 0) - yyterminate(); - else { - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer( - include_stack[include_stack_ptr]); - } -} -.Ed -.Pp -Three routines are available for setting up input buffers for -scanning in-memory strings instead of files. -All of them create a new input buffer for scanning the string, -and return a corresponding -.Dv YY_BUFFER_STATE -handle (which should be deleted afterwards using -.Fn yy_delete_buffer ) . -They also switch to the new buffer using -.Fn yy_switch_to_buffer , -so the next call to -.Fn yylex -will start scanning the string. -.Bl -tag -width Ds -.It yy_scan_string(const char *str) -Scans a NUL-terminated string. -.It yy_scan_bytes(const char *bytes, int len) -Scans -.Fa len -bytes -.Pq including possibly NUL's -starting at location -.Fa bytes . -.El -.Pp -Note that both of these functions create and scan a copy -of the string or bytes. -(This may be desirable, since -.Fn yylex -modifies the contents of the buffer it is scanning.) -The copy can be avoided by using: -.Bl -tag -width Ds -.It yy_scan_buffer(char *base, yy_size_t size) -Which scans the buffer starting at -.Fa base , -consisting of -.Fa size -bytes, the last two bytes of which must be -.Dv YY_END_OF_BUFFER_CHAR -.Pq ASCII NUL . -These last two bytes are not scanned; thus, scanning consists of -base[0] through base[size-2], inclusive. -.Pp -If -.Fa base -is not set up in this manner -(i.e., forget the final two -.Dv YY_END_OF_BUFFER_CHAR -bytes), then -.Fn yy_scan_buffer -returns a nil pointer instead of creating a new input buffer. -.Pp -The type -.Fa yy_size_t -is an integral type which can be cast to an integer expression -reflecting the size of the buffer. -.El -.Sh END-OF-FILE RULES -The special rule -.Qq Aq Aq EOF -indicates actions which are to be taken when an end-of-file is encountered and -.Fn yywrap -returns non-zero -.Pq i.e., indicates no further files to process . -The action must finish by doing one of four things: -.Bl -dash -.It -Assigning -.Em yyin -to a new input file -(in previous versions of -.Nm , -after doing the assignment, it was necessary to call the special action -.Dv YY_NEW_FILE ; -this is no longer necessary). -.It -Executing a -.Em return -statement. -.It -Executing the special -.Fn yyterminate -action. -.It -Switching to a new buffer using -.Fn yy_switch_to_buffer -as shown in the example above. -.El -.Pp -.Aq Aq EOF -rules may not be used with other patterns; -they may only be qualified with a list of start conditions. -If an unqualified -.Aq Aq EOF -rule is given, it applies to all start conditions which do not already have -.Aq Aq EOF -actions. -To specify an -.Aq Aq EOF -rule for only the initial start condition, use -.Pp -.Dl <> -.Pp -These rules are useful for catching things like unclosed comments. -An example: -.Bd -literal -offset indent -%x quote -%% - -\&...other rules for dealing with quotes... - -<> { - error("unterminated quote"); - yyterminate(); -} -<> { - if (*++filelist) - yyin = fopen(*filelist, "r"); - else - yyterminate(); -} -.Ed -.Sh MISCELLANEOUS MACROS -The macro -.Dv YY_USER_ACTION -can be defined to provide an action -which is always executed prior to the matched rule's action. -For example, -it could be #define'd to call a routine to convert yytext to lower-case. -When -.Dv YY_USER_ACTION -is invoked, the variable -.Fa yy_act -gives the number of the matched rule -.Pq rules are numbered starting with 1 . -For example, to profile how often each rule is matched, -the following would do the trick: -.Pp -.Dl #define YY_USER_ACTION ++ctr[yy_act] -.Pp -where -.Fa ctr -is an array to hold the counts for the different rules. -Note that the macro -.Dv YY_NUM_RULES -gives the total number of rules -(including the default rule, even if -.Fl s -is used), -so a correct declaration for -.Fa ctr -is: -.Pp -.Dl int ctr[YY_NUM_RULES]; -.Pp -The macro -.Dv YY_USER_INIT -may be defined to provide an action which is always executed before -the first scan -.Pq and before the scanner's internal initializations are done . -For example, it could be used to call a routine to read -in a data table or open a logging file. -.Pp -The macro -.Dv yy_set_interactive(is_interactive) -can be used to control whether the current buffer is considered -.Em interactive . -An interactive buffer is processed more slowly, -but must be used when the scanner's input source is indeed -interactive to avoid problems due to waiting to fill buffers -(see the discussion of the -.Fl I -flag below). -A non-zero value in the macro invocation marks the buffer as interactive, -a zero value as non-interactive. -Note that use of this macro overrides -.Dq %option always-interactive -or -.Dq %option never-interactive -(see -.Sx OPTIONS -below). -.Fn yy_set_interactive -must be invoked prior to beginning to scan the buffer that is -.Pq or is not -to be considered interactive. -.Pp -The macro -.Dv yy_set_bol(at_bol) -can be used to control whether the current buffer's scanning -context for the next token match is done as though at the -beginning of a line. -A non-zero macro argument makes rules anchored with -.Sq ^ -active, while a zero argument makes -.Sq ^ -rules inactive. -.Pp -The macro -.Dv YY_AT_BOL -returns true if the next token scanned from the current buffer will have -.Sq ^ -rules active, false otherwise. -.Pp -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.Dv YY_BREAK , -which may be redefined. -By default, it is simply a -.Qq break , -to separate each rule's action from the following rules. -Redefining -.Dv YY_BREAK -allows, for example, C++ users to -.Dq #define YY_BREAK -to do nothing -(while being very careful that every rule ends with a -.Qq break -or a -.Qq return ! ) -to avoid suffering from unreachable statement warnings where because a rule's -action ends with -.Dq return , -the -.Dv YY_BREAK -is inaccessible. -.Sh VALUES AVAILABLE TO THE USER -This section summarizes the various values available to the user -in the rule actions. -.Bl -tag -width Ds -.It char *yytext -Holds the text of the current token. -It may be modified but not lengthened -.Pq characters cannot be appended to the end . -.Pp -If the special directive -.Dq %array -appears in the first section of the scanner description, then -.Fa yytext -is instead declared -.Dq char yytext[YYLMAX] , -where -.Dv YYLMAX -is a macro definition that can be redefined in the first section -to change the default value -.Pq generally 8KB . -Using -.Dq %array -results in somewhat slower scanners, but the value of -.Fa yytext -becomes immune to calls to -.Fn input -and -.Fn unput , -which potentially destroy its value when -.Fa yytext -is a character pointer. -The opposite of -.Dq %array -is -.Dq %pointer , -which is the default. -.Pp -.Dq %array -cannot be used when generating C++ scanner classes -(the -.Fl + -flag). -.It int yyleng -Holds the length of the current token. -.It FILE *yyin -Is the file which by default -.Nm -reads from. -It may be redefined, but doing so only makes sense before -scanning begins or after an -.Dv EOF -has been encountered. -Changing it in the midst of scanning will have unexpected results since -.Nm -buffers its input; use -.Fn yyrestart -instead. -Once scanning terminates because an end-of-file -has been seen, -.Fa yyin -can be assigned as the new input file -and the scanner can be called again to continue scanning. -.It void yyrestart(FILE *new_file) -May be called to point -.Fa yyin -at the new input file. -The switch-over to the new file is immediate -.Pq any previously buffered-up input is lost . -Note that calling -.Fn yyrestart -with -.Fa yyin -as an argument thus throws away the current input buffer and continues -scanning the same input file. -.It FILE *yyout -Is the file to which -.Em ECHO -actions are done. -It can be reassigned by the user. -.It YY_CURRENT_BUFFER -Returns a -.Dv YY_BUFFER_STATE -handle to the current buffer. -.It YY_START -Returns an integer value corresponding to the current start condition. -This value can subsequently be used with -.Em BEGIN -to return to that start condition. -.El -.Sh INTERFACING WITH YACC -One of the main uses of -.Nm -is as a companion to the -.Xr yacc 1 -parser-generator. -yacc parsers expect to call a routine named -.Fn yylex -to find the next input token. -The routine is supposed to return the type of the next token -as well as putting any associated value in the global -.Fa yylval , -which is defined externally, -and can be a union or any other complex data structure. -To use -.Nm -with yacc, one specifies the -.Fl d -option to yacc to instruct it to generate the file -.Pa y.tab.h -containing definitions of all the -.Dq %tokens -appearing in the yacc input. -This file is then included in the -.Nm -scanner. -For example, if one of the tokens is -.Qq TOK_NUMBER , -part of the scanner might look like: -.Bd -literal -offset indent -%{ -#include "y.tab.h" -%} - -%% - -[0-9]+ yylval = atoi(yytext); return TOK_NUMBER; -.Ed -.Sh OPTIONS -.Nm -has the following options: -.Bl -tag -width Ds -.It Fl 7 -Instructs -.Nm -to generate a 7-bit scanner, i.e., one which can only recognize 7-bit -characters in its input. -The advantage of using -.Fl 7 -is that the scanner's tables can be up to half the size of those generated -using the -.Fl 8 -option -.Pq see below . -The disadvantage is that such scanners often hang -or crash if their input contains an 8-bit character. -.Pp -Note, however, that unless generating a scanner using the -.Fl Cf -or -.Fl CF -table compression options, use of -.Fl 7 -will save only a small amount of table space, -and make the scanner considerably less portable. -.Nm flex Ns 's -default behavior is to generate an 8-bit scanner unless -.Fl Cf -or -.Fl CF -is specified, in which case -.Nm -defaults to generating 7-bit scanners unless it was -configured to generate 8-bit scanners -(as will often be the case with non-USA sites). -It is possible tell whether -.Nm -generated a 7-bit or an 8-bit scanner by inspecting the flag summary in the -.Fl v -output as described below. -.Pp -Note that if -.Fl Cfe -or -.Fl CFe -are used -(the table compression options, but also using equivalence classes as -discussed below), -.Nm -still defaults to generating an 8-bit scanner, -since usually with these compression options full 8-bit tables -are not much more expensive than 7-bit tables. -.It Fl 8 -Instructs -.Nm -to generate an 8-bit scanner, i.e., one which can recognize 8-bit -characters. -This flag is only needed for scanners generated using -.Fl Cf -or -.Fl CF , -as otherwise -.Nm -defaults to generating an 8-bit scanner anyway. -.Pp -See the discussion of -.Fl 7 -above for -.Nm flex Ns 's -default behavior and the tradeoffs between 7-bit and 8-bit scanners. -.It Fl B -Instructs -.Nm -to generate a -.Em batch -scanner, the opposite of -.Em interactive -scanners generated by -.Fl I -.Pq see below . -In general, -.Fl B -is used when the scanner will never be used interactively, -and you want to squeeze a little more performance out of it. -If the aim is instead to squeeze out a lot more performance, -use the -.Fl Cf -or -.Fl CF -options -.Pq discussed below , -which turn on -.Fl B -automatically anyway. -.It Fl b -Generate backing-up information to -.Pa lex.backup . -This is a list of scanner states which require backing up -and the input characters on which they do so. -By adding rules one can remove backing-up states. -If all backing-up states are eliminated and -.Fl Cf -or -.Fl CF -is used, the generated scanner will run faster (see the -.Fl p -flag). -Only users who wish to squeeze every last cycle out of their -scanners need worry about this option. -(See the section on -.Sx PERFORMANCE CONSIDERATIONS -below.) -.It Fl C Ns Op Cm aeFfmr -Controls the degree of table compression and, more generally, trade-offs -between small scanners and fast scanners. -.Bl -tag -width Ds -.It Fl Ca -Instructs -.Nm -to trade off larger tables in the generated scanner for faster performance -because the elements of the tables are better aligned for memory access -and computation. -On some -.Tn RISC -architectures, fetching and manipulating longwords is more efficient -than with smaller-sized units such as shortwords. -This option can double the size of the tables used by the scanner. -.It Fl Ce -Directs -.Nm -to construct -.Em equivalence classes , -i.e., sets of characters which have identical lexical properties -(for example, if the only appearance of digits in the -.Nm -input is in the character class -.Qq [0-9] -then the digits -.Sq 0 , -.Sq 1 , -.Sq ... , -.Sq 9 -will all be put in the same equivalence class). -Equivalence classes usually give dramatic reductions in the final -table/object file sizes -.Pq typically a factor of 2\-5 -and are pretty cheap performance-wise -.Pq one array look-up per character scanned . -.It Fl CF -Specifies that the alternate fast scanner representation -(described below under the -.Fl F -option) -should be used. -This option cannot be used with -.Fl + . -.It Fl Cf -Specifies that the -.Em full -scanner tables should be generated \- -.Nm -should not compress the tables by taking advantage of -similar transition functions for different states. -.It Fl \&Cm -Directs -.Nm -to construct -.Em meta-equivalence classes , -which are sets of equivalence classes -(or characters, if equivalence classes are not being used) -that are commonly used together. -Meta-equivalence classes are often a big win when using compressed tables, -but they have a moderate performance impact -(one or two -.Qq if -tests and one array look-up per character scanned). -.It Fl Cr -Causes the generated scanner to -.Em bypass -use of the standard I/O library -.Pq stdio -for input. -Instead of calling -.Xr fread 3 -or -.Xr getc 3 , -the scanner will use the -.Xr read 2 -system call, -resulting in a performance gain which varies from system to system, -but in general is probably negligible unless -.Fl Cf -or -.Fl CF -are being used. -Using -.Fl Cr -can cause strange behavior if, for example, reading from -.Fa yyin -using stdio prior to calling the scanner -(because the scanner will miss whatever text previous reads left -in the stdio input buffer). -.Pp -.Fl Cr -has no effect if -.Dv YY_INPUT -is defined -(see -.Sx THE GENERATED SCANNER -above). -.El -.Pp -A lone -.Fl C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.Pp -The options -.Fl Cf -or -.Fl CF -and -.Fl \&Cm -do not make sense together \- there is no opportunity for meta-equivalence -classes if the table is not being compressed. -Otherwise the options may be freely mixed, and are cumulative. -.Pp -The default setting is -.Fl Cem -which specifies that -.Nm -should generate equivalence classes and meta-equivalence classes. -This setting provides the highest degree of table compression. -It is possible to trade off faster-executing scanners at the cost of -larger tables with the following generally being true: -.Bd -unfilled -offset indent -slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a -fastest & largest -.Ed -.Pp -Note that scanners with the smallest tables are usually generated and -compiled the quickest, -so during development the default is usually best, -maximal compression. -.Pp -.Fl Cfe -is often a good compromise between speed and size for production scanners. -.It Fl d -Makes the generated scanner run in debug mode. -Whenever a pattern is recognized and the global -.Fa yy_flex_debug -is non-zero -.Pq which is the default , -the scanner will write to stderr a line of the form: -.Pp -.D1 --accepting rule at line 53 ("the matched text") -.Pp -The line number refers to the location of the rule in the file -defining the scanner -(i.e., the file that was fed to -.Nm ) . -Messages are also generated when the scanner backs up, -accepts the default rule, -reaches the end of its input buffer -(or encounters a NUL; -at this point, the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.It Fl F -Specifies that the fast scanner table representation should be used -.Pq and stdio bypassed . -This representation is about as fast as the full table representation -.Pq Fl f , -and for some sets of patterns will be considerably smaller -.Pq and for others, larger . -In general, if the pattern set contains both -.Qq keywords -and a catch-all, -.Qq identifier -rule, such as in the set: -.Bd -unfilled -offset indent -"case" return TOK_CASE; -"switch" return TOK_SWITCH; -\&... -"default" return TOK_DEFAULT; -[a-z]+ return TOK_ID; -.Ed -.Pp -then it's better to use the full table representation. -If only the -.Qq identifier -rule is present and a hash table or some such is used to detect the keywords, -it's better to use -.Fl F . -.Pp -This option is equivalent to -.Fl CFr -.Pq see above . -It cannot be used with -.Fl + . -.It Fl f -Specifies -.Em fast scanner . -No table compression is done and stdio is bypassed. -The result is large but fast. -This option is equivalent to -.Fl Cfr -.Pq see above . -.It Fl h -Generates a help summary of -.Nm flex Ns 's -options to stdout and then exits. -.Fl ?\& -and -.Fl Fl help -are synonyms for -.Fl h . -.It Fl I -Instructs -.Nm -to generate an -.Em interactive -scanner. -An interactive scanner is one that only looks ahead to decide -what token has been matched if it absolutely must. -It turns out that always looking one extra character ahead, -even if the scanner has already seen enough text -to disambiguate the current token, is a bit faster than -only looking ahead when necessary. -But scanners that always look ahead give dreadful interactive performance; -for example, when a user types a newline, -it is not recognized as a newline token until they enter -.Em another -token, which often means typing in another whole line. -.Pp -.Nm -scanners default to -.Em interactive -unless -.Fl Cf -or -.Fl CF -table-compression options are specified -.Pq see above . -That's because if high-performance is most important, -one of these options should be used, -so if they weren't, -.Nm -assumes it is preferable to trade off a bit of run-time performance for -intuitive interactive behavior. -Note also that -.Fl I -cannot be used in conjunction with -.Fl Cf -or -.Fl CF . -Thus, this option is not really needed; it is on by default for all those -cases in which it is allowed. -.Pp -A scanner can be forced to not be interactive by using -.Fl B -.Pq see above . -.It Fl i -Instructs -.Nm -to generate a case-insensitive scanner. -The case of letters given in the -.Nm -input patterns will be ignored, -and tokens in the input will be matched regardless of case. -The matched text given in -.Fa yytext -will have the preserved case -.Pq i.e., it will not be folded . -.It Fl L -Instructs -.Nm -not to generate -.Dq #line -directives. -Without this option, -.Nm -peppers the generated scanner with #line directives so error messages -in the actions will be correctly located with respect to either the original -.Nm -input file -(if the errors are due to code in the input file), -or -.Pa lex.yy.c -(if the errors are -.Nm flex Ns 's -fault \- these sorts of errors should be reported to the email address -given below). -.It Fl l -Turns on maximum compatibility with the original -.At -.Nm lex -implementation. -Note that this does not mean full compatibility. -Use of this option costs a considerable amount of performance, -and it cannot be used with the -.Fl + , f , F , Cf , -or -.Fl CF -options. -For details on the compatibilities it provides, see the section -.Sx INCOMPATIBILITIES WITH LEX AND POSIX -below. -This option also results in the name -.Dv YY_FLEX_LEX_COMPAT -being #define'd in the generated scanner. -.It Fl n -Another do-nothing, deprecated option included only for -.Tn POSIX -compliance. -.It Fl o Ns Ar output -Directs -.Nm -to write the scanner to the file -.Ar output -instead of -.Pa lex.yy.c . -If -.Fl o -is combined with the -.Fl t -option, then the scanner is written to stdout but its -.Dq #line -directives -(see the -.Fl L -option above) -refer to the file -.Ar output . -.It Fl P Ns Ar prefix -Changes the default -.Qq yy -prefix used by -.Nm -for all globally visible variable and function names to instead be -.Ar prefix . -For example, -.Fl P Ns Ar foo -changes the name of -.Fa yytext -to -.Fa footext . -It also changes the name of the default output file from -.Pa lex.yy.c -to -.Pa lex.foo.c . -Here are all of the names affected: -.Bd -unfilled -offset indent -yy_create_buffer -yy_delete_buffer -yy_flex_debug -yy_init_buffer -yy_flush_buffer -yy_load_buffer_state -yy_switch_to_buffer -yyin -yyleng -yylex -yylineno -yyout -yyrestart -yytext -yywrap -.Ed -.Pp -(If using a C++ scanner, then only -.Fa yywrap -and -.Fa yyFlexLexer -are affected.) -Within the scanner itself, it is still possible to refer to the global variables -and functions using either version of their name; but externally, they -have the modified name. -.Pp -This option allows multiple -.Nm -programs to be easily linked together into the same executable. -Note, though, that using this option also renames -.Fn yywrap , -so now either an -.Pq appropriately named -version of the routine for the scanner must be supplied, or -.Dq %option noyywrap -must be used, as linking with -.Fl lfl -no longer provides one by default. -.It Fl p -Generates a performance report to stderr. -The report consists of comments regarding features of the -.Nm -input file which will cause a serious loss of performance in the resulting -scanner. -If the flag is specified twice, -comments regarding features that lead to minor performance losses -will also be reported> -.Pp -Note that the use of -.Em REJECT , -.Dq %option yylineno , -and variable trailing context -(see the -.Sx BUGS -section below) -entails a substantial performance penalty; use of -.Fn yymore , -the -.Sq ^ -operator, and the -.Fl I -flag entail minor performance penalties. -.It Fl S Ns Ar skeleton -Overrides the default skeleton file from which -.Nm -constructs its scanners. -This option is needed only for -.Nm -maintenance or development. -.It Fl s -Causes the default rule -.Pq that unmatched scanner input is echoed to stdout -to be suppressed. -If the scanner encounters input that does not -match any of its rules, it aborts with an error. -This option is useful for finding holes in a scanner's rule set. -.It Fl T -Makes -.Nm -run in -.Em trace -mode. -It will generate a lot of messages to stderr concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. -This option is mostly for use in maintaining -.Nm . -.It Fl t -Instructs -.Nm -to write the scanner it generates to standard output instead of -.Pa lex.yy.c . -.It Fl V -Prints the version number to stdout and exits. -.Fl Fl version -is a synonym for -.Fl V . -.It Fl v -Specifies that -.Nm -should write to stderr -a summary of statistics regarding the scanner it generates. -Most of the statistics are meaningless to the casual -.Nm -user, but the first line identifies the version of -.Nm -(same as reported by -.Fl V ) , -and the next line the flags used when generating the scanner, -including those that are on by default. -.It Fl w -Suppresses warning messages. -.It Fl + -Specifies that -.Nm -should generate a C++ scanner class. -See the section on -.Sx GENERATING C++ SCANNERS -below for details. -.El -.Pp -.Nm -also provides a mechanism for controlling options within the -scanner specification itself, rather than from the -.Nm -command line. -This is done by including -.Dq %option -directives in the first section of the scanner specification. -Multiple options can be specified with a single -.Dq %option -directive, and multiple directives in the first section of the -.Nm -input file. -.Pp -Most options are given simply as names, optionally preceded by the word -.Qq no -.Pq with no intervening whitespace -to negate their meaning. -A number are equivalent to -.Nm -flags or their negation: -.Bd -unfilled -offset indent -7bit -7 option -8bit -8 option -align -Ca option -backup -b option -batch -B option -c++ -+ option - -caseful or -case-sensitive opposite of -i (default) - -case-insensitive or -caseless -i option - -debug -d option -default opposite of -s option -ecs -Ce option -fast -F option -full -f option -interactive -I option -lex-compat -l option -meta-ecs -Cm option -perf-report -p option -read -Cr option -stdout -t option -verbose -v option -warn opposite of -w option - (use "%option nowarn" for -w) - -array equivalent to "%array" -pointer equivalent to "%pointer" (default) -.Ed -.Pp -Some %option's provide features otherwise not available: -.Bl -tag -width Ds -.It always-interactive -Instructs -.Nm -to generate a scanner which always considers its input -.Qq interactive . -Normally, on each new input file the scanner calls -.Fn isatty -in an attempt to determine whether the scanner's input source is interactive -and thus should be read a character at a time. -When this option is used, however, no such call is made. -.It main -Directs -.Nm -to provide a default -.Fn main -program for the scanner, which simply calls -.Fn yylex . -This option implies -.Dq noyywrap -.Pq see below . -.It never-interactive -Instructs -.Nm -to generate a scanner which never considers its input -.Qq interactive -(again, no call made to -.Fn isatty ) . -This is the opposite of -.Dq always-interactive . -.It stack -Enables the use of start condition stacks -(see -.Sx START CONDITIONS -above). -.It stdinit -If set (i.e., -.Dq %option stdinit ) , -initializes -.Fa yyin -and -.Fa yyout -to stdin and stdout, instead of the default of -.Dq nil . -Some existing -.Nm lex -programs depend on this behavior, even though it is not compliant with ANSI C, -which does not require stdin and stdout to be compile-time constant. -.It yylineno -Directs -.Nm -to generate a scanner that maintains the number of the current line -read from its input in the global variable -.Fa yylineno . -This option is implied by -.Dq %option lex-compat . -.It yywrap -If unset (i.e., -.Dq %option noyywrap ) , -makes the scanner not call -.Fn yywrap -upon an end-of-file, but simply assume that there are no more files to scan -(until the user points -.Fa yyin -at a new file and calls -.Fn yylex -again). -.El -.Pp -.Nm -scans rule actions to determine whether the -.Em REJECT -or -.Fn yymore -features are being used. -The -.Dq reject -and -.Dq yymore -options are available to override its decision as to whether to use the -options, either by setting them (e.g., -.Dq %option reject ) -to indicate the feature is indeed used, -or unsetting them to indicate it actually is not used -(e.g., -.Dq %option noyymore ) . -.Pp -Three options take string-delimited values, offset with -.Sq = : -.Pp -.D1 %option outfile="ABC" -.Pp -is equivalent to -.Fl o Ns Ar ABC , -and -.Pp -.D1 %option prefix="XYZ" -.Pp -is equivalent to -.Fl P Ns Ar XYZ . -Finally, -.Pp -.D1 %option yyclass="foo" -.Pp -only applies when generating a C++ scanner -.Pf ( Fl + -option). -It informs -.Nm -that -.Dq foo -has been derived as a subclass of yyFlexLexer, so -.Nm -will place actions in the member function -.Dq foo::yylex() -instead of -.Dq yyFlexLexer::yylex() . -It also generates a -.Dq yyFlexLexer::yylex() -member function that emits a run-time error (by invoking -.Dq yyFlexLexer::LexerError() ) -if called. -See -.Sx GENERATING C++ SCANNERS , -below, for additional information. -.Pp -A number of options are available for -lint -purists who want to suppress the appearance of unneeded routines -in the generated scanner. -Each of the following, if unset -(e.g., -.Dq %option nounput ) , -results in the corresponding routine not appearing in the generated scanner: -.Bd -unfilled -offset indent -input, unput -yy_push_state, yy_pop_state, yy_top_state -yy_scan_buffer, yy_scan_bytes, yy_scan_string -.Ed -.Pp -(though -.Fn yy_push_state -and friends won't appear anyway unless -.Dq %option stack -is being used). -.Sh PERFORMANCE CONSIDERATIONS -The main design goal of -.Nm -is that it generate high-performance scanners. -It has been optimized for dealing well with large sets of rules. -Aside from the effects on scanner speed of the table compression -.Fl C -options outlined above, -there are a number of options/actions which degrade performance. -These are, from most expensive to least: -.Bd -unfilled -offset indent -REJECT -%option yylineno -arbitrary trailing context - -pattern sets that require backing up -%array -%option interactive -%option always-interactive - -\&'^' beginning-of-line operator -yymore() -.Ed -.Pp -with the first three all being quite expensive -and the last two being quite cheap. -Note also that -.Fn unput -is implemented as a routine call that potentially does quite a bit of work, -while -.Fn yyless -is a quite-cheap macro; so if just putting back some excess text, -use -.Fn yyless . -.Pp -.Em REJECT -should be avoided at all costs when performance is important. -It is a particularly expensive option. -.Pp -Getting rid of backing up is messy and often may be an enormous -amount of work for a complicated scanner. -In principal, one begins by using the -.Fl b -flag to generate a -.Pa lex.backup -file. -For example, on the input -.Bd -literal -offset indent -%% -foo return TOK_KEYWORD; -foobar return TOK_KEYWORD; -.Ed -.Pp -the file looks like: -.Bd -literal -offset indent -State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \e001-n p-\e177 ] - -State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \e001-` b-\e177 ] - -State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \e001-q s-\e177 ] - -Compressed tables always back up. -.Ed -.Pp -The first few lines tell us that there's a scanner state in -which it can make a transition on an -.Sq o -but not on any other character, -and that in that state the currently scanned text does not match any rule. -The state occurs when trying to match the rules found -at lines 2 and 3 in the input file. -If the scanner is in that state and then reads something other than an -.Sq o , -it will have to back up to find a rule which is matched. -With a bit of headscratching one can see that this must be the -state it's in when it has seen -.Sq fo . -When this has happened, if anything other than another -.Sq o -is seen, the scanner will have to back up to simply match the -.Sq f -.Pq by the default rule . -.Pp -The comment regarding State #8 indicates there's a problem when -.Qq foob -has been scanned. -Indeed, on any character other than an -.Sq a , -the scanner will have to back up to accept -.Qq foo . -Similarly, the comment for State #9 concerns when -.Qq fooba -has been scanned and an -.Sq r -does not follow. -.Pp -The final comment reminds us that there's no point going to -all the trouble of removing backing up from the rules unless we're using -.Fl Cf -or -.Fl CF , -since there's no performance gain doing so with compressed scanners. -.Pp -The way to remove the backing up is to add -.Qq error -rules: -.Bd -literal -offset indent -%% -foo return TOK_KEYWORD; -foobar return TOK_KEYWORD; - -fooba | -foob | -fo { - /* false alarm, not really a keyword */ - return TOK_ID; -} -.Ed -.Pp -Eliminating backing up among a list of keywords can also be done using a -.Qq catch-all -rule: -.Bd -literal -offset indent -%% -foo return TOK_KEYWORD; -foobar return TOK_KEYWORD; - -[a-z]+ return TOK_ID; -.Ed -.Pp -This is usually the best solution when appropriate. -.Pp -Backing up messages tend to cascade. -With a complicated set of rules it's not uncommon to get hundreds of messages. -If one can decipher them, though, -it often only takes a dozen or so rules to eliminate the backing up -(though it's easy to make a mistake and have an error rule accidentally match -a valid token; a possible future -.Nm -feature will be to automatically add rules to eliminate backing up). -.Pp -It's important to keep in mind that the benefits of eliminating -backing up are gained only if -.Em every -instance of backing up is eliminated. -Leaving just one gains nothing. -.Pp -.Em Variable -trailing context -(where both the leading and trailing parts do not have a fixed length) -entails almost the same performance loss as -.Em REJECT -.Pq i.e., substantial . -So when possible a rule like: -.Bd -literal -offset indent -%% -mouse|rat/(cat|dog) run(); -.Ed -.Pp -is better written: -.Bd -literal -offset indent -%% -mouse/cat|dog run(); -rat/cat|dog run(); -.Ed -.Pp -or as -.Bd -literal -offset indent -%% -mouse|rat/cat run(); -mouse|rat/dog run(); -.Ed -.Pp -Note that here the special -.Sq |\& -action does not provide any savings, and can even make things worse (see -.Sx BUGS -below). -.Pp -Another area where the user can increase a scanner's performance -.Pq and one that's easier to implement -arises from the fact that the longer the tokens matched, -the faster the scanner will run. -This is because with long tokens the processing of most input -characters takes place in the -.Pq short -inner scanning loop, and does not often have to go through the additional work -of setting up the scanning environment (e.g., -.Fa yytext ) -for the action. -Recall the scanner for C comments: -.Bd -literal -offset indent -%x comment -%% -int line_num = 1; - -"/*" BEGIN(comment); - -[^*\en]* -"*"+[^*/\en]* -\en ++line_num; -"*"+"/" BEGIN(INITIAL); -.Ed -.Pp -This could be sped up by writing it as: -.Bd -literal -offset indent -%x comment -%% -int line_num = 1; - -"/*" BEGIN(comment); - -[^*\en]* -[^*\en]*\en ++line_num; -"*"+[^*/\en]* -"*"+[^*/\en]*\en ++line_num; -"*"+"/" BEGIN(INITIAL); -.Ed -.Pp -Now instead of each newline requiring the processing of another action, -recognizing the newlines is -.Qq distributed -over the other rules to keep the matched text as long as possible. -Note that adding rules does -.Em not -slow down the scanner! -The speed of the scanner is independent of the number of rules or -(modulo the considerations given at the beginning of this section) -how complicated the rules are with regard to operators such as -.Sq * -and -.Sq |\& . -.Pp -A final example in speeding up a scanner: -scan through a file containing identifiers and keywords, one per line -and with no other extraneous characters, and recognize all the keywords. -A natural first approach is: -.Bd -literal -offset indent -%% -asm | -auto | -break | -\&... etc ... -volatile | -while /* it's a keyword */ - -\&.|\en /* it's not a keyword */ -.Ed -.Pp -To eliminate the back-tracking, introduce a catch-all rule: -.Bd -literal -offset indent -%% -asm | -auto | -break | -\&... etc ... -volatile | -while /* it's a keyword */ - -[a-z]+ | -\&.|\en /* it's not a keyword */ -.Ed -.Pp -Now, if it's guaranteed that there's exactly one word per line, -then we can reduce the total number of matches by a half by -merging in the recognition of newlines with that of the other tokens: -.Bd -literal -offset indent -%% -asm\en | -auto\en | -break\en | -\&... etc ... -volatile\en | -while\en /* it's a keyword */ - -[a-z]+\en | -\&.|\en /* it's not a keyword */ -.Ed -.Pp -One has to be careful here, -as we have now reintroduced backing up into the scanner. -In particular, while we know that there will never be any characters -in the input stream other than letters or newlines, -.Nm -can't figure this out, and it will plan for possibly needing to back up -when it has scanned a token like -.Qq auto -and then the next character is something other than a newline or a letter. -Previously it would then just match the -.Qq auto -rule and be done, but now it has no -.Qq auto -rule, only an -.Qq auto\en -rule. -To eliminate the possibility of backing up, -we could either duplicate all rules but without final newlines or, -since we never expect to encounter such an input and therefore don't -how it's classified, we can introduce one more catch-all rule, -this one which doesn't include a newline: -.Bd -literal -offset indent -%% -asm\en | -auto\en | -break\en | -\&... etc ... -volatile\en | -while\en /* it's a keyword */ - -[a-z]+\en | -[a-z]+ | -\&.|\en /* it's not a keyword */ -.Ed -.Pp -Compiled with -.Fl Cf , -this is about as fast as one can get a -.Nm -scanner to go for this particular problem. -.Pp -A final note: -.Nm -is slow when matching NUL's, -particularly when a token contains multiple NUL's. -It's best to write rules which match short -amounts of text if it's anticipated that the text will often include NUL's. -.Pp -Another final note regarding performance: as mentioned above in the section -.Sx HOW THE INPUT IS MATCHED , -dynamically resizing -.Fa yytext -to accommodate huge tokens is a slow process because it presently requires that -the -.Pq huge -token be rescanned from the beginning. -Thus if performance is vital, it is better to attempt to match -.Qq large -quantities of text but not -.Qq huge -quantities, where the cutoff between the two is at about 8K characters/token. -.Sh GENERATING C++ SCANNERS -.Nm -provides two different ways to generate scanners for use with C++. -The first way is to simply compile a scanner generated by -.Nm -using a C++ compiler instead of a C compiler. -This should not generate any compilation errors -(please report any found to the email address given in the -.Sx AUTHORS -section below). -C++ code can then be used in rule actions instead of C code. -Note that the default input source for scanners remains -.Fa yyin , -and default echoing is still done to -.Fa yyout . -Both of these remain -.Fa FILE * -variables and not C++ streams. -.Pp -.Nm -can also be used to generate a C++ scanner class, using the -.Fl + -option (or, equivalently, -.Dq %option c++ ) , -which is automatically specified if the name of the flex executable ends in a -.Sq + , -such as -.Nm flex++ . -When using this option, -.Nm -defaults to generating the scanner to the file -.Pa lex.yy.cc -instead of -.Pa lex.yy.c . -The generated scanner includes the header file -.In g++/FlexLexer.h , -which defines the interface to two C++ classes. -.Pp -The first class, -.Em FlexLexer , -provides an abstract base class defining the general scanner class interface. -It provides the following member functions: -.Bl -tag -width Ds -.It const char* YYText() -Returns the text of the most recently matched token, the equivalent of -.Fa yytext . -.It int YYLeng() -Returns the length of the most recently matched token, the equivalent of -.Fa yyleng . -.It int lineno() const -Returns the current input line number -(see -.Dq %option yylineno ) , -or 1 if -.Dq %option yylineno -was not used. -.It void set_debug(int flag) -Sets the debugging flag for the scanner, equivalent to assigning to -.Fa yy_flex_debug -(see the -.Sx OPTIONS -section above). -Note that the scanner must be built using -.Dq %option debug -to include debugging information in it. -.It int debug() const -Returns the current setting of the debugging flag. -.El -.Pp -Also provided are member functions equivalent to -.Fn yy_switch_to_buffer , -.Fn yy_create_buffer -(though the first argument is an -.Fa std::istream* -object pointer and not a -.Fa FILE* ) , -.Fn yy_flush_buffer , -.Fn yy_delete_buffer , -and -.Fn yyrestart -(again, the first argument is an -.Fa std::istream* -object pointer). -.Pp -The second class defined in -.In g++/FlexLexer.h -is -.Fa yyFlexLexer , -which is derived from -.Fa FlexLexer . -It defines the following additional member functions: -.Bl -tag -width Ds -.It "yyFlexLexer(std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0)" -Constructs a -.Fa yyFlexLexer -object using the given streams for input and output. -If not specified, the streams default to -.Fa cin -and -.Fa cout , -respectively. -.It virtual int yylex() -Performs the same role as -.Fn yylex -does for ordinary flex scanners: it scans the input stream, consuming -tokens, until a rule's action returns a value. -If subclass -.Sq S -is derived from -.Fa yyFlexLexer , -in order to access the member functions and variables of -.Sq S -inside -.Fn yylex , -use -.Dq %option yyclass="S" -to inform -.Nm -that the -.Sq S -subclass will be used instead of -.Fa yyFlexLexer . -In this case, rather than generating -.Dq yyFlexLexer::yylex() , -.Nm -generates -.Dq S::yylex() -(and also generates a dummy -.Dq yyFlexLexer::yylex() -that calls -.Dq yyFlexLexer::LexerError() -if called). -.It "virtual void switch_streams(std::istream* new_in = 0, std::ostream* new_out = 0)" -Reassigns -.Fa yyin -to -.Fa new_in -.Pq if non-nil -and -.Fa yyout -to -.Fa new_out -.Pq ditto , -deleting the previous input buffer if -.Fa yyin -is reassigned. -.It int yylex(std::istream* new_in, std::ostream* new_out = 0) -First switches the input streams via -.Dq switch_streams(new_in, new_out) -and then returns the value of -.Fn yylex . -.El -.Pp -In addition, -.Fa yyFlexLexer -defines the following protected virtual functions which can be redefined -in derived classes to tailor the scanner: -.Bl -tag -width Ds -.It virtual int LexerInput(char* buf, int max_size) -Reads up to -.Fa max_size -characters into -.Fa buf -and returns the number of characters read. -To indicate end-of-input, return 0 characters. -Note that -.Qq interactive -scanners (see the -.Fl B -and -.Fl I -flags) define the macro -.Dv YY_INTERACTIVE . -If -.Fn LexerInput -has been redefined, and it's necessary to take different actions depending on -whether or not the scanner might be scanning an interactive input source, -it's possible to test for the presence of this name via -.Dq #ifdef . -.It virtual void LexerOutput(const char* buf, int size) -Writes out -.Fa size -characters from the buffer -.Fa buf , -which, while NUL-terminated, may also contain -.Qq internal -NUL's if the scanner's rules can match text with NUL's in them. -.It virtual void LexerError(const char* msg) -Reports a fatal error message. -The default version of this function writes the message to the stream -.Fa cerr -and exits. -.El -.Pp -Note that a -.Fa yyFlexLexer -object contains its entire scanning state. -Thus such objects can be used to create reentrant scanners. -Multiple instances of the same -.Fa yyFlexLexer -class can be instantiated, and multiple C++ scanner classes can be combined -in the same program using the -.Fl P -option discussed above. -.Pp -Finally, note that the -.Dq %array -feature is not available to C++ scanner classes; -.Dq %pointer -must be used -.Pq the default . -.Pp -Here is an example of a simple C++ scanner: -.Bd -literal -offset indent -// An example of using the flex C++ scanner class. - -%{ -#include -int mylineno = 0; -%} - -string \e"[^\en"]+\e" - -ws [ \et]+ - -alpha [A-Za-z] -dig [0-9] -name ({alpha}|{dig}|\e$)({alpha}|{dig}|[_.\e-/$])* -num1 [-+]?{dig}+\e.?([eE][-+]?{dig}+)? -num2 [-+]?{dig}*\e.{dig}+([eE][-+]?{dig}+)? -number {num1}|{num2} - -%% - -{ws} /* skip blanks and tabs */ - -"/*" { - int c; - - while ((c = yyinput()) != 0) { - if(c == '\en') - ++mylineno; - else if(c == '*') { - if ((c = yyinput()) == '/') - break; - else - unput(c); - } - } -} - -{number} cout << "number " << YYText() << '\en'; - -\en mylineno++; - -{name} cout << "name " << YYText() << '\en'; - -{string} cout << "string " << YYText() << '\en'; - -%% - -int main(int /* argc */, char** /* argv */) -{ - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; -} -.Ed -.Pp -To create multiple -.Pq different -lexer classes, use the -.Fl P -flag -(or the -.Dq prefix= -option) -to rename each -.Fa yyFlexLexer -to some other -.Fa xxFlexLexer . -.In g++/FlexLexer.h -can then be included in other sources once per lexer class, first renaming -.Fa yyFlexLexer -as follows: -.Bd -literal -offset indent -#undef yyFlexLexer -#define yyFlexLexer xxFlexLexer -#include - -#undef yyFlexLexer -#define yyFlexLexer zzFlexLexer -#include -.Ed -.Pp -If, for example, -.Dq %option prefix="xx" -is used for one scanner and -.Dq %option prefix="zz" -is used for the other. -.Pp -.Sy IMPORTANT : -the present form of the scanning class is experimental -and may change considerably between major releases. -.Sh INCOMPATIBILITIES WITH LEX AND POSIX -.Nm -is a rewrite of the -.At -.Nm lex -tool -(the two implementations do not share any code, though), -with some extensions and incompatibilities, both of which are of concern -to those who wish to write scanners acceptable to either implementation. -.Nm -is fully compliant with the -.Tn POSIX -.Nm lex -specification, except that when using -.Dq %pointer -.Pq the default , -a call to -.Fn unput -destroys the contents of -.Fa yytext , -which is counter to the -.Tn POSIX -specification. -.Pp -In this section we discuss all of the known areas of incompatibility between -.Nm , -.At -.Nm lex , -and the -.Tn POSIX -specification. -.Pp -.Nm flex Ns 's -.Fl l -option turns on maximum compatibility with the original -.At -.Nm lex -implementation, at the cost of a major loss in the generated scanner's -performance. -We note below which incompatibilities can be overcome using the -.Fl l -option. -.Pp -.Nm -is fully compatible with -.Nm lex -with the following exceptions: -.Bl -dash -.It -The undocumented -.Nm lex -scanner internal variable -.Fa yylineno -is not supported unless -.Fl l -or -.Dq %option yylineno -is used. -.Pp -.Fa yylineno -should be maintained on a per-buffer basis, rather than a per-scanner -.Pq single global variable -basis. -.Pp -.Fa yylineno -is not part of the -.Tn POSIX -specification. -.It -The -.Fn input -routine is not redefinable, though it may be called to read characters -following whatever has been matched by a rule. -If -.Fn input -encounters an end-of-file, the normal -.Fn yywrap -processing is done. -A -.Dq real -end-of-file is returned by -.Fn input -as -.Dv EOF . -.Pp -Input is instead controlled by defining the -.Dv YY_INPUT -macro. -.Pp -The -.Nm -restriction that -.Fn input -cannot be redefined is in accordance with the -.Tn POSIX -specification, which simply does not specify any way of controlling the -scanner's input other than by making an initial assignment to -.Fa yyin . -.It -The -.Fn unput -routine is not redefinable. -This restriction is in accordance with -.Tn POSIX . -.It -.Nm -scanners are not as reentrant as -.Nm lex -scanners. -In particular, if a scanner is interactive and -an interrupt handler long-jumps out of the scanner, -and the scanner is subsequently called again, -the following error message may be displayed: -.Pp -.D1 fatal flex scanner internal error--end of buffer missed -.Pp -To reenter the scanner, first use -.Pp -.Dl yyrestart(yyin); -.Pp -Note that this call will throw away any buffered input; -usually this isn't a problem with an interactive scanner. -.Pp -Also note that flex C++ scanner classes are reentrant, -so if using C++ is an option , they should be used instead. -See -.Sx GENERATING C++ SCANNERS -above for details. -.It -.Fn output -is not supported. -Output from the -.Em ECHO -macro is done to the file-pointer -.Fa yyout -.Pq default stdout . -.Pp -.Fn output -is not part of the -.Tn POSIX -specification. -.It -.Nm lex -does not support exclusive start conditions -.Pq %x , -though they are in the -.Tn POSIX -specification. -.It -When definitions are expanded, -.Nm -encloses them in parentheses. -With -.Nm lex , -the following: -.Bd -literal -offset indent -NAME [A-Z][A-Z0-9]* -%% -foo{NAME}? printf("Found it\en"); -%% -.Ed -.Pp -will not match the string -.Qq foo -because when the macro is expanded the rule is equivalent to -.Qq foo[A-Z][A-Z0-9]*? -and the precedence is such that the -.Sq ?\& -is associated with -.Qq [A-Z0-9]* . -With -.Nm , -the rule will be expanded to -.Qq foo([A-Z][A-Z0-9]*)? -and so the string -.Qq foo -will match. -.Pp -Note that if the definition begins with -.Sq ^ -or ends with -.Sq $ -then it is not expanded with parentheses, to allow these operators to appear in -definitions without losing their special meanings. -But the -.Sq Aq s , -.Sq / , -and -.Aq Aq EOF -operators cannot be used in a -.Nm -definition. -.Pp -Using -.Fl l -results in the -.Nm lex -behavior of no parentheses around the definition. -.Pp -The -.Tn POSIX -specification is that the definition be enclosed in parentheses. -.It -Some implementations of -.Nm lex -allow a rule's action to begin on a separate line, -if the rule's pattern has trailing whitespace: -.Bd -literal -offset indent -%% -foo|bar - { foobar_action(); } -.Ed -.Pp -.Nm -does not support this feature. -.It -The -.Nm lex -.Sq %r -.Pq generate a Ratfor scanner -option is not supported. -It is not part of the -.Tn POSIX -specification. -.It -After a call to -.Fn unput , -.Fa yytext -is undefined until the next token is matched, -unless the scanner was built using -.Dq %array . -This is not the case with -.Nm lex -or the -.Tn POSIX -specification. -The -.Fl l -option does away with this incompatibility. -.It -The precedence of the -.Sq {} -.Pq numeric range -operator is different. -.Nm lex -interprets -.Qq abc{1,3} -as match one, two, or three occurrences of -.Sq abc , -whereas -.Nm -interprets it as match -.Sq ab -followed by one, two, or three occurrences of -.Sq c . -The latter is in agreement with the -.Tn POSIX -specification. -.It -The precedence of the -.Sq ^ -operator is different. -.Nm lex -interprets -.Qq ^foo|bar -as match either -.Sq foo -at the beginning of a line, or -.Sq bar -anywhere, whereas -.Nm -interprets it as match either -.Sq foo -or -.Sq bar -if they come at the beginning of a line. -The latter is in agreement with the -.Tn POSIX -specification. -.It -The special table-size declarations such as -.Sq %a -supported by -.Nm lex -are not required by -.Nm -scanners; -.Nm -ignores them. -.It -The name -.Dv FLEX_SCANNER -is #define'd so scanners may be written for use with either -.Nm -or -.Nm lex . -Scanners also include -.Dv YY_FLEX_MAJOR_VERSION -and -.Dv YY_FLEX_MINOR_VERSION -indicating which version of -.Nm -generated the scanner -(for example, for the 2.5 release, these defines would be 2 and 5, -respectively). -.El -.Pp -The following -.Nm -features are not included in -.Nm lex -or the -.Tn POSIX -specification: -.Bd -unfilled -offset indent -C++ scanners -%option -start condition scopes -start condition stacks -interactive/non-interactive scanners -yy_scan_string() and friends -yyterminate() -yy_set_interactive() -yy_set_bol() -YY_AT_BOL() -<> -<*> -YY_DECL -YY_START -YY_USER_ACTION -YY_USER_INIT -#line directives -%{}'s around actions -multiple actions on a line -.Ed -.Pp -plus almost all of the -.Nm -flags. -The last feature in the list refers to the fact that with -.Nm -multiple actions can be placed on the same line, -separated with semi-colons, while with -.Nm lex , -the following -.Pp -.Dl foo handle_foo(); ++num_foos_seen; -.Pp -is -.Pq rather surprisingly -truncated to -.Pp -.Dl foo handle_foo(); -.Pp -.Nm -does not truncate the action. -Actions that are not enclosed in braces -are simply terminated at the end of the line. -.Sh FILES -.Bl -tag -width "" -.It Pa flex.skl -Skeleton scanner. -This file is only used when building flex, not when -.Nm -executes. -.It Pa lex.backup -Backing-up information for the -.Fl b -flag (called -.Pa lex.bck -on some systems). -.It Pa lex.yy.c -Generated scanner -(called -.Pa lexyy.c -on some systems). -.It Pa lex.yy.cc -Generated C++ scanner class, when using -.Fl + . -.It In g++/FlexLexer.h -Header file defining the C++ scanner base class, -.Fa FlexLexer , -and its derived class, -.Fa yyFlexLexer . -.It Pa /usr/lib/libl.* -.Nm -libraries. -The -.Pa /usr/lib/libfl.*\& -libraries are links to these. -Scanners must be linked using either -.Fl \&ll -or -.Fl lfl . -.El -.Sh EXIT STATUS -.Ex -std flex -.Sh DIAGNOSTICS -.Bl -diag -.It warning, rule cannot be matched -Indicates that the given rule cannot be matched because it follows other rules -that will always match the same text as it. -For example, in the following -.Dq foo -cannot be matched because it comes after an identifier -.Qq catch-all -rule: -.Bd -literal -offset indent -[a-z]+ got_identifier(); -foo got_foo(); -.Ed -.Pp -Using -.Em REJECT -in a scanner suppresses this warning. -.It "warning, \-s option given but default rule can be matched" -Means that it is possible -.Pq perhaps only in a particular start condition -that the default rule -.Pq match any single character -is the only one that will match a particular input. -Since -.Fl s -was given, presumably this is not intended. -.It reject_used_but_not_detected undefined -.It yymore_used_but_not_detected undefined -These errors can occur at compile time. -They indicate that the scanner uses -.Em REJECT -or -.Fn yymore -but that -.Nm -failed to notice the fact, meaning that -.Nm -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow they snuck in -.Pq via an #include file, for example . -Use -.Dq %option reject -or -.Dq %option yymore -to indicate to -.Nm -that these features are really needed. -.It flex scanner jammed -A scanner compiled with -.Fl s -has encountered an input string which wasn't matched by any of its rules. -This error can also occur due to internal problems. -.It token too large, exceeds YYLMAX -The scanner uses -.Dq %array -and one of its rules matched a string longer than the -.Dv YYLMAX -constant -.Pq 8K bytes by default . -The value can be increased by #define'ing -.Dv YYLMAX -in the definitions section of -.Nm -input. -.It "scanner requires \-8 flag to use the character 'x'" -The scanner specification includes recognizing the 8-bit character -.Sq x -and the -.Fl 8 -flag was not specified, and defaulted to 7-bit because the -.Fl Cf -or -.Fl CF -table compression options were used. -See the discussion of the -.Fl 7 -flag for details. -.It flex scanner push-back overflow -unput() was used to push back so much text that the scanner's buffer -could not hold both the pushed-back text and the current token in -.Fa yytext . -Ideally the scanner should dynamically resize the buffer in this case, -but at present it does not. -.It "input buffer overflow, can't enlarge buffer because scanner uses REJECT" -The scanner was working on matching an extremely large token and needed -to expand the input buffer. -This doesn't work with scanners that use -.Em REJECT . -.It "fatal flex scanner internal error--end of buffer missed" -This can occur in an scanner which is reentered after a long-jump -has jumped out -.Pq or over -the scanner's activation frame. -Before reentering the scanner, use: -.Pp -.Dl yyrestart(yyin); -.Pp -or, as noted above, switch to using the C++ scanner class. -.It "too many start conditions in <> construct!" -More start conditions than exist were listed in a <> construct -(so at least one of them must have been listed twice). -.El -.Sh SEE ALSO -.Xr awk 1 , -.Xr sed 1 , -.Xr yacc 1 -.Rs -.%A John Levine -.%A Tony Mason -.%A Doug Brown -.%B Lex & Yacc -.%I O'Reilly and Associates -.%N 2nd edition -.Re -.Rs -.%A Alfred Aho -.%A Ravi Sethi -.%A Jeffrey Ullman -.%B Compilers: Principles, Techniques and Tools -.%I Addison-Wesley -.%D 1986 -.%O "Describes the pattern-matching techniques used by flex (deterministic finite automata)" -.Re -.Sh STANDARDS -The -.Nm lex -utility is compliant with the -.St -p1003.1-2008 -specification, -though its presence is optional. -.Pp -The flags -.Op Fl 78BbCdFfhIiLloPpSsTVw+? , -.Op Fl -help , -and -.Op Fl -version -are extensions to that specification. -.Pp -See also the -.Sx INCOMPATIBILITIES WITH LEX AND POSIX -section, above. -.Sh AUTHORS -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. -Original version by Jef Poskanzer. -The fast table representation is a partial implementation of a design done by -Van Jacobson. -The implementation was done by Kevin Gong and Vern Paxson. -.Pp -Thanks to the many -.Nm -beta-testers, feedbackers, and contributors, especially Francois Pinard, -Casey Leedom, -Robert Abramovitz, -Stan Adermann, Terry Allen, David Barker-Plummer, John Basrai, -Neal Becker, Nelson H.F. Beebe, -.Mt benson@odi.com , -Karl Berry, Peter A. Bigot, Simon Blanchard, -Keith Bostic, Frederic Brehm, Ian Brockbank, Kin Cho, Nick Christopher, -Brian Clapper, J.T. Conklin, -Jason Coughlin, Bill Cox, Nick Cropper, Dave Curtis, Scott David -Daniels, Chris G. Demetriou, Theo de Raadt, -Mike Donahue, Chuck Doucette, Tom Epperly, Leo Eskin, -Chris Faylor, Chris Flatters, Jon Forrest, Jeffrey Friedl, -Joe Gayda, Kaveh R. Ghazi, Wolfgang Glunz, -Eric Goldman, Christopher M. Gould, Ulrich Grepel, Peer Griebel, -Jan Hajic, Charles Hemphill, NORO Hideo, -Jarkko Hietaniemi, Scott Hofmann, -Jeff Honig, Dana Hudes, Eric Hughes, John Interrante, -Ceriel Jacobs, Michal Jaegermann, Sakari Jalovaara, Jeffrey R. Jones, -Henry Juengst, Klaus Kaempf, Jonathan I. Kamens, Terrence O Kane, -Amir Katz, -.Mt ken@ken.hilco.com , -Kevin B. Kenny, -Steve Kirsch, Winfried Koenig, Marq Kole, Ronald Lamprecht, -Greg Lee, Rohan Lenard, Craig Leres, John Levine, Steve Liddle, -David Loffredo, Mike Long, -Mohamed el Lozy, Brian Madsen, Malte, Joe Marshall, -Bengt Martensson, Chris Metcalf, -Luke Mewburn, Jim Meyering, R. Alexander Milowski, Erik Naggum, -G.T. Nicol, Landon Noll, James Nordby, Marc Nozell, -Richard Ohnemus, Karsten Pahnke, -Sven Panne, Roland Pesch, Walter Pelissero, Gaumond Pierre, -Esmond Pitt, Jef Poskanzer, Joe Rahmeh, Jarmo Raiha, -Frederic Raimbault, Pat Rankin, Rick Richardson, -Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, Alberto Santini, -Andreas Scherer, Darrell Schiebel, Raf Schietekat, -Doug Schmidt, Philippe Schnoebelen, Andreas Schwab, -Larry Schwimmer, Alex Siegel, Eckehard Stolz, Jan-Erik Strvmquist, -Mike Stump, Paul Stuart, Dave Tallman, Ian Lance Taylor, -Chris Thewalt, Richard M. Timoney, Jodi Tsai, -Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams, -Ken Yap, Ron Zellar, Nathan Zelle, David Zuhn, -and those whose names have slipped my marginal mail-archiving skills -but whose contributions are appreciated all the -same. -.Pp -Thanks to Keith Bostic, Jon Forrest, Noah Friedman, -John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T. -Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various -distribution headaches. -.Pp -Thanks to Esmond Pitt and Earle Horton for 8-bit character support; -to Benson Margulies and Fred Burke for C++ support; -to Kent Williams and Tom Epperly for C++ class support; -to Ove Ewerlid for support of NUL's; -and to Eric Hughes for support of multiple buffers. -.Pp -This work was primarily done when I was with the Real Time Systems Group -at the Lawrence Berkeley Laboratory in Berkeley, CA. -Many thanks to all there for the support I received. -.Pp -Send comments to -.Aq Mt vern@ee.lbl.gov . -.Sh BUGS -Some trailing context patterns cannot be properly matched and generate -warning messages -.Pq "dangerous trailing context" . -These are patterns where the ending of the first part of the rule -matches the beginning of the second part, such as -.Qq zx*/xy* , -where the -.Sq x* -matches the -.Sq x -at the beginning of the trailing context. -(Note that the POSIX draft states that the text matched by such patterns -is undefined.) -.Pp -For some trailing context rules, parts which are actually fixed-length are -not recognized as such, leading to the above mentioned performance loss. -In particular, parts using -.Sq |\& -or -.Sq {n} -(such as -.Qq foo{3} ) -are always considered variable-length. -.Pp -Combining trailing context with the special -.Sq |\& -action can result in fixed trailing context being turned into -the more expensive variable trailing context. -For example, in the following: -.Bd -literal -offset indent -%% -abc | -xyz/def -.Ed -.Pp -Use of -.Fn unput -invalidates yytext and yyleng, unless the -.Dq %array -directive -or the -.Fl l -option has been used. -.Pp -Pattern-matching of NUL's is substantially slower than matching other -characters. -.Pp -Dynamic resizing of the input buffer is slow, as it entails rescanning -all the text matched so far by the current -.Pq generally huge -token. -.Pp -Due to both buffering of input and read-ahead, -it is not possible to intermix calls to -.In stdio.h -routines, such as, for example, -.Fn getchar , -with -.Nm -rules and expect it to work. -Call -.Fn input -instead. -.Pp -The total table entries listed by the -.Fl v -flag excludes the number of table entries needed to determine -what rule has been matched. -The number of entries is equal to the number of DFA states -if the scanner does not use -.Em REJECT , -and somewhat greater than the number of states if it does. -.Pp -.Em REJECT -cannot be used with the -.Fl f -or -.Fl F -options. -.Pp -The -.Nm -internal algorithms need documentation. diff --git a/third_party/lex/flex.skl b/third_party/lex/flex.skl deleted file mode 100644 index ca36c8fe..00000000 --- a/third_party/lex/flex.skl +++ /dev/null @@ -1,3451 +0,0 @@ -/* $OpenBSD: flex.skl,v 1.16 2017/05/02 19:16:19 millert Exp $ */ - -%# -*-C-*- vi: set ft=c: -%# This file is processed in several stages. -%# Here are the stages, as best as I can describe: -%# -%# 1. flex.skl is processed through GNU m4 during the -%# pre-compilation stage of flex. Only macros starting -%# with `m4preproc_' are processed, and quoting is normal. -%# -%# 2. The preprocessed skeleton is translated verbatim into a -%# C array, saved as "skel.c" and compiled into the flex binary. -%# -%# 3. At runtime, the skeleton is generated and filtered (again) -%# through m4. Macros beginning with `m4_' will be processed. -%# The quoting is "[[" and "]]" so we don't interfere with -%# user code. -%# -%# All generate macros for the m4 stage contain the text "m4" or "M4" -%# in them. This is to distinguish them from CPP macros. -%# The exception to this rule is YY_G, which is an m4 macro, -%# but it needs to be remain short because it is used everywhere. -%# -/* A lexical scanner generated by flex */ - -%# Macros for preproc stage. -m4preproc_changecom - -%# Macros for runtime processing stage. -m4_changecom -m4_changequote -m4_changequote([[, ]]) - -%# -%# Lines in this skeleton starting with a "%" character are "control lines" -%# and affect the generation of the scanner. The possible control codes are -%# listed and processed in misc.c. -%# -%# %# - A comment. The current line is omitted from the generated scanner. -%# %if-c++-only - The following lines are printed for C++ scanners ONLY. -%# %if-c-only - The following lines are NOT printed for C++ scanners. -%# %if-c-or-c++ - The following lines are printed in BOTH C and C++ scanners. -%# %if-reentrant - Print for reentrant scanners.(push) -%# %if-not-reentrant - Print for non-reentrant scanners. (push) -%# %if-bison-bridge - Print for bison-bridge. (push) -%# %if-not-bison-bridge - Print for non-bison-bridge. (push) -%# %endif - pop from the previous if code. -%# %% - A stop-point, where code is inserted by flex. -%# Each stop-point is numbered here and also in the code generator. -%# (See gen.c, etc. for details.) -%# %not-for-header - Begin code that should NOT appear in a ".h" file. -%# %ok-for-header - %c and %e are used for building a header file. -%# %if-tables-serialization -%# -%# All control-lines EXCEPT comment lines ("%#") will be inserted into -%# the generated scanner as a C-style comment. This is to aid those who -%# edit the skeleton. -%# - -%not-for-header -%if-c-only -%if-not-reentrant -m4_ifelse(M4_YY_PREFIX,yy,, -#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]] -#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]] -#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]] -#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]] -#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]] -#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]] -#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]] -#define yyin M4_YY_PREFIX[[in]] -#define yyleng M4_YY_PREFIX[[leng]] -#define yylex M4_YY_PREFIX[[lex]] -#define yylineno M4_YY_PREFIX[[lineno]] -#define yyout M4_YY_PREFIX[[out]] -#define yyrestart M4_YY_PREFIX[[restart]] -#define yytext M4_YY_PREFIX[[text]] -#define yywrap M4_YY_PREFIX[[wrap]] -#define yyalloc M4_YY_PREFIX[[alloc]] -#define yyrealloc M4_YY_PREFIX[[realloc]] -#define yyfree M4_YY_PREFIX[[free]] -) -%endif -%endif -%ok-for-header - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION -#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION -#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -%# Some negated symbols -m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) -m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) - -%# This is the m4 way to say "(stack_used || is_reentrant) -m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) -m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) - -%# Prefixes. -%# The complexity here is necessary so that m4 preserves -%# the argument lists to each C function. - - -m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]]) - -m4preproc_define(`M4_GEN_PREFIX', - ``m4_define(yy[[$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'') - -%if-c++-only - /* The c++ scanner is a mess. The FlexLexer.h header file relies on the - * following macro. This is required in order to pass the c++-multiple-scanners - * test in the regression suite. We get reports that it breaks inheritance. - * We will address this in a future release of flex, or omit the C++ scanner - * altogether. - */ - #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]] -%endif - -%if-c-only - M4_GEN_PREFIX(`_create_buffer') - M4_GEN_PREFIX(`_delete_buffer') - M4_GEN_PREFIX(`_scan_buffer') - M4_GEN_PREFIX(`_scan_string') - M4_GEN_PREFIX(`_scan_bytes') - M4_GEN_PREFIX(`_init_buffer') - M4_GEN_PREFIX(`_flush_buffer') - M4_GEN_PREFIX(`_load_buffer_state') - M4_GEN_PREFIX(`_switch_to_buffer') - M4_GEN_PREFIX(`push_buffer_state') - M4_GEN_PREFIX(`pop_buffer_state') - M4_GEN_PREFIX(`ensure_buffer_stack') - M4_GEN_PREFIX(`lex') - M4_GEN_PREFIX(`restart') - M4_GEN_PREFIX(`lex_init') - M4_GEN_PREFIX(`lex_init_extra') - M4_GEN_PREFIX(`lex_destroy') - M4_GEN_PREFIX(`get_debug') - M4_GEN_PREFIX(`set_debug') - M4_GEN_PREFIX(`get_extra') - M4_GEN_PREFIX(`set_extra') - M4_GEN_PREFIX(`get_in') - M4_GEN_PREFIX(`set_in') - M4_GEN_PREFIX(`get_out') - M4_GEN_PREFIX(`set_out') - M4_GEN_PREFIX(`get_leng') - M4_GEN_PREFIX(`get_text') - M4_GEN_PREFIX(`get_lineno') - M4_GEN_PREFIX(`set_lineno') - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - M4_GEN_PREFIX(`get_column') - M4_GEN_PREFIX(`set_column') - ]]) - M4_GEN_PREFIX(`wrap') -%endif - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - M4_GEN_PREFIX(`get_lval') - M4_GEN_PREFIX(`set_lval') -]]) - -m4_ifdef( [[]], -[[ - M4_GEN_PREFIX(`get_lloc') - M4_GEN_PREFIX(`set_lloc') -]]) - - - M4_GEN_PREFIX(`alloc') - M4_GEN_PREFIX(`realloc') - M4_GEN_PREFIX(`free') - -%if-c-only -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - M4_GEN_PREFIX(`text') - M4_GEN_PREFIX(`leng') - M4_GEN_PREFIX(`in') - M4_GEN_PREFIX(`out') - M4_GEN_PREFIX(`_flex_debug') - M4_GEN_PREFIX(`lineno') -]]) -%endif - - -m4_ifdef( [[M4_YY_TABLES_EXTERNAL]], -[[ - M4_GEN_PREFIX(`tables_fload') - M4_GEN_PREFIX(`tables_destroy') - M4_GEN_PREFIX(`TABLES_NAME') -]]) - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -%if-c-only -#include -#include -#include -#include -%endif - -%if-tables-serialization -#include -#include -%endif -/* end standard C headers. */ - -%if-c-or-c++ -m4preproc_include(`flexint.h') -%endif - -%if-c++-only -/* begin standard C++ headers. */ -#include -#include -#include -#include -#include -/* end standard C++ headers. */ -%endif - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -%# For compilers that can not handle prototypes. -%# e.g., -%# The function prototype -%# int foo(int x, char* y); -%# -%# ...should be written as -%# int foo M4_YY_PARAMS(int x, char* y); -%# -%# ...which could possibly generate -%# int foo (); -%# -m4_ifdef( [[M4_YY_NO_ANSI_FUNC_PROTOS]], -[[ - m4_define( [[M4_YY_PARAMS]], [[()]]) -]], -[[ - m4_define( [[M4_YY_PARAMS]], [[($*)]]) -]]) - -%not-for-header -/* Returned upon end-of-file. */ -#define YY_NULL 0 -%ok-for-header - -%not-for-header -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) -%ok-for-header - - - -%if-reentrant - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -%# Declare yyguts variable -m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]]) -%# Perform a noop access on yyguts to prevent unused variable complains -m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[(void)yyg]]) -%# For use wherever a Global is accessed or assigned. -m4_define( [[YY_G]], [[yyg->$1]]) - -%# For use in function prototypes to append the additional argument. -m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]]) -m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]]) - -%# For use in function definitions to append the additional argument. -m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], -[[ - m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscanner]]) - m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscanner]]) -]], -[[ - m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]]) - m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]]) -]]) -m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]]) - -%# For use in function calls to pass the additional argument. -m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]]) -m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]]) - -%# For use in function documentation to adjust for additional argument. -m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin YY_G(yyin_r) -#define yyout YY_G(yyout_r) -#define yyextra YY_G(yyextra_r) -#define yyleng YY_G(yyleng_r) -#define yytext YY_G(yytext_r) -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug YY_G(yy_flex_debug_r) - -m4_define( [[M4_YY_INCR_LINENO]], -[[ - do{ yylineno++; - yycolumn=0; - }while(0) -]]) - -%endif - - - -%if-not-reentrant - -m4_define( [[M4_YY_INCR_LINENO]], -[[ - yylineno++; -]]) - -%# Define these macros to be no-ops. -m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]]) -m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[m4_dnl]]) -m4_define( [[YY_G]], [[($1)]]) -m4_define( [[M4_YY_PROTO_LAST_ARG]]) -m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]]) -m4_define( [[M4_YY_DEF_LAST_ARG]]) - -m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], -[[ - m4_define( [[M4_YY_DEF_ONLY_ARG]]) -]], -[[ - m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]]) -]]) -m4_define([[M4_YY_DECL_LAST_ARG]]) -m4_define([[M4_YY_CALL_LAST_ARG]]) -m4_define([[M4_YY_CALL_ONLY_ARG]]) -m4_define( [[M4_YY_DOC_PARAM]], [[]]) - -%endif - - -m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], -[[ -%# For compilers that need traditional function definitions. -%# e.g., -%# The function prototype taking 2 arguments -%# int foo (int x, char* y) -%# -%# ...should be written as -%# int foo YYFARGS2(int,x, char*,y) -%# -%# ...which could possibly generate -%# int foo (x,y,yyscanner) -%# int x; -%# char * y; -%# yyscan_t yyscanner; -%# -%# Generate traditional function defs - m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG) [[\]] - M4_YY_DECL_LAST_ARG]]) - m4_define( [[YYFARGS1]], [[($2 M4_YY_DEF_LAST_ARG) [[\]] - $1 $2; [[\]] - M4_YY_DECL_LAST_ARG]]) - m4_define( [[YYFARGS2]], [[($2,$4 M4_YY_DEF_LAST_ARG) [[\]] - $1 $2; [[\]] - $3 $4; [[\]] - M4_YY_DECL_LAST_ARG]]) - m4_define( [[YYFARGS3]], [[($2,$4,$6 M4_YY_DEF_LAST_ARG) [[\]] - $1 $2; [[\]] - $3 $4; [[\]] - $5 $6; [[\]] - M4_YY_DECL_LAST_ARG]]) -]], -[[ -%# Generate C99 function defs. - m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG)]]) - m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]]) - m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]]) - m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN YY_G(yy_start) = 1 + 2 * -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((YY_G(yy_start) - 1) / 2) -#define YYSTATE YY_START -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG ) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define YY_END_OF_BUFFER_CHAR 0 -]]) - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) -]]) - - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -%if-not-reentrant -extern yy_size_t yyleng; -%endif - -%if-c-only -%if-not-reentrant -extern FILE *yyin, *yyout; -%endif -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ - m4_ifdef( [[M4_YY_USE_LINENO]], - [[ - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl )\ - if ( yytext[yyl] == '\n' )\ - --yylineno;\ - }while(0) - #define YY_LINENO_REWIND_TO(dst) \ - do {\ - const char *p;\ - for ( p = yy_cp-1; p >= (dst); --p)\ - if ( *p == '\n' )\ - --yylineno;\ - }while(0) - ]], - [[ - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - ]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = YY_G(yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) -]]) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { -%if-c-only - FILE *yy_input_file; -%endif - -%if-c++-only - std::istream* yy_input_file; -%endif - - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 -]]) - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -%if-c-only Standard (non-C++) definition -%not-for-header -%if-not-reentrant - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ -%endif -%ok-for-header -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \ - ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ - : NULL) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] -]]) - -%if-c-only Standard (non-C++) definition - -%if-not-reentrant -%not-for-header -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; -%ok-for-header -%endif - -void yyrestart M4_YY_PARAMS( FILE *input_file M4_YY_PROTO_LAST_ARG ); -void yy_switch_to_buffer M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_create_buffer M4_YY_PARAMS( FILE *file, int size M4_YY_PROTO_LAST_ARG ); -void yy_delete_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); -void yy_flush_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); -void yypush_buffer_state M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); -void yypop_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static void yyensure_buffer_stack M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -static void yy_load_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -static void yy_init_buffer M4_YY_PARAMS( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG) -]]) - -YY_BUFFER_STATE yy_scan_buffer M4_YY_PARAMS( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_string M4_YY_PARAMS( yyconst char *yy_str M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_bytes M4_YY_PARAMS( yyconst char *bytes, yy_size_t len M4_YY_PROTO_LAST_ARG ); - -%endif - -void *yyalloc M4_YY_PARAMS( yy_size_t M4_YY_PROTO_LAST_ARG ); -void *yyrealloc M4_YY_PARAMS( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); -void yyfree M4_YY_PARAMS( void * M4_YY_PROTO_LAST_ARG ); - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define yy_new_buffer yy_create_buffer -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -]]) - -%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -%% [1.5] DFA -]]) - -%if-c-only Standard (non-C++) definition - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static yy_state_type yy_get_previous_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -static yy_state_type yy_try_NUL_trans M4_YY_PARAMS( yy_state_type current_state M4_YY_PROTO_LAST_ARG); -static int yy_get_next_buffer M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -static void yy_fatal_error M4_YY_PARAMS( yyconst char msg[] M4_YY_PROTO_LAST_ARG ); -]]) - -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - YY_G(yytext_ptr) = yy_bp; \ -%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ - YY_G(yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ -%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ - YY_G(yy_c_buf_p) = yy_cp; -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -%% [4.0] data tables for the DFA and the user's section 1 definitions go here -]]) - -m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) -M4_YY_SC_DEFS -m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) - -m4_ifdef( [[M4_YY_NO_UNISTD_H]],, -[[ -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -%if-c-only -#include -%endif -%if-c++-only -#include -%endif -#endif -]]) - -m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], -[[ -#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS -]], -[[ -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif -]] -) - -%if-c-only Reentrant structure and macros (non-C++). -%if-reentrant - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - yy_size_t yy_n_chars; - yy_size_t yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; - int yy_lp; - - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ - int yy_looking_for_trail_begin; - int yy_full_lp; - int *yy_full_state; -]]) - -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], -[[ - char yytext_r[YYLMAX]; - char *yytext_ptr; - int yy_more_offset; - int yy_prev_more_offset; -]], -[[ - char *yytext_r; - int yy_more_flag; - int yy_more_len; -]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - YYSTYPE * yylval_r; -]]) - -m4_ifdef( [[]], -[[ - YYLTYPE * yylloc_r; -]]) - - }; /* end struct yyguts_t */ -]]) - - -%if-c-only -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static int yy_init_globals M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) -%endif - -%if-reentrant - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ - m4_ifdef( [[M4_YY_BISON_LVAL]], - [[ - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval YY_G(yylval_r) - ]]) - - m4_ifdef( [[]], - [[ - # define yylloc YY_G(yylloc_r) - ]]) -]]) - -int yylex_init M4_YY_PARAMS(yyscan_t* scanner); - -int yylex_init_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -%endif - -%endif End reentrant structures and macros. - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -m4_ifdef( [[M4_YY_NO_DESTROY]],, -[[ -int yylex_destroy M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, -[[ -int yyget_debug M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, -[[ -void yyset_debug M4_YY_PARAMS( int debug_flag M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, -[[ -YY_EXTRA_TYPE yyget_extra M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, -[[ -void yyset_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_IN]],, -[[ -FILE *yyget_in M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_IN]],, -[[ -void yyset_in M4_YY_PARAMS( FILE * in_str M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_OUT]],, -[[ -FILE *yyget_out M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_OUT]],, -[[ -void yyset_out M4_YY_PARAMS( FILE * out_str M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_LENG]],, -[[ -yy_size_t yyget_leng M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, -[[ -char *yyget_text M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, -[[ -int yyget_lineno M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, -[[ -void yyset_lineno M4_YY_PARAMS( int line_number M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, -[[ -int yyget_column M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, -[[ -void yyset_column M4_YY_PARAMS( int column_no M4_YY_PROTO_LAST_ARG ); -]]) -]]) - -%if-bison-bridge -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE * yyget_lval M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -]]) - -void yyset_lval M4_YY_PARAMS( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG ); - -m4_ifdef( [[]], -[[ - m4_ifdef( [[M4_YY_NO_GET_LLOC]],, - [[ - YYLTYPE *yyget_lloc M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); - ]]) - - m4_ifdef( [[M4_YY_NO_SET_LLOC]],, - [[ - void yyset_lloc M4_YY_PARAMS( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); - ]]) -]]) -%endif - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -#else -extern int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -#endif -#endif - -%not-for-header - m4_ifdef( [[M4_YY_NO_UNPUT]],, - [[ - static void yyunput M4_YY_PARAMS( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); - ]]) -%ok-for-header -%endif - -#ifndef yytext_ptr -static void yy_flex_strncpy M4_YY_PARAMS( char *, yyconst char *, int M4_YY_PROTO_LAST_ARG); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen M4_YY_PARAMS( yyconst char * M4_YY_PROTO_LAST_ARG); -#endif - -#ifndef YY_NO_INPUT -%if-c-only Standard (non-C++) definition -%not-for-header -#ifdef __cplusplus -static int yyinput M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -#else -static int input M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); -#endif -%ok-for-header -%endif -#endif - - -%if-c-only -%# TODO: This is messy. -m4_ifdef( [[M4_YY_STACK_USED]], -[[ - -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - m4_ifdef( [[M4_YY_NOT_IN_HEADER]], - [[ - static int yy_start_stack_ptr = 0; - static int yy_start_stack_depth = 0; - static int *yy_start_stack = NULL; - ]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ - m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, - [[ - static void yy_push_state M4_YY_PARAMS( int new_state M4_YY_PROTO_LAST_ARG); - ]]) - m4_ifdef( [[M4_YY_NO_POP_STATE]],, - [[ - static void yy_pop_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); - ]]) - m4_ifdef( [[M4_YY_NO_TOP_STATE]],, - [[ - static int yy_top_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); - ]]) -]]) - -]], -[[ -m4_define( [[M4_YY_NO_PUSH_STATE]]) -m4_define( [[M4_YY_NO_POP_STATE]]) -m4_define( [[M4_YY_NO_TOP_STATE]]) -]]) -%endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -%if-c-only Standard (non-C++) definition -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -%endif -%if-c++-only C++ definition -#define ECHO LexerOutput( yytext, yyleng ) -%endif -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ -\ -%if-c++-only C++ definition \ - if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -%endif - -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif -]]) - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -%if-c-only -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) -%endif -%if-c++-only -#define YY_FATAL_ERROR(msg) LexerError( msg ) -%endif -#endif -]]) - -%if-tables-serialization structures and prototypes -m4preproc_include(`tables_shared.h') - -/* Load the DFA tables from the given stream. */ -int yytables_fload M4_YY_PARAMS(FILE * fp M4_YY_PROTO_LAST_ARG); - -/* Unload the tables from memory. */ -int yytables_destroy M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG); -%not-for-header - -/** Describes a mapping from a serialized table id to its deserialized state in - * this scanner. This is the bridge between our "generic" deserialization code - * and the specifics of this scanner. - */ -struct yytbl_dmap { - enum yytbl_id dm_id;/**< table identifier */ - void **dm_arr; /**< address of pointer to store the deserialized table. */ - size_t dm_sz; /**< local sizeof() each element in table. */ -}; - -/** A {0,0,0}-terminated list of structs, forming the map */ -static struct yytbl_dmap yydmap[] = -{ -%tables-yydmap generated elements - {0,0,0} -}; - -/** A tables-reader object to maintain some state in the read. */ -struct yytbl_reader { - FILE * fp; /**< input stream */ - flex_uint32_t bread; /**< bytes read since beginning of current tableset */ -}; - -%endif -/* end tables serialization structures and prototypes */ - -%ok-for-header - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 -%if-c-only Standard (non-C++) definition - - -m4_define( [[M4_YY_LEX_PROTO]], [[M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG)]]) -m4_define( [[M4_YY_LEX_DECLARATION]], [[YYFARGS0(void)]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - m4_dnl The bison pure parser is used. Redefine yylex to - m4_dnl accept the lval parameter. - - m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[M4_YY_PARAMS(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[YYFARGS1(YYSTYPE *,yylval_param)]]) -]]) - -m4_ifdef( [[]], -[[ - m4_dnl Locations are used. yylex should also accept the ylloc parameter. - - m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[M4_YY_PARAMS(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]]) -]]) - -extern int yylex M4_YY_LEX_PROTO; - -#define YY_DECL int yylex M4_YY_LEX_DECLARATION -%endif -%if-c++-only C++ definition -#define YY_DECL int yyFlexLexer::yylex() -%endif -#endif /* !YY_DECL */ - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -%% [6.0] YY_RULE_SETUP definition goes here -]]) - -%not-for-header -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - M4_YY_DECL_GUTS_VAR(); - -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - m4_ifdef( [[M4_YY_BISON_LVAL]], - [[ - YYSTYPE * yylval; - ]]) - m4_ifdef( [[]], - [[ - YYLTYPE * yylloc; - ]]) -]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - yylval = yylval_param; -]]) - -m4_ifdef( [[]], -[[ - yylloc = yylloc_param; -]]) - - if ( !YY_G(yy_init) ) - { - YY_G(yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! YY_G(yy_state_buf) ) - YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_state_buf) ) - YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); -]]) - - if ( ! YY_G(yy_start) ) - YY_G(yy_start) = 1; /* first start state */ - - if ( ! yyin ) -%if-c-only - yyin = stdin; -%endif -%if-c++-only - yyin = & std::cin; -%endif - - if ( ! yyout ) -%if-c-only - yyout = stdout; -%endif -%if-c++-only - yyout = & std::cout; -%endif - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); - } - - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - } - - { -%% [7.0] user's declarations go here - - while ( 1 ) /* loops until end-of-file is reached */ - { -%% [8.0] yymore()-related code goes here - yy_cp = YY_G(yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = YY_G(yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - -%% [9.0] code to set up and find next match goes here - -yy_find_action: -%% [10.0] code to find the action number goes here - - YY_DO_BEFORE_ACTION; - -%% [11.0] code for yylineno update goes here - -do_action: /* This label is used only to access EOF actions. */ - -%% [12.0] debug code goes here - - switch ( yy_act ) - { /* beginning of action switch */ -%% [13.0] actions go here - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = YY_G(yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); - - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++YY_G(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { -%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) - { - case EOB_ACT_END_OF_FILE: - { - YY_G(yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = - YY_G(yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - YY_G(yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ -%ok-for-header - -%if-c++-only -%not-for-header -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) -{ - yyin = arg_yyin; - yyout = arg_yyout; - yy_c_buf_p = 0; - yy_init = 0; - yy_start = 0; - yy_flex_debug = 0; - yylineno = 1; // this will only get updated if %option yylineno - - yy_did_buffer_switch_on_eof = 0; - - yy_looking_for_trail_begin = 0; - yy_more_flag = 0; - yy_more_len = 0; - yy_more_offset = yy_prev_more_offset = 0; - - yy_start_stack_ptr = yy_start_stack_depth = 0; - yy_start_stack = NULL; - - yy_buffer_stack = 0; - yy_buffer_stack_top = 0; - yy_buffer_stack_max = 0; - - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; -]], -[[ - yy_state_buf = 0; -]]) -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -yyFlexLexer::~yyFlexLexer() -{ - delete [] yy_state_buf; - yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) -{ - if ( new_in ) - { - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); - } - - if ( new_out ) - yyout = new_out; -} - -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif -{ - if ( yyin->eof() || yyin->fail() ) - return 0; - -#ifdef YY_INTERACTIVE - yyin->get( buf[0] ); - - if ( yyin->eof() ) - return 0; - - if ( yyin->bad() ) - return -1; - - return 1; - -#else - (void) yyin->read( buf, max_size ); - - if ( yyin->bad() ) - return -1; - else - return yyin->gcount(); -#endif -} - -void yyFlexLexer::LexerOutput( const char* buf, int size ) -{ - (void) yyout->write( buf, size ); -} -%ok-for-header -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -%if-c-only -static int yy_get_next_buffer YYFARGS0(void) -%endif -%if-c++-only -int yyFlexLexer::yy_get_next_buffer() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = YY_G(yytext_ptr); - int number_to_move, i; - int ret_val; - - if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -]], -[[ - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; -]]) - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - YY_G(yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } - - if ( YY_G(yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin M4_YY_CALL_LAST_ARG); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - YY_G(yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} -]]) - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -%if-c-only -%not-for-header - static yy_state_type yy_get_previous_state YYFARGS0(void) -%endif -%if-c++-only - yy_state_type yyFlexLexer::yy_get_previous_state() -%endif -{ - yy_state_type yy_current_state; - char *yy_cp; - M4_YY_DECL_GUTS_VAR(); - -%% [15.0] code to get the start state into yy_current_state goes here - - for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) - { -%% [16.0] code to find the next state goes here - } - - return yy_current_state; -} - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ -%if-c-only - static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) -%endif -%if-c++-only - yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -%endif -{ - int yy_is_jam; - M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ -%% [17.0] code to find the next state, and perhaps do backing up, goes here - - M4_YY_NOOP_GUTS_VAR(); - return yy_is_jam ? 0 : yy_current_state; -} - - -%if-c-only -m4_ifdef( [[M4_YY_NO_UNPUT]],, -[[ - static void yyunput YYFARGS2( int,c, char *,yy_bp) -%endif -%if-c++-only - void yyFlexLexer::yyunput( int c, char* yy_bp) -%endif -{ - char *yy_cp; - M4_YY_DECL_GUTS_VAR(); - - yy_cp = YY_G(yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = YY_G(yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - yy_size_t number_to_move = YY_G(yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - -%% [18.0] update yylineno here -m4_ifdef( [[M4_YY_USE_LINENO]], -[[ - if ( c == '\n' ){ - --yylineno; - } -]]) - - YY_G(yytext_ptr) = yy_bp; - YY_G(yy_hold_char) = *yy_cp; - YY_G(yy_c_buf_p) = yy_cp; -} -%if-c-only -]]) -%endif - -%if-c-only -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput YYFARGS0(void) -#else - static int input YYFARGS0(void) -#endif - -%endif -%if-c++-only - int yyFlexLexer::yyinput() -%endif -{ - int c; - M4_YY_DECL_GUTS_VAR(); - - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - - if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) - /* This was really a NUL. */ - *YY_G(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr); - ++YY_G(yy_c_buf_p); - - switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin M4_YY_CALL_LAST_ARG); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - return EOF; - - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(M4_YY_CALL_ONLY_ARG); -#else - return input(M4_YY_CALL_ONLY_ARG); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ - *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ - YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); - -%% [19.0] update BOL and yylineno - - return c; -} -%if-c-only -#endif /* ifndef YY_NO_INPUT */ -%endif - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * M4_YY_DOC_PARAM - * @note This function does not reset the start condition to @c INITIAL . - */ -%if-c-only - void yyrestart YYFARGS1( FILE *,input_file) -%endif -%if-c++-only - void yyFlexLexer::yyrestart( std::istream* input_file ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * M4_YY_DOC_PARAM - */ -%if-c-only - void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) -%endif -%if-c++-only - void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - YY_G(yy_did_buffer_switch_on_eof) = 1; -} - - -%if-c-only -static void yy_load_buffer_state YYFARGS0(void) -%endif -%if-c++-only - void yyFlexLexer::yy_load_buffer_state() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * M4_YY_DOC_PARAM - * @return the allocated buffer state. - */ -%if-c-only - YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) -%endif -%if-c++-only - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) -%endif -{ - YY_BUFFER_STATE b; - m4_dnl M4_YY_DECL_GUTS_VAR(); - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * M4_YY_DOC_PARAM - */ -%if-c-only - void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) -%endif -%if-c++-only - void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); - - yyfree( (void *) b M4_YY_CALL_LAST_ARG ); -} - - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -%if-c-only - static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) -%endif -%if-c++-only - void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) -%endif - -{ - int oerrno = errno; - M4_YY_DECL_GUTS_VAR(); - - yy_flush_buffer( b M4_YY_CALL_LAST_ARG); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - -%if-c-only -m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], -[[ - b->yy_is_interactive = 1; -]], -[[ - m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], - [[ - b->yy_is_interactive = 0; - ]], - [[ - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - ]]) -]]) -%endif -%if-c++-only - b->yy_is_interactive = 0; -%endif - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * M4_YY_DOC_PARAM - */ -%if-c-only - void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) -%endif -%if-c++-only - void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); -} - -%if-c-or-c++ -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * M4_YY_DOC_PARAM - */ -%if-c-only -void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) -%endif -%if-c++-only -void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - YY_G(yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - YY_G(yy_did_buffer_switch_on_eof) = 1; -} -%endif - - -%if-c-or-c++ -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * M4_YY_DOC_PARAM - */ -%if-c-only -void yypop_buffer_state YYFARGS0(void) -%endif -%if-c++-only -void yyFlexLexer::yypop_buffer_state (void) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (YY_G(yy_buffer_stack_top) > 0) - --YY_G(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - YY_G(yy_did_buffer_switch_on_eof) = 1; - } -} -%endif - - -%if-c-or-c++ -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -%if-c-only -static void yyensure_buffer_stack YYFARGS0(void) -%endif -%if-c++-only -void yyFlexLexer::yyensure_buffer_stack(void) -%endif -{ - yy_size_t num_to_alloc; - M4_YY_DECL_GUTS_VAR(); - - if (!YY_G(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - - memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - YY_G(yy_buffer_stack_max) = num_to_alloc; - YY_G(yy_buffer_stack_top) = 0; - return; - } - - if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; - YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - (YY_G(yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - YY_G(yy_buffer_stack_max) = num_to_alloc; - } -} -%endif - - - - -m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, -[[ -%if-c-only -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) -{ - YY_BUFFER_STATE b; - m4_dnl M4_YY_DECL_GUTS_VAR(); - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); - - return b; -} -%endif -]]) - - -m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, -[[ -%if-c-only -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *, yystr) -{ - m4_dnl M4_YY_DECL_GUTS_VAR(); - - return yy_scan_bytes( yystr, strlen(yystr) M4_YY_CALL_LAST_ARG); -} -%endif -]]) - - -m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, -[[ -%if-c-only -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, yy_size_t ,_yybytes_len) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; - m4_dnl M4_YY_DECL_GUTS_VAR(); - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} -%endif -]]) - - -m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, -[[ -%if-c-only - static void yy_push_state YYFARGS1( int ,new_state) -%endif -%if-c++-only - void yyFlexLexer::yy_push_state( int new_state ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) - { - yy_size_t new_size; - - YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; - new_size = YY_G(yy_start_stack_depth) * sizeof( int ); - - if ( ! YY_G(yy_start_stack) ) - YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); - - else - YY_G(yy_start_stack) = (int *) yyrealloc( - (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); - - if ( ! YY_G(yy_start_stack) ) - YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); - } - - YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; - - BEGIN(new_state); -} -]]) - - -m4_ifdef( [[M4_YY_NO_POP_STATE]],, -[[ -%if-c-only - static void yy_pop_state YYFARGS0(void) -%endif -%if-c++-only - void yyFlexLexer::yy_pop_state() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if ( --YY_G(yy_start_stack_ptr) < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); -} -]]) - - -m4_ifdef( [[M4_YY_NO_TOP_STATE]],, -[[ -%if-c-only - static int yy_top_state YYFARGS0(void) -%endif -%if-c++-only - int yyFlexLexer::yy_top_state() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1]; -} -]]) - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -%if-c-only -static void yy_fatal_error YYFARGS1(yyconst char*, msg) -{ - m4_dnl M4_YY_DECL_GUTS_VAR(); - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} -%endif -%if-c++-only -void yyFlexLexer::LexerError( yyconst char msg[] ) -{ - M4_YY_DECL_GUTS_VAR(); - std::cerr << msg << std::endl; - exit( YY_EXIT_FAILURE ); -} -%endif - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = YY_G(yy_hold_char); \ - YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ - *YY_G(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - - - -/* Accessor methods (get/set functions) to struct members. */ - -%if-c-only -%if-reentrant -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, -[[ -/** Get the user-defined data for this scanner. - * M4_YY_DOC_PARAM - */ -YY_EXTRA_TYPE yyget_extra YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yyextra; -} -]]) -%endif - -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, -[[ -/** Get the current line number. - * M4_YY_DOC_PARAM - */ -int yyget_lineno YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (! YY_CURRENT_BUFFER) - return 0; - ]]) - return yylineno; -} -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, -[[ -/** Get the current column number. - * M4_YY_DOC_PARAM - */ -int yyget_column YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (! YY_CURRENT_BUFFER) - return 0; - ]]) - return yycolumn; -} -]]) -]]) - -m4_ifdef( [[M4_YY_NO_GET_IN]],, -[[ -/** Get the input stream. - * M4_YY_DOC_PARAM - */ -FILE *yyget_in YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yyin; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_OUT]],, -[[ -/** Get the output stream. - * M4_YY_DOC_PARAM - */ -FILE *yyget_out YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yyout; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_LENG]],, -[[ -/** Get the length of the current token. - * M4_YY_DOC_PARAM - */ -yy_size_t yyget_leng YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yyleng; -} -]]) - -/** Get the current token. - * M4_YY_DOC_PARAM - */ -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, -[[ -char *yyget_text YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yytext; -} -]]) - -%if-reentrant -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, -[[ -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * M4_YY_DOC_PARAM - */ -void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) -{ - M4_YY_DECL_GUTS_VAR(); - yyextra = user_defined ; -} -]]) -%endif - -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, -[[ -/** Set the current line number. - * @param line_number - * M4_YY_DOC_PARAM - */ -void yyset_lineno YYFARGS1( int ,line_number) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - ]]) - yylineno = line_number; -} -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, -[[ -/** Set the current column. - * @param line_number - * M4_YY_DOC_PARAM - */ -void yyset_column YYFARGS1( int , column_no) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - ]]) - yycolumn = column_no; -} -]]) -]]) - - -m4_ifdef( [[M4_YY_NO_SET_IN]],, -[[ -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * M4_YY_DOC_PARAM - * @see yy_switch_to_buffer - */ -void yyset_in YYFARGS1( FILE * ,in_str) -{ - M4_YY_DECL_GUTS_VAR(); - yyin = in_str ; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_OUT]],, -[[ -void yyset_out YYFARGS1( FILE * ,out_str) -{ - M4_YY_DECL_GUTS_VAR(); - yyout = out_str ; -} -]]) - - -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, -[[ -int yyget_debug YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yy_flex_debug; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, -[[ -void yyset_debug YYFARGS1( int ,bdebug) -{ - M4_YY_DECL_GUTS_VAR(); - yy_flex_debug = bdebug ; -} -]]) -%endif - -%if-reentrant -/* Accessor methods for yylval and yylloc */ - -%if-bison-bridge -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE * yyget_lval YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yylval; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_LVAL]],, -[[ -void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) -{ - M4_YY_DECL_GUTS_VAR(); - yylval = yylval_param; -} -]]) - -m4_ifdef( [[]], -[[ - m4_ifdef( [[M4_YY_NO_GET_LLOC]],, - [[ -YYLTYPE *yyget_lloc YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - return yylloc; -} - ]]) - - m4_ifdef( [[M4_YY_NO_SET_LLOC]],, - [[ -void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) -{ - M4_YY_DECL_GUTS_VAR(); - yylloc = yylloc_param; -} - ]]) -]]) - -%endif - - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], -[[ -int yylex_init( ptr_yy_globals ) - yyscan_t* ptr_yy_globals; -]], -[[ -int yylex_init(yyscan_t* ptr_yy_globals) -]]) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - - -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], -[[ -int yylex_init_extra( yy_user_defined, ptr_yy_globals ) - YY_EXTRA_TYPE yy_user_defined; - yyscan_t* ptr_yy_globals; -]], -[[ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -]]) -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -%endif if-c-only - - -%if-c-only -static int yy_init_globals YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - -m4_ifdef( [[M4_YY_USE_LINENO]], -[[ - m4_ifdef( [[M4_YY_NOT_REENTRANT]], - [[ - /* We do not touch yylineno unless the option is enabled. */ - yylineno = 1; - ]]) -]]) - YY_G(yy_buffer_stack) = 0; - YY_G(yy_buffer_stack_top) = 0; - YY_G(yy_buffer_stack_max) = 0; - YY_G(yy_c_buf_p) = (char *) 0; - YY_G(yy_init) = 0; - YY_G(yy_start) = 0; - -m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], -[[ - YY_G(yy_start_stack_ptr) = 0; - YY_G(yy_start_stack_depth) = 0; - YY_G(yy_start_stack) = NULL; -]]) - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - YY_G(yy_state_buf) = 0; - YY_G(yy_state_ptr) = 0; - YY_G(yy_full_match) = 0; - YY_G(yy_lp) = 0; -]]) - -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], -[[ - YY_G(yytext_ptr) = 0; - YY_G(yy_more_offset) = 0; - YY_G(yy_prev_more_offset) = 0; -]]) - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} -%endif - - -%if-c-only SNIP! this currently causes conflicts with the c++ scanner -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy YYFARGS0(void) -{ - M4_YY_DECL_GUTS_VAR(); - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(M4_YY_CALL_ONLY_ARG); - } - - /* Destroy the stack itself. */ - yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); - YY_G(yy_buffer_stack) = NULL; - -m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], -[[ - /* Destroy the start condition stack. */ - yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); - YY_G(yy_start_stack) = NULL; -]]) - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); - YY_G(yy_state_buf) = NULL; -]]) - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( M4_YY_CALL_ONLY_ARG); - -%if-reentrant - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); - yyscanner = NULL; -%endif - return 0; -} -%endif - - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* - * Internal utility routines. - */ -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#ifndef yytext_ptr -static void yy_flex_strncpy YYFARGS3( char*,s1, yyconst char *,s2, int,n) -{ - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YYFARGS1( yyconst char *,s) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc YYFARGS1( yy_size_t ,size) -{ - return (void *) malloc( size ); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree YYFARGS1( void *,ptr) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} -]]) - -%if-tables-serialization definitions -m4preproc_include(`tables_shared.c') - -static int yytbl_read8 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - rd->bread += sizeof(flex_uint8_t); - return 0; -} - -static int yytbl_read16 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); - rd->bread += sizeof(flex_uint16_t); - return 0; -} - -static int yytbl_read32 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); - rd->bread += sizeof(flex_uint32_t); - return 0; -} - -/** Read the header */ -static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) -{ - int bytes; - memset (th, 0, sizeof (struct yytbl_hdr)); - - if (yytbl_read32 (&(th->th_magic), rd) != 0) - return -1; - - if (th->th_magic != YYTBL_MAGIC){ - YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ - return -1; - } - - if (yytbl_read32 (&(th->th_hsize), rd) != 0 - || yytbl_read32 (&(th->th_ssize), rd) != 0 - || yytbl_read16 (&(th->th_flags), rd) != 0) - return -1; - - /* Sanity check on header size. Greater than 1k suggests some funny business. */ - if (th->th_hsize < 16 || th->th_hsize > 1024){ - YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate enough space for the version and name fields */ - bytes = th->th_hsize - 14; - th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! th->th_version ) - YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); - - /* we read it all into th_version, and point th_name into that data */ - if (fread (th->th_version, 1, bytes, rd->fp) != bytes){ - errno = EIO; - yyfree(th->th_version M4_YY_CALL_LAST_ARG); - th->th_version = NULL; - return -1; - } - else - rd->bread += bytes; - - th->th_name = th->th_version + strlen (th->th_version) + 1; - return 0; -} - -/** lookup id in the dmap list. - * @param dmap pointer to first element in list - * @return NULL if not found. - */ -static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, - int, id) -{ - while (dmap->dm_id) - if (dmap->dm_id == id) - return dmap; - else - dmap++; - return NULL; -} - -/** Read a table while mapping its contents to the local array. - * @param dmap used to performing mapping - * @return 0 on success - */ -static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) -{ - struct yytbl_data td; - struct yytbl_dmap *transdmap=0; - int len, i, rv, inner_loop_count; - void *p=0; - - memset (&td, 0, sizeof (struct yytbl_data)); - - if (yytbl_read16 (&td.td_id, rd) != 0 - || yytbl_read16 (&td.td_flags, rd) != 0 - || yytbl_read32 (&td.td_hilen, rd) != 0 - || yytbl_read32 (&td.td_lolen, rd) != 0) - return -1; - - /* Lookup the map for the transition table so we have it in case we need it - * inside the loop below. This scanner might not even have a transition - * table, which is ok. - */ - transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); - - if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){ - YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate space for table. - * The --full yy_transition table is a special case, since we - * need the dmap.dm_sz entry to tell us the sizeof the individual - * struct members. - */ - { - size_t bytes; - - if ((td.td_flags & YYTD_STRUCT)) - bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); - else - bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; - - if(M4_YY_TABLES_VERIFY) - /* We point to the array itself */ - p = dmap->dm_arr; - else - /* We point to the address of a pointer. */ - *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! p ) - YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); - } - - /* If it's a struct, we read 2 integers to get one element */ - if ((td.td_flags & YYTD_STRUCT) != 0) - inner_loop_count = 2; - else - inner_loop_count = 1; - - /* read and map each element. - * This loop iterates once for each element of the td_data array. - * Notice that we increment 'i' in the inner loop. - */ - len = yytbl_calc_total_len (&td); - for (i = 0; i < len; ){ - int j; - - - /* This loop really executes exactly 1 or 2 times. - * The second time is to handle the second member of the - * YYTD_STRUCT for the yy_transition array. - */ - for (j = 0; j < inner_loop_count; j++, i++) { - flex_int32_t t32; - - /* read into t32 no matter what the real size is. */ - { - flex_int16_t t16; - flex_int8_t t8; - - switch (YYTDFLAGS2BYTES (td.td_flags)) { - case sizeof (flex_int32_t): - rv = yytbl_read32 (&t32, rd); - break; - case sizeof (flex_int16_t): - rv = yytbl_read16 (&t16, rd); - t32 = t16; - break; - case sizeof (flex_int8_t): - rv = yytbl_read8 (&t8, rd); - t32 = t8; - break; - default: - YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ - return -1; - } - } - if (rv != 0) - return -1; - - /* copy into the deserialized array... */ - - if ((td.td_flags & YYTD_STRUCT)) { - /* t32 is the j'th member of a two-element struct. */ - void *v; - - v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) - : &(((struct yy_trans_info *) p)->yy_nxt); - - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if (M4_YY_TABLES_VERIFY){ - if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); - }else - ((flex_int32_t *) v)[0] = (flex_int32_t) t32; - break; - case sizeof (flex_int16_t): - if (M4_YY_TABLES_VERIFY ){ - if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); - }else - ((flex_int16_t *) v)[0] = (flex_int16_t) t32; - break; - case sizeof(flex_int8_t): - if (M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); - }else - ((flex_int8_t *) v)[0] = (flex_int8_t) t32; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ - return -1; - } - - /* if we're done with j, increment p */ - if (j == 1) - p = (struct yy_trans_info *) p + 1; - } - else if ((td.td_flags & YYTD_PTRANS)) { - /* t32 is an index into the transition array. */ - struct yy_trans_info *v; - - - if (!transdmap){ - YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ - return -1; - } - - if( M4_YY_TABLES_VERIFY) - v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); - else - v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); - - if(M4_YY_TABLES_VERIFY ){ - if( ((struct yy_trans_info **) p)[0] != v) - YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); - }else - ((struct yy_trans_info **) p)[0] = v; - - /* increment p */ - p = (struct yy_trans_info **) p + 1; - } - else { - /* t32 is a plain int. copy data, then incrememnt p. */ - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); - }else - ((flex_int32_t *) p)[0] = (flex_int32_t) t32; - p = ((flex_int32_t *) p) + 1; - break; - case sizeof (flex_int16_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); - }else - ((flex_int16_t *) p)[0] = (flex_int16_t) t32; - p = ((flex_int16_t *) p) + 1; - break; - case sizeof (flex_int8_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); - }else - ((flex_int8_t *) p)[0] = (flex_int8_t) t32; - p = ((flex_int8_t *) p) + 1; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ - return -1; - } - } - } - - } - - /* Now eat padding. */ - { - int pad; - pad = yypad64(rd->bread); - while(--pad >= 0){ - flex_int8_t t8; - if(yytbl_read8(&t8,rd) != 0) - return -1; - } - } - - return 0; -} - -%define-yytables The name for this specific scanner's tables. - -/* Find the key and load the DFA tables from the given stream. */ -static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) -{ - int rv=0; - struct yytbl_hdr th; - struct yytbl_reader rd; - - rd.fp = fp; - th.th_version = NULL; - - /* Keep trying until we find the right set of tables or end of file. */ - while (!feof(rd.fp)) { - rd.bread = 0; - if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - - /* A NULL key means choose the first set of tables. */ - if (key == NULL) - break; - - if (strcmp(th.th_name,key) != 0){ - /* Skip ahead to next set */ - fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - else - break; - } - - while (rd.bread < th.th_ssize){ - /* Load the data tables */ - if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - } - -return_rv: - if(th.th_version){ - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - - return rv; -} - -/** Load the DFA tables for this scanner from the given stream. */ -int yytables_fload YYFARGS1(FILE *, fp) -{ - - if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) - return -1; - return 0; -} - -/** Destroy the loaded tables, freeing memory, etc.. */ -int yytables_destroy YYFARGS0(void) -{ - struct yytbl_dmap *dmap=0; - - if(!M4_YY_TABLES_VERIFY){ - /* Walk the dmap, freeing the pointers */ - for(dmap=yydmap; dmap->dm_id; dmap++) { - void * v; - v = dmap->dm_arr; - if(v && *(char**)v){ - yyfree(*(char**)v M4_YY_CALL_LAST_ARG); - *(char**)v = NULL; - } - } - } - - return 0; -} - -/* end table serialization code definitions */ -%endif - - -m4_ifdef([[M4_YY_MAIN]], [[ -int main M4_YY_PARAMS(void); - -int main () -{ - -%if-reentrant - yyscan_t lexer; - yylex_init(&lexer); - yylex( lexer ); - yylex_destroy( lexer); - -%endif -%if-not-reentrant - yylex(); -%endif - - return 0; -} -]]) - -%ok-for-header -m4_ifdef( [[M4_YY_IN_HEADER]], -[[ -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif -]]) diff --git a/third_party/lex/flexdef.h b/third_party/lex/flexdef.h deleted file mode 100644 index 33ca638e..00000000 --- a/third_party/lex/flexdef.h +++ /dev/null @@ -1,1105 +0,0 @@ -/* clang-format off */ -#include "libc/stdio/stdio.h" -#include "libc/runtime/runtime.h" -#include "libc/macros.h" -#include "libc/calls/openbsd.internal.h" - -/* $OpenBSD: flexdef.h,v 1.15 2015/11/19 23:48:06 tedu Exp $ */ - -/* flexdef - definitions file for flex */ - -/* 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 "third_party/lex/config.h" -#endif - -#include "libc/limits.h" -#include "third_party/regex/regex.h" -#include "third_party/lex/flexint.h" - -#define _(STRING) STRING - -/* Always be prepared to generate an 8-bit scanner. */ -#define CSIZE 256 - -/* Size of input alphabet - should be size of ASCII set. */ -#ifndef DEFAULT_CSIZE -#define DEFAULT_CSIZE 128 -#endif - -#ifndef PROTO -#if defined(__STDC__) -#define PROTO(proto) proto -#else -#define PROTO(proto) () -#endif -#endif - -/* Maximum line length we'll have to deal with. */ -#define MAXLINE 2048 - -#define unspecified -1 - -/* Special chk[] values marking the slots taking by end-of-buffer and action - * numbers. - */ -#define EOB_POSITION -1 -#define ACTION_POSITION -2 - -/* Number of data items per line for -f output. */ -#define NUMDATAITEMS 10 - -/* Number of lines of data in -f output before inserting a blank line for - * readability. - */ -#define NUMDATALINES 10 - -/* transition_struct_out() definitions. */ -#define TRANS_STRUCT_PRINT_LENGTH 14 - -/* Returns true if an nfa state has an epsilon out-transition slot - * that can be used. This definition is currently not used. - */ -#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 - * and both slots are free - */ -#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 - * big because if there's a lot of rules, the initial state will have a - * huge epsilon closure. - */ -#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 - * as being special. As such, they implicitly limit the number of accepting - * numbers (i.e., rules) because if there are too many rules the rule numbers - * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 == - * 8192) so unlikely to actually cause any problems. A check is made in - * new_rule() to ensure that this limit is not reached. - */ - -/* 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 - * (it marks the representative of a given e.c.) will be unidentifiable. - */ -#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 - * is guaranteed to be negative. - */ -#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 out-transitions a state must be of the - * number of equivalence classes in order to be considered for table - * compaction by using protos. - */ -#define PROTO_SIZE_PERCENTAGE 15 - -/* The percentage the number of homogeneous out-transitions of a state - * must be of the number of total out-transitions of the state in order - * that the state's transition table is first compared with a potential - * template of the most common out-transition instead of with the first - * proto in the proto queue. - */ -#define CHECK_COM_PERCENTAGE 50 - -/* The percentage the number of differences between a state's transition - * table and the proto it was first compared with must be of the total - * number of out-transitions of the state in order to keep the first - * proto as a good match and not search any further. - */ -#define FIRST_MATCH_DIFF_PERCENTAGE 10 - -/* The percentage the number of differences between a state's transition - * table and the most similar proto must be of the state's total number - * of out-transitions to use the proto as an acceptable close match. - */ -#define ACCEPTABLE_DIFF_PERCENTAGE 50 - -/* The percentage the number of homogeneous out-transitions of a state - * must be of the number of total out-transitions of the state in order - * to consider making a template from the state. - */ -#define TEMPLATE_SAME_PERCENTAGE 60 - -/* The percentage the number of differences between a state's transition - * table and the most similar proto must be of the state's total number - * of out-transitions to create a new proto from the state. - */ -#define NEW_PROTO_DIFF_PERCENTAGE 20 - -/* The percentage the total number of out-transitions of a state must be - * of the number of equivalence classes in order to consider trying to - * fit the transition table into "holes" inside the nxt/chk table. - */ -#define INTERIOR_FIT_PERCENTAGE 15 - -/* Size of region set aside to cache the complete transition table of - * protos on the proto queue to enable quick comparisons. - */ -#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 - * around through the interior of the internal fast table looking for a - * spot for it. - */ -#define MAX_XTIONS_FULL_INTERIOR_FIT 4 - -/* Maximum number of rules which will be reported as being associated - * with a DFA state. - */ -#define MAX_ASSOC_RULES 100 - -/* Number that, if used to subscript an array, has a good chance of producing - * an error; should be small enough to fit into a short. - */ -#define BAD_SUBSCRIPT -32767 - -/* Absolute value of largest number that can be stored in a short, with a - * bit of slop thrown in for general paranoia. - */ -#define MAX_SHORT 32700 - -/* Declarations for global variables. */ - -/* Variables for flags: - * printstats - if true (-v), dump statistics - * syntaxerror - true if a syntax error has been found - * eofseen - true if we've seen an eof in the input file - * ddebug - if true (-d), make a "debug" scanner - * trace - if true (-T), trace processing - * nowarn - if true (-w), do not generate warnings - * spprdflt - if true (-s), suppress the default rule - * interactive - if true (-I), generate an interactive scanner - * lex_compat - if true (-l), maximize compatibility with AT&T lex - * posix_compat - if true (-X), maximize compatibility with POSIX lex - * do_yylineno - if true, generate code to maintain yylineno - * useecs - if true (-Ce flag), use equivalence classes - * fulltbl - if true (-Cf flag), don't compress the DFA state table - * usemecs - if true (-Cm flag), use meta-equivalence classes - * fullspd - if true (-F flag), use Jacobson method of table representation - * gen_line_dirs - if true (i.e., no -L flag), generate #line directives - * performance_report - if > 0 (i.e., -p flag), generate a report relating - * to scanner performance; if > 1 (-p -p), report on minor performance - * problems, too - * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file - * listing backing-up states - * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class; - * otherwise, a standard C scanner - * reentrant - if true (-R), generate a reentrant C scanner. - * bison_bridge_lval - if true (--bison-bridge), bison pure calling convention. - * bison_bridge_lloc - if true (--bison-locations), bison yylloc. - * long_align - if true (-Ca flag), favor long-word alignment. - * use_read - if true (-f, -F, or -Cr) then use read() for scanner input; - * otherwise, use fread(). - * yytext_is_array - if true (i.e., %array directive), then declare - * yytext as a array instead of a character pointer. Nice and inefficient. - * do_yywrap - do yywrap() processing on EOF. If false, EOF treated as - * "no more files". - * csize - size of character set for the scanner we're generating; - * 128 for 7-bit chars and 256 for 8-bit - * yymore_used - if true, yymore() is used in input rules - * reject - if true, generate back-up tables for REJECT macro - * real_reject - if true, scanner really uses REJECT (as opposed to just - * having "reject" set for variable trailing context) - * continued_action - true if this rule's action is to "fall through" to - * the next rule's action (i.e., the '|' action) - * in_rule - true if we're inside an individual rule, false if not. - * yymore_really_used - whether to treat yymore() as really used, regardless - * of what we think based on references to it in the user's actions. - * reject_really_used - same for REJECT - */ - -extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; -extern int interactive, lex_compat, posix_compat, do_yylineno; -extern int useecs, fulltbl, usemecs, fullspd; -extern int gen_line_dirs, performance_report, backing_up_report; -extern int reentrant, bison_bridge_lval, bison_bridge_lloc; -extern bool ansi_func_defs, ansi_func_protos; -extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap; -extern int csize; -extern int yymore_used, reject, real_reject, continued_action, in_rule; - -extern int yymore_really_used, reject_really_used; - -/* Variables used in the flex input routines: - * datapos - characters on current output line - * dataline - number of contiguous lines of data in current data - * statement. Used to generate readable -f output - * linenum - current input line number - * skelfile - the skeleton file - * skel - compiled-in skeleton array - * skel_ind - index into "skel" array, if skelfile is nil - * yyin - input file - * backing_up_file - file to summarize backing-up states to - * infilename - name of input file - * outfilename - name of output file - * headerfilename - name of the .h file to generate - * did_outfilename - whether outfilename was explicitly set - * prefix - the prefix used for externally visible names ("yy" by default) - * yyclass - yyFlexLexer subclass to use for YY_DECL - * do_stdinit - whether to initialize yyin/yyout to stdin/stdout - * use_stdout - the -t flag - * input_files - array holding names of input files - * num_input_files - size of input_files array - * program_name - name with which program was invoked - * - * action_array - array to hold the rule actions - * action_size - size of action_array - * defs1_offset - index where the user's section 1 definitions start - * in action_array - * prolog_offset - index where the prolog starts in action_array - * action_offset - index where the non-prolog starts in action_array - * action_index - index where the next action should go, with respect - * to "action_array" - */ - -extern int datapos, dataline, linenum; -extern FILE *skelfile, *yyin, *backing_up_file; -extern const char *skel[]; -extern int skel_ind; -extern char *infilename, *outfilename, *headerfilename; -extern int did_outfilename; -extern char *prefix, *yyclass, *extra_type; -extern int do_stdinit, use_stdout; -extern char **input_files; -extern int num_input_files; -extern char *program_name; - -extern char *action_array; -extern int action_size; -extern int defs1_offset, prolog_offset, action_offset, action_index; - -/* Variables for stack of states having only one out-transition: - * onestate - state number - * onesym - transition symbol - * onenext - target state - * onedef - default base entry - * onesp - stack pointer - */ - -extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; -extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; - -/* Variables for nfa machine data: - * maximum_mns - maximal number of NFA states supported by tables - * current_mns - current maximum on number of NFA states - * num_rules - number of the last accepting state; also is number of - * rules created so far - * num_eof_rules - number of <> rules - * default_rule - number of the default rule - * current_max_rules - current maximum number of rules - * lastnfa - last nfa state number created - * firstst - physically the first state of a fragment - * lastst - last physical state of fragment - * finalst - last logical state of fragment - * transchar - transition character - * trans1 - transition state - * trans2 - 2nd transition state for epsilons - * accptnum - accepting number - * assoc_rule - rule associated with this NFA state (or 0 if none) - * state_type - a STATE_xxx type identifying whether the state is part - * of a normal rule, the leading state in a trailing context - * rule (i.e., the state which marks the transition from - * recognizing the text-to-be-matched to the beginning of - * the trailing context), or a subsequent state in a trailing - * context rule - * rule_type - a RULE_xxx type identifying whether this a ho-hum - * normal rule or one which has variable head & trailing - * context - * rule_linenum - line number associated with rule - * rule_useful - true if we've determined that the rule can be matched - * rule_has_nl - true if rule could possibly match a newline - * ccl_has_nl - true if current ccl could match a newline - * nlch - default eol char - */ - -extern int maximum_mns, current_mns, current_max_rules; -extern int num_rules, num_eof_rules, default_rule, lastnfa; -extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; -extern int *accptnum, *assoc_rule, *state_type; -extern int *rule_type, *rule_linenum, *rule_useful; -extern bool *rule_has_nl, *ccl_has_nl; -extern int nlch; - -/* Different types of states; values are useful as masks, as well, for - * routines like check_trailing_context(). - */ -#define STATE_NORMAL 0x1 -#define STATE_TRAILING_CONTEXT 0x2 - -/* Global holding current type of state we're making. */ - -extern int 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 - * and trailing context, false otherwise. - */ -extern int variable_trailing_context_rules; - -/* Variables for protos: - * numtemps - number of templates created - * numprots - number of protos created - * protprev - backlink to a more-recently used proto - * protnext - forward link to a less-recently used proto - * prottbl - base/def table entry for proto - * protcomst - common state of proto - * firstprot - number of the most recently used proto - * lastprot - number of the least recently used proto - * protsave contains the entire state array for protos - */ - -extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; -extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; - -/* Variables for managing equivalence classes: - * numecs - number of equivalence classes - * nextecm - forward link of Equivalence Class members - * ecgroup - class number or backward link of EC members - * nummecs - number of meta-equivalence classes (used to compress - * templates) - * tecfwd - forward link of meta-equivalence classes members - * tecbck - backward link of MEC's - */ - -/* Reserve enough room in the equivalence class arrays so that we - * can use the CSIZE'th element to hold equivalence class information - * for the NUL character. Later we'll move this information into - * the 0th element. - */ -extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs; - -/* Meta-equivalence classes are indexed starting at 1, so it's possible - * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1 - * slots total (since the arrays are 0-based). nextecm[] and ecgroup[] - * don't require the extra position since they're indexed from 1 .. CSIZE - 1. - */ -extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1]; - -/* Variables for start conditions: - * lastsc - last start condition created - * current_max_scs - current limit on number of start conditions - * scset - set of rules active in start condition - * scbol - set of rules active only at the beginning of line in a s.c. - * scxclu - true if start condition is exclusive - * sceof - true if start condition has EOF rule - * scname - start condition name - */ - -extern int lastsc, *scset, *scbol, *scxclu, *sceof; -extern int current_max_scs; -extern char **scname; - -/* Variables for dfa machine data: - * current_max_dfa_size - current maximum number of NFA states in DFA - * current_max_xpairs - current maximum number of non-template xtion pairs - * current_max_template_xpairs - current maximum number of template pairs - * current_max_dfas - current maximum number DFA states - * lastdfa - last dfa state number created - * nxt - state to enter upon reading character - * chk - check value to see if "nxt" applies - * tnxt - internal nxt table for templates - * base - offset into "nxt" for given state - * def - where to go if "chk" disallows "nxt" entry - * nultrans - NUL transition for each state - * NUL_ec - equivalence class of the NUL character - * tblend - last "nxt/chk" table entry being used - * firstfree - first empty entry in "nxt/chk" table - * dss - nfa state set for each dfa - * dfasiz - size of nfa state set for each dfa - * dfaacc - accepting set for each dfa state (if using REJECT), or accepting - * number, if not - * accsiz - size of accepting set for each dfa state - * dhash - dfa state hash value - * numas - number of DFA accepting states created; note that this - * is not necessarily the same value as num_rules, which is the analogous - * value for the NFA - * numsnpairs - number of state/nextstate transition pairs - * jambase - position in base/def where the default jam table starts - * jamstate - state number corresponding to "jam" state - * end_of_buffer_state - end-of-buffer dfa state number - */ - -extern int current_max_dfa_size, current_max_xpairs; -extern int current_max_template_xpairs, current_max_dfas; -extern int lastdfa, *nxt, *chk, *tnxt; -extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; -extern union dfaacc_union { - int *dfaacc_set; - int dfaacc_state; -} * dfaacc; -extern int *accsiz, *dhash, numas; -extern int numsnpairs, jambase, jamstate; -extern int end_of_buffer_state; - -/* Variables for ccl information: - * lastccl - ccl index of the last created ccl - * current_maxccls - current limit on the maximum number of unique ccl's - * cclmap - maps a ccl index to its set pointer - * ccllen - gives the length of a ccl - * cclng - true for a given ccl if the ccl is negated - * cclreuse - counts how many times a ccl is re-used - * current_max_ccl_tbl_size - current limit on number of characters needed - * to represent the unique ccl's - * ccltbl - holds the characters in each ccl - indexed by cclmap - */ - -extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse; -extern int current_maxccls, current_max_ccl_tbl_size; -extern u_char *ccltbl; - -/* Variables for miscellaneous information: - * nmstr - last NAME scanned by the scanner - * sectnum - section number currently being parsed - * nummt - number of empty nxt/chk table entries - * hshcol - number of hash collisions detected by snstods - * dfaeql - number of times a newly created dfa was equal to an old one - * numeps - number of epsilon NFA states created - * eps2 - number of epsilon states which have 2 out-transitions - * num_reallocs - number of times it was necessary to realloc() a group - * of arrays - * tmpuses - number of DFA states that chain to templates - * totnst - total number of NFA states used to make DFA states - * peakpairs - peak number of transition pairs we had to store internally - * numuniq - number of unique transitions - * numdup - number of duplicate transitions - * hshsave - number of hash collisions saved by checking number of states - * num_backing_up - number of DFA states requiring backing up - * bol_needed - whether scanner needs beginning-of-line recognition - */ - -extern char nmstr[MAXLINE]; -extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; -extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; -extern int num_backing_up, bol_needed; - -void *allocate_array PROTO((int, size_t)); -void *reallocate_array PROTO((void *, int, size_t)); - -#define allocate_integer_array(size) (int *)allocate_array(size, sizeof(int)) - -#define reallocate_integer_array(array, size) \ - (int *)reallocate_array((void *)array, size, sizeof(int)) - -#define allocate_bool_array(size) (bool *)allocate_array(size, sizeof(bool)) - -#define reallocate_bool_array(array, size) \ - (bool *)reallocate_array((void *)array, size, sizeof(bool)) - -#define allocate_int_ptr_array(size) (int **)allocate_array(size, sizeof(int *)) - -#define allocate_char_ptr_array(size) \ - (char **)allocate_array(size, sizeof(char *)) - -#define allocate_dfaacc_union(size) \ - (union dfaacc_union *)allocate_array(size, sizeof(union dfaacc_union)) - -#define reallocate_int_ptr_array(array, size) \ - (int **)reallocate_array((void *)array, size, sizeof(int *)) - -#define reallocate_char_ptr_array(array, size) \ - (char **)reallocate_array((void *)array, size, sizeof(char *)) - -#define reallocate_dfaacc_union(array, size) \ - (union dfaacc_union *)reallocate_array((void *)array, size, \ - sizeof(union dfaacc_union)) - -#define allocate_character_array(size) \ - (char *)allocate_array(size, sizeof(char)) - -#define reallocate_character_array(array, size) \ - (char *)reallocate_array((void *)array, size, sizeof(char)) - -#define allocate_Character_array(size) \ - (u_char *)allocate_array(size, sizeof(u_char)) - -#define reallocate_Character_array(array, size) \ - (u_char *)reallocate_array((void *)array, size, sizeof(u_char)) - -/* Used to communicate between scanner and parser. The type should really - * be YYSTYPE, but we can't easily get our hands on it. - */ -extern int yylval; - -/* External functions that are cross-referenced among the flex source files. */ - -/* from file ccl.c */ - -extern void ccladd PROTO((int, int)); /* add a single character to a ccl */ -extern int cclinit PROTO((void)); /* make an empty ccl */ -extern void cclnegate PROTO((int)); /* negate a ccl */ -extern int ccl_set_diff(int a, int b); /* set difference of two ccls. */ -extern int ccl_set_union(int a, int b); /* set union of two ccls. */ - -/* List the members of a set of characters in CCL form. */ -extern void list_character_set PROTO((FILE *, int[])); - -/* from file dfa.c */ - -/* Check a DFA state for backing up. */ -extern void check_for_backing_up PROTO((int, int[])); - -/* Check to see if NFA state set constitutes "dangerous" trailing context. */ -extern void check_trailing_context PROTO((int *, int, int *, int)); - -/* Construct the epsilon closure of a set of ndfa states. */ -extern int *epsclosure PROTO((int *, int *, int[], int *, int *)); - -/* Increase the maximum number of dfas. */ -extern void increase_max_dfas PROTO((void)); - -extern void ntod PROTO((void)); /* convert a ndfa to a dfa */ - -/* Converts a set of ndfa states into a dfa state. */ -extern int snstods PROTO((int[], int, int[], int, int, int *)); - -/* from file ecs.c */ - -/* Convert character classes to set of equivalence classes. */ -extern void ccl2ecl PROTO((void)); - -/* Associate equivalence class numbers with class members. */ -extern int cre8ecs PROTO((int[], int[], int)); - -/* Update equivalence classes based on character class transitions. */ -extern void mkeccl PROTO((u_char[], int, int[], int[], int, int)); - -/* Create equivalence class for single character. */ -extern void mkechar PROTO((int, int[], int[])); - -/* from file gen.c */ - -extern void do_indent PROTO((void)); /* indent to the current level */ - -/* Generate the code to keep backing-up information. */ -extern void gen_backing_up PROTO((void)); - -/* Generate the code to perform the backing up. */ -extern void gen_bu_action PROTO((void)); - -/* Generate full speed compressed transition table. */ -extern void genctbl PROTO((void)); - -/* Generate the code to find the action number. */ -extern void gen_find_action PROTO((void)); - -extern void genftbl PROTO((void)); /* generate full transition table */ - -/* Generate the code to find the next compressed-table state. */ -extern void gen_next_compressed_state PROTO((char *)); - -/* Generate the code to find the next match. */ -extern void gen_next_match PROTO((void)); - -/* Generate the code to find the next state. */ -extern void gen_next_state PROTO((int)); - -/* Generate the code to make a NUL transition. */ -extern void gen_NUL_trans PROTO((void)); - -/* Generate the code to find the start state. */ -extern void gen_start_state PROTO((void)); - -/* Generate data statements for the transition tables. */ -extern void gentabs PROTO((void)); - -/* Write out a formatted string at the current indentation level. */ -extern void indent_put2s PROTO((const char *, const char *)); - -/* Write out a string + newline at the current indentation level. */ -extern void indent_puts PROTO((const char *)); - -extern void make_tables PROTO((void)); /* generate transition tables */ - -/* from file main.c */ - -extern void check_options PROTO((void)); -extern void flexend PROTO((int)); -extern void usage PROTO((void)); - -/* from file misc.c */ - -/* Add a #define to the action file. */ -extern void action_define PROTO((const char *defname, int value)); - -/* Add the given text to the stored actions. */ -extern void add_action PROTO((const char *new_text)); - -/* True if a string is all lower case. */ -extern int all_lower PROTO((char *)); - -/* True if a string is all upper case. */ -extern int all_upper PROTO((char *)); - -/* Compare two integers for use by qsort. */ -extern int intcmp PROTO((const void *, const void *)); - -/* Check a character to make sure it's in the expected range. */ -extern void check_char PROTO((int c)); - -/* Replace upper-case letter to lower-case. */ -extern u_char clower PROTO((int)); - -/* Returns a dynamically allocated copy of a string. */ -extern char *copy_string PROTO((const char *)); - -/* Returns a dynamically allocated copy of a (potentially) unsigned string. */ -extern u_char *copy_unsigned_string PROTO((u_char *)); - -/* Compare two characters for use by qsort with '\0' sorting last. */ -extern int cclcmp PROTO((const void *, const void *)); - -/* Finish up a block of data declarations. */ -extern void dataend PROTO((void)); - -/* Flush generated data statements. */ -extern void dataflush PROTO((void)); - -/* Report an error message and terminate. */ -extern void flexerror PROTO((const char *)); - -/* Report a fatal error message and terminate. */ -extern void flexfatal PROTO((const char *)); - -/* Report a fatal error with a pinpoint, and terminate */ -#if HAVE_DECL___FUNC__ -#define flex_die(msg) \ - do { \ - fprintf(stderr, _("%s: fatal internal error at %s:%d (%s): %s\n"), \ - program_name, __FILE__, (int)__LINE__, __func__, msg); \ - FLEX_EXIT(1); \ - } while (0) -#else /* ! HAVE_DECL___FUNC__ */ -#define flex_die(msg) \ - do { \ - fprintf(stderr, _("%s: fatal internal error at %s:%d %s\n"), program_name, \ - __FILE__, (int)__LINE__, msg); \ - FLEX_EXIT(1); \ - } while (0) -#endif /* ! HAVE_DECL___func__ */ - -/* Convert a hexadecimal digit string to an integer value. */ -extern int htoi PROTO((u_char[])); - -/* Report an error message formatted with one integer argument. */ -extern void lerrif PROTO((const char *, int)); - -/* Report an error message formatted with one string argument. */ -extern void lerrsf PROTO((const char *, const char *)); - -/* Like lerrsf, but also exit after displaying message. */ -extern void lerrsf_fatal PROTO((const char *, const char *)); - -/* Spit out a "#line" statement. */ -extern void line_directive_out PROTO((FILE *, int)); - -/* Mark the current position in the action array as the end of the section 1 - * user defs. - */ -extern void mark_defs1 PROTO((void)); - -/* Mark the current position in the action array as the end of the prolog. */ -extern void mark_prolog PROTO((void)); - -/* Generate a data statment for a two-dimensional array. */ -extern void mk2data PROTO((int)); - -extern void mkdata PROTO((int)); /* generate a data statement */ - -/* Return the integer represented by a string of digits. */ -extern int myctoi PROTO((const char *)); - -/* Return character corresponding to escape sequence. */ -extern u_char myesc PROTO((u_char[])); - -/* Convert an octal digit string to an integer value. */ -extern int otoi PROTO((u_char[])); - -/* Output a (possibly-formatted) string to the generated scanner. */ -extern void out PROTO((const char *)); -extern void out_dec PROTO((const char *, int)); -extern void out_dec2 PROTO((const char *, int, int)); -extern void out_hex PROTO((const char *, unsigned int)); -extern void out_str PROTO((const char *, const char *)); -extern void out_str3 PROTO((const char *, const char *, const char *, - const char *)); -extern void out_str_dec PROTO((const char *, const char *, int)); -extern void outc PROTO((int)); -extern void outn PROTO((const char *)); -extern void out_m4_define(const char *def, const char *val); - -/* Return a printable version of the given character, which might be - * 8-bit. - */ -extern char *readable_form PROTO((int)); - -/* Write out one section of the skeleton file. */ -extern void skelout PROTO((void)); - -/* Output a yy_trans_info structure. */ -extern void transition_struct_out PROTO((int, int)); - -/* Only needed when using certain broken versions of bison to build parse.c. */ -extern void *yy_flex_xmalloc PROTO((int)); - -/* from file nfa.c */ - -/* Add an accepting state to a machine. */ -extern void add_accept PROTO((int, int)); - -/* Make a given number of copies of a singleton machine. */ -extern int copysingl PROTO((int, int)); - -/* Debugging routine to write out an nfa. */ -extern void dumpnfa PROTO((int)); - -/* Finish up the processing for a rule. */ -extern void finish_rule PROTO((int, int, int, int, int)); - -/* Connect two machines together. */ -extern int link_machines PROTO((int, int)); - -/* Mark each "beginning" state in a machine as being a "normal" (i.e., - * not trailing context associated) state. - */ -extern void mark_beginning_as_normal PROTO((int)); - -/* Make a machine that branches to two machines. */ -extern int mkbranch PROTO((int, int)); - -extern int mkclos PROTO((int)); /* convert a machine into a closure */ -extern int mkopt PROTO((int)); /* make a machine optional */ - -/* Make a machine that matches either one of two machines. */ -extern int mkor PROTO((int, int)); - -/* Convert a machine into a positive closure. */ -extern int mkposcl PROTO((int)); - -extern int mkrep PROTO((int, int, int)); /* make a replicated machine */ - -/* Create a state with a transition on a given symbol. */ -extern int mkstate PROTO((int)); - -extern void new_rule PROTO((void)); /* initialize for a new rule */ - -/* from file parse.y */ - -/* Build the "<>" action for the active start conditions. */ -extern void build_eof_action PROTO((void)); - -/* Write out a message formatted with one string, pinpointing its location. */ -extern void format_pinpoint_message PROTO((const char *, const char *)); - -/* Write out a message, pinpointing its location. */ -extern void pinpoint_message PROTO((const char *)); - -/* Write out a warning, pinpointing it at the given line. */ -extern void line_warning PROTO((const char *, int)); - -/* Write out a message, pinpointing it at the given line. */ -extern void line_pinpoint PROTO((const char *, int)); - -/* Report a formatted syntax error. */ -extern void format_synerr PROTO((const char *, const char *)); -extern void synerr PROTO((const char *)); /* report a syntax error */ -extern void format_warn PROTO((const char *, const char *)); -extern void lexwarn PROTO((const char *)); /* report a warning */ -extern void yyerror PROTO((const char *)); /* report a parse error */ -extern int yyparse PROTO((void)); /* the YACC parser */ - -/* from file scan.l */ - -/* The Flex-generated scanner for flex. */ -extern int flexscan PROTO((void)); - -/* Open the given file (if NULL, stdin) for scanning. */ -extern void set_input_file PROTO((char *)); - -/* Wrapup a file in the lexical analyzer. */ -extern int yywrap PROTO((void)); - -/* from file sym.c */ - -/* Save the text of a character class. */ -extern void cclinstal PROTO((u_char[], int)); - -/* Lookup the number associated with character class. */ -extern int ccllookup PROTO((u_char[])); - -extern void ndinstal PROTO((const char *, - u_char[])); /* install a name definition */ -extern u_char *ndlookup PROTO((const char *)); /* lookup a name definition */ - -/* Increase maximum number of SC's. */ -extern void scextend PROTO((void)); -extern void scinstal PROTO((const char *, int)); /* make a start condition */ - -/* Lookup the number associated with a start condition. */ -extern int sclookup PROTO((const char *)); - -/* from file tblcmp.c */ - -/* Build table entries for dfa state. */ -extern void bldtbl PROTO((int[], int, int, int, int)); - -extern void cmptmps PROTO((void)); /* compress template table entries */ -extern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */ - -/* Finds a space in the table for a state to be placed. */ -extern int find_table_space PROTO((int *, int)); -extern void inittbl PROTO((void)); /* initialize transition tables */ - -/* Make the default, "jam" table entries. */ -extern void mkdeftbl PROTO((void)); - -/* Create table entries for a state (or state fragment) which has - * only one out-transition. - */ -extern void mk1tbl PROTO((int, int, int, int)); - -/* Place a state into full speed transition table. */ -extern void place_state PROTO((int *, int, int)); - -/* Save states with only one out-transition to be processed later. */ -extern void stack1 PROTO((int, int, int, int)); - -/* from file yylex.c */ - -extern int 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. */ -}; - -extern void buf_init PROTO((struct Buf * buf, size_t elem_size)); -extern void buf_destroy PROTO((struct Buf * buf)); -extern struct Buf *buf_append PROTO((struct Buf * buf, const void *ptr, - int n_elem)); -extern struct Buf *buf_concat PROTO((struct Buf * dest, const struct Buf *src)); -extern struct Buf *buf_strappend PROTO((struct Buf *, const char *str)); -extern struct Buf *buf_strnappend PROTO((struct Buf *, const char *str, - int nchars)); -extern struct Buf *buf_strdefine PROTO((struct Buf * buf, const char *str, - const char *def)); -extern struct Buf *buf_prints PROTO((struct Buf * buf, const char *fmt, - const char *s)); -extern struct Buf *buf_m4_define PROTO((struct Buf * buf, const char *def, - const char *val)); -extern struct Buf *buf_m4_undefine PROTO((struct Buf * buf, const char *def)); -extern struct Buf *buf_print_strings PROTO((struct Buf * buf, FILE *out)); -extern struct Buf *buf_linedir PROTO((struct Buf * buf, const char *filename, - int lineno)); - -extern struct Buf userdef_buf; /* a string buffer for #define's generated by - user-options on cmd line. */ -extern struct Buf defs_buf; /* a char* buffer to save #define'd some symbols - generated by flex. */ -extern struct Buf yydmap_buf; /* a string buffer to hold yydmap elements */ -extern struct Buf m4defs_buf; /* Holds m4 definitions. */ -extern struct 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; - -#define FLEX_EXIT(status) longjmp(flex_main_jmp_buf, (status) + 1) - -/* ctype functions forced to return boolean */ -#define b_isalnum(c) (isalnum(c) ? true : false) -#define b_isalpha(c) (isalpha(c) ? true : false) -#define b_isascii(c) (isascii(c) ? true : false) -#define b_isblank(c) (isblank(c) ? true : false) -#define b_iscntrl(c) (iscntrl(c) ? true : false) -#define b_isdigit(c) (isdigit(c) ? true : false) -#define b_isgraph(c) (isgraph(c) ? true : false) -#define b_islower(c) (islower(c) ? true : false) -#define b_isprint(c) (isprint(c) ? true : false) -#define b_ispunct(c) (ispunct(c) ? true : false) -#define b_isspace(c) (isspace(c) ? true : false) -#define b_isupper(c) (isupper(c) ? true : false) -#define b_isxdigit(c) (isxdigit(c) ? true : false) - -/* return true if char is uppercase or lowercase. */ -bool has_case(int c); - -/* Change case of character if possible. */ -int reverse_case(int c); - -/* return false if [c1-c2] is ambiguous for a caseless scanner. */ -bool range_covers_case(int c1, int c2); - -/* - * From "filter.c" - */ - -/** A single stdio filter to execute. - * The filter may be external, such as "sed", or it - * may be internal, as a function call. - */ -struct filter { - int (*filter_func)(struct filter *); /**< internal filter function */ - void *extra; /**< extra data passed to filter_func */ - int argc; /**< arg count */ - const char **argv; /**< arg vector, \0-terminated */ - struct filter *next; /**< next filter or NULL */ -}; - -/* output filter chain */ -extern struct filter *output_chain; -extern struct filter *filter_create_ext PROTO((struct filter * chain, - const char *cmd, ...)); -struct filter *filter_create_int PROTO((struct filter * chain, - int (*filter_func)(struct filter *), - void *extra)); -extern bool filter_apply_chain PROTO((struct filter * chain)); -extern int filter_truncate(struct filter *chain, int max_len); -extern int filter_tee_header PROTO((struct filter * chain)); -extern int filter_fix_linedirs PROTO((struct filter * chain)); - -/* - * From "regex.c" - */ - -extern regex_t regex_linedir, regex_blank_line; -bool flex_init_regex(void); -void flex_regcomp(regex_t *preg, const char *regex, int cflags); -char *regmatch_dup(regmatch_t *m, const char *src); -char *regmatch_cpy(regmatch_t *m, char *dest, const char *src); -int regmatch_len(regmatch_t *m); -int regmatch_strtol(regmatch_t *m, const char *src, char **endptr, int base); -bool regmatch_empty(regmatch_t *m); - -/* From "scanflags.h" */ -typedef unsigned int scanflags_t; -extern scanflags_t *_sf_stk; -extern size_t _sf_top_ix, _sf_max; /**< stack of scanner flags. */ -#define _SF_CASE_INS 0x0001 -#define _SF_DOT_ALL 0x0002 -#define _SF_SKIP_WS 0x0004 -#define sf_top() (_sf_stk[_sf_top_ix]) -#define sf_case_ins() (sf_top() & _SF_CASE_INS) -#define sf_dot_all() (sf_top() & _SF_DOT_ALL) -#define sf_skip_ws() (sf_top() & _SF_SKIP_WS) -#define sf_set_case_ins(X) \ - ((X) ? (sf_top() |= _SF_CASE_INS) : (sf_top() &= ~_SF_CASE_INS)) -#define sf_set_dot_all(X) \ - ((X) ? (sf_top() |= _SF_DOT_ALL) : (sf_top() &= ~_SF_DOT_ALL)) -#define sf_set_skip_ws(X) \ - ((X) ? (sf_top() |= _SF_SKIP_WS) : (sf_top() &= ~_SF_SKIP_WS)) -extern void sf_init(void); -extern void sf_push(void); -extern void sf_pop(void); - -#endif /* not defined FLEXDEF_H */ diff --git a/third_party/lex/flexint.h b/third_party/lex/flexint.h deleted file mode 100644 index 91f3bbba..00000000 --- a/third_party/lex/flexint.h +++ /dev/null @@ -1,67 +0,0 @@ -/* clang-format off */ -/* $OpenBSD: flexint.h,v 1.1 2015/11/19 19:43:40 tedu Exp $ */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include "libc/limits.h" - -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ diff --git a/third_party/lex/gen.c b/third_party/lex/gen.c deleted file mode 100644 index 0a9e9262..00000000 --- a/third_party/lex/gen.c +++ /dev/null @@ -1,2145 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -/* $OpenBSD: gen.c,v 1.15 2015/11/19 23:28:03 tedu Exp $ */ - -/* gen - actual generation (writing) of flex scanners */ - -/* 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. */ - -#include "flexdef.h" -#include "libc/mem/mem.h" -#include "libc/fmt/fmt.h" -#include "libc/fmt/fmt.h" -#include "libc/str/str.h" -#include "tables.h" - - -/* declare functions that have forward references */ - -/* void gen_next_state PROTO((int)); */ -void genecs PROTO((void)); -/* void indent_put2s PROTO((const char *, const char *)); */ -/* void indent_puts PROTO((const char *)); */ - - -static int indent_level = 0; /* each level is 8 spaces */ - -#define indent_up() (++indent_level) -#define indent_down() (--indent_level) -#define set_indent(indent_val) indent_level = indent_val - -/* Almost everything is done in terms of arrays starting at 1, so provide - * a null entry for the zero element of all C arrays. (The exception - * to this is that the fast table representation generally uses the - * 0 elements of its arrays, too.) - */ - -static const char * -get_int16_decl(void) -{ - return (gentables) - ? "static yyconst flex_int16_t %s[%d] =\n { 0,\n" - : "static yyconst flex_int16_t * %s = 0;\n"; -} - - -static const char * -get_int32_decl(void) -{ - return (gentables) - ? "static yyconst flex_int32_t %s[%d] =\n { 0,\n" - : "static yyconst flex_int32_t * %s = 0;\n"; -} - -static const char * -get_state_decl(void) -{ - return (gentables) - ? "static yyconst yy_state_type %s[%d] =\n { 0,\n" - : "static yyconst yy_state_type * %s = 0;\n"; -} - -/* Indent to the current level. */ - -void -do_indent() -{ - int i = indent_level * 8; - - while (i >= 8) { - outc('\t'); - i -= 8; - } - - while (i > 0) { - outc(' '); - --i; - } -} - - -/** Make the table for possible eol matches. - * @return the newly allocated rule_can_match_eol table - */ -static struct yytbl_data * -mkeoltbl(void) -{ - int i; - flex_int8_t *tdata = NULL; - struct yytbl_data *tbl; - - tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(tbl, YYTD_ID_RULE_CAN_MATCH_EOL); - tbl->td_flags = YYTD_DATA8; - tbl->td_lolen = num_rules + 1; - tbl->td_data = tdata = - calloc(tbl->td_lolen, sizeof(flex_int8_t)); - - for (i = 1; i <= num_rules; i++) - tdata[i] = rule_has_nl[i] ? 1 : 0; - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", - "flex_int32_t"); - return tbl; -} - -/* Generate the table for possible eol matches. */ -static void -geneoltbl() -{ - int i; - - outn("m4_ifdef( [[M4_YY_USE_LINENO]],[["); - outn("/* Table of booleans, true if rule could match eol. */"); - out_str_dec(get_int32_decl(), "yy_rule_can_match_eol", - num_rules + 1); - - if (gentables) { - for (i = 1; i <= num_rules; i++) { - out_dec("%d, ", rule_has_nl[i] ? 1 : 0); - /* format nicely, 20 numbers per line. */ - if ((i % 20) == 19) - out("\n "); - } - out(" };\n"); - } - outn("]])"); -} - - -/* Generate the code to keep backing-up information. */ - -void -gen_backing_up() -{ - if (reject || num_backing_up == 0) - return; - - if (fullspd) - indent_puts("if ( yy_current_state[-1].yy_nxt )"); - else - indent_puts("if ( yy_accept[yy_current_state] )"); - - indent_up(); - indent_puts("{"); - indent_puts("YY_G(yy_last_accepting_state) = yy_current_state;"); - indent_puts("YY_G(yy_last_accepting_cpos) = yy_cp;"); - indent_puts("}"); - indent_down(); -} - - -/* Generate the code to perform the backing up. */ - -void -gen_bu_action() -{ - if (reject || num_backing_up == 0) - return; - - set_indent(3); - - indent_puts("case 0: /* must back up */"); - indent_puts("/* undo the effects of YY_DO_BEFORE_ACTION */"); - indent_puts("*yy_cp = YY_G(yy_hold_char);"); - - if (fullspd || fulltbl) - indent_puts("yy_cp = YY_G(yy_last_accepting_cpos) + 1;"); - else - /* - * Backing-up info for compressed tables is taken \after/ - * yy_cp has been incremented for the next state. - */ - indent_puts("yy_cp = YY_G(yy_last_accepting_cpos);"); - - indent_puts("yy_current_state = YY_G(yy_last_accepting_state);"); - indent_puts("goto yy_find_action;"); - outc('\n'); - - set_indent(0); -} - -/** mkctbl - make full speed compressed transition table - * This is an array of structs; each struct a pair of integers. - * You should call mkssltbl() immediately after this. - * Then, I think, mkecstbl(). Arrrg. - * @return the newly allocated trans table - */ - -static struct yytbl_data * -mkctbl(void) -{ - int i; - struct yytbl_data *tbl = NULL; - flex_int32_t *tdata = NULL, curr = 0; - int end_of_buffer_action = num_rules + 1; - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n", - ((tblend + numecs + 1) >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - - tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(tbl, YYTD_ID_TRANSITION); - tbl->td_flags = YYTD_DATA32 | YYTD_STRUCT; - tbl->td_hilen = 0; - tbl->td_lolen = tblend + numecs + 1; /* number of structs */ - - tbl->td_data = tdata = - calloc(tbl->td_lolen * 2, sizeof(flex_int32_t)); - - /* - * We want the transition to be represented as the offset to the next - * state, not the actual state number, which is what it currently is. - * The offset is base[nxt[i]] - (base of current state)]. That's - * just the difference between the starting points of the two - * involved states (to - from). - * - * First, though, we need to find some way to put in our end-of-buffer - * flags and states. We do this by making a state with absolutely no - * transitions. We put it at the end of the table. - */ - - /* - * We need to have room in nxt/chk for two more slots: One for the - * action and one for the end-of-buffer transition. We now *assume* - * that we're guaranteed the only character we'll try to index this - * nxt/chk pair with is EOB, i.e., 0, so we don't have to make sure - * there's room for jam entries for other characters. - */ - - while (tblend + 2 >= current_max_xpairs) - expand_nxt_chk(); - - while (lastdfa + 1 >= current_max_dfas) - increase_max_dfas(); - - base[lastdfa + 1] = tblend + 2; - nxt[tblend + 1] = end_of_buffer_action; - chk[tblend + 1] = numecs + 1; - chk[tblend + 2] = 1; /* anything but EOB */ - - /* So that "make test" won't show arb. differences. */ - nxt[tblend + 2] = 0; - - /* - * Make sure every state has an end-of-buffer transition and an - * action #. - */ - for (i = 0; i <= lastdfa; ++i) { - int anum = dfaacc[i].dfaacc_state; - int offset = base[i]; - - chk[offset] = EOB_POSITION; - chk[offset - 1] = ACTION_POSITION; - nxt[offset - 1] = anum; /* action number */ - } - - for (i = 0; i <= tblend; ++i) { - if (chk[i] == EOB_POSITION) { - tdata[curr++] = 0; - tdata[curr++] = base[lastdfa + 1] - i; - } else if (chk[i] == ACTION_POSITION) { - tdata[curr++] = 0; - tdata[curr++] = nxt[i]; - } else if (chk[i] > numecs || chk[i] == 0) { - tdata[curr++] = 0; - tdata[curr++] = 0; - } else { /* verify, transition */ - - tdata[curr++] = chk[i]; - tdata[curr++] = base[nxt[i]] - (i - chk[i]); - } - } - - - /* Here's the final, end-of-buffer state. */ - tdata[curr++] = chk[tblend + 1]; - tdata[curr++] = nxt[tblend + 1]; - - tdata[curr++] = chk[tblend + 2]; - tdata[curr++] = nxt[tblend + 2]; - - return tbl; -} - - -/** Make start_state_list table. - * @return the newly allocated start_state_list table - */ -static struct yytbl_data * -mkssltbl(void) -{ - struct yytbl_data *tbl = NULL; - flex_int32_t *tdata = NULL; - flex_int32_t i; - - tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(tbl, YYTD_ID_START_STATE_LIST); - tbl->td_flags = YYTD_DATA32 | YYTD_PTRANS; - tbl->td_hilen = 0; - tbl->td_lolen = lastsc * 2 + 1; - - tbl->td_data = tdata = - calloc(tbl->td_lolen, sizeof(flex_int32_t)); - - for (i = 0; i <= lastsc * 2; ++i) - tdata[i] = base[i]; - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n", - "struct yy_trans_info*"); - - return tbl; -} - - - -/* genctbl - generates full speed compressed transition table */ - -void -genctbl() -{ - int i; - int end_of_buffer_action = num_rules + 1; - - /* Table of verify for transition and offset to next state. */ - if (gentables) - out_dec("static yyconst struct yy_trans_info yy_transition[%d] =\n {\n", tblend + numecs + 1); - else - outn("static yyconst struct yy_trans_info *yy_transition = 0;"); - - /* - * We want the transition to be represented as the offset to the next - * state, not the actual state number, which is what it currently is. - * The offset is base[nxt[i]] - (base of current state)]. That's - * just the difference between the starting points of the two - * involved states (to - from). - * - * First, though, we need to find some way to put in our end-of-buffer - * flags and states. We do this by making a state with absolutely no - * transitions. We put it at the end of the table. - */ - - /* - * We need to have room in nxt/chk for two more slots: One for the - * action and one for the end-of-buffer transition. We now *assume* - * that we're guaranteed the only character we'll try to index this - * nxt/chk pair with is EOB, i.e., 0, so we don't have to make sure - * there's room for jam entries for other characters. - */ - - while (tblend + 2 >= current_max_xpairs) - expand_nxt_chk(); - - while (lastdfa + 1 >= current_max_dfas) - increase_max_dfas(); - - base[lastdfa + 1] = tblend + 2; - nxt[tblend + 1] = end_of_buffer_action; - chk[tblend + 1] = numecs + 1; - chk[tblend + 2] = 1; /* anything but EOB */ - - /* So that "make test" won't show arb. differences. */ - nxt[tblend + 2] = 0; - - /* - * Make sure every state has an end-of-buffer transition and an - * action #. - */ - for (i = 0; i <= lastdfa; ++i) { - int anum = dfaacc[i].dfaacc_state; - int offset = base[i]; - - chk[offset] = EOB_POSITION; - chk[offset - 1] = ACTION_POSITION; - nxt[offset - 1] = anum; /* action number */ - } - - for (i = 0; i <= tblend; ++i) { - if (chk[i] == EOB_POSITION) - transition_struct_out(0, base[lastdfa + 1] - i); - - else if (chk[i] == ACTION_POSITION) - transition_struct_out(0, nxt[i]); - - else if (chk[i] > numecs || chk[i] == 0) - transition_struct_out(0, 0); /* unused slot */ - - else /* verify, transition */ - transition_struct_out(chk[i], - base[nxt[i]] - (i - - chk[i])); - } - - - /* Here's the final, end-of-buffer state. */ - transition_struct_out(chk[tblend + 1], nxt[tblend + 1]); - transition_struct_out(chk[tblend + 2], nxt[tblend + 2]); - - if (gentables) - outn(" };\n"); - - /* Table of pointers to start states. */ - if (gentables) - out_dec("static yyconst struct yy_trans_info *yy_start_state_list[%d] =\n", lastsc * 2 + 1); - else - outn("static yyconst struct yy_trans_info **yy_start_state_list =0;"); - - if (gentables) { - outn(" {"); - - for (i = 0; i <= lastsc * 2; ++i) - out_dec(" &yy_transition[%d],\n", base[i]); - - dataend(); - } - if (useecs) - genecs(); -} - - -/* mkecstbl - Make equivalence-class tables. */ - -struct yytbl_data * -mkecstbl(void) -{ - int i; - struct yytbl_data *tbl = NULL; - flex_int32_t *tdata = NULL; - - tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(tbl, YYTD_ID_EC); - tbl->td_flags |= YYTD_DATA32; - tbl->td_hilen = 0; - tbl->td_lolen = csize; - - tbl->td_data = tdata = - calloc(tbl->td_lolen, sizeof(flex_int32_t)); - - for (i = 1; i < csize; ++i) { - ecgroup[i] = ABS(ecgroup[i]); - tdata[i] = ecgroup[i]; - } - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", - "flex_int32_t"); - - return tbl; -} - -/* Generate equivalence-class tables. */ - -void -genecs() -{ - int i, j; - int numrows; - - out_str_dec(get_int32_decl(), "yy_ec", csize); - - for (i = 1; i < csize; ++i) { - ecgroup[i] = ABS(ecgroup[i]); - mkdata(ecgroup[i]); - } - - dataend(); - - if (trace) { - fputs(_("\n\nEquivalence Classes:\n\n"), stderr); - - numrows = csize / 8; - - for (j = 0; j < numrows; ++j) { - for (i = j; i < csize; i = i + numrows) { - fprintf(stderr, "%4s = %-2d", - readable_form(i), ecgroup[i]); - - putc(' ', stderr); - } - - putc('\n', stderr); - } - } -} - - -/* Generate the code to find the action number. */ - -void -gen_find_action() -{ - if (fullspd) - indent_puts("yy_act = yy_current_state[-1].yy_nxt;"); - - else if (fulltbl) - indent_puts("yy_act = yy_accept[yy_current_state];"); - - else if (reject) { - indent_puts("yy_current_state = *--YY_G(yy_state_ptr);"); - indent_puts("YY_G(yy_lp) = yy_accept[yy_current_state];"); - - outn("find_rule: /* we branch to this label when backing up */"); - - indent_puts - ("for ( ; ; ) /* until we find what rule we matched */"); - - indent_up(); - - indent_puts("{"); - - indent_puts - ("if ( YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1] )"); - indent_up(); - indent_puts("{"); - indent_puts("yy_act = yy_acclist[YY_G(yy_lp)];"); - - if (variable_trailing_context_rules) { - indent_puts - ("if ( yy_act & YY_TRAILING_HEAD_MASK ||"); - indent_puts(" YY_G(yy_looking_for_trail_begin) )"); - indent_up(); - indent_puts("{"); - - indent_puts - ("if ( yy_act == YY_G(yy_looking_for_trail_begin) )"); - indent_up(); - indent_puts("{"); - indent_puts("YY_G(yy_looking_for_trail_begin) = 0;"); - indent_puts("yy_act &= ~YY_TRAILING_HEAD_MASK;"); - indent_puts("break;"); - indent_puts("}"); - indent_down(); - - indent_puts("}"); - indent_down(); - - indent_puts - ("else if ( yy_act & YY_TRAILING_MASK )"); - indent_up(); - indent_puts("{"); - indent_puts - ("YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK;"); - indent_puts - ("YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK;"); - - if (real_reject) { - /* - * Remember matched text in case we back up - * due to REJECT. - */ - indent_puts - ("YY_G(yy_full_match) = yy_cp;"); - indent_puts - ("YY_G(yy_full_state) = YY_G(yy_state_ptr);"); - indent_puts("YY_G(yy_full_lp) = YY_G(yy_lp);"); - } - indent_puts("}"); - indent_down(); - - indent_puts("else"); - indent_up(); - indent_puts("{"); - indent_puts("YY_G(yy_full_match) = yy_cp;"); - indent_puts - ("YY_G(yy_full_state) = YY_G(yy_state_ptr);"); - indent_puts("YY_G(yy_full_lp) = YY_G(yy_lp);"); - indent_puts("break;"); - indent_puts("}"); - indent_down(); - - indent_puts("++YY_G(yy_lp);"); - indent_puts("goto find_rule;"); - } else { - /* - * Remember matched text in case we back up due to - * trailing context plus REJECT. - */ - indent_up(); - indent_puts("{"); - indent_puts("YY_G(yy_full_match) = yy_cp;"); - indent_puts("break;"); - indent_puts("}"); - indent_down(); - } - - indent_puts("}"); - indent_down(); - - indent_puts("--yy_cp;"); - - /* - * We could consolidate the following two lines with those at - * the beginning, but at the cost of complaints that we're - * branching inside a loop. - */ - indent_puts("yy_current_state = *--YY_G(yy_state_ptr);"); - indent_puts("YY_G(yy_lp) = yy_accept[yy_current_state];"); - - indent_puts("}"); - - indent_down(); - } else { /* compressed */ - indent_puts("yy_act = yy_accept[yy_current_state];"); - - if (interactive && !reject) { - /* - * Do the guaranteed-needed backing up to figure out - * the match. - */ - indent_puts("if ( yy_act == 0 )"); - indent_up(); - indent_puts("{ /* have to back up */"); - indent_puts - ("yy_cp = YY_G(yy_last_accepting_cpos);"); - indent_puts - ("yy_current_state = YY_G(yy_last_accepting_state);"); - indent_puts - ("yy_act = yy_accept[yy_current_state];"); - indent_puts("}"); - indent_down(); - } - } -} - -/* mkftbl - make the full table and return the struct . - * you should call mkecstbl() after this. - */ - -struct yytbl_data * -mkftbl(void) -{ - int i; - int end_of_buffer_action = num_rules + 1; - struct yytbl_data *tbl; - flex_int32_t *tdata = NULL; - - tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(tbl, YYTD_ID_ACCEPT); - tbl->td_flags |= YYTD_DATA32; - tbl->td_hilen = 0; /* it's a one-dimensional array */ - tbl->td_lolen = lastdfa + 1; - - tbl->td_data = tdata = - calloc(tbl->td_lolen, sizeof(flex_int32_t)); - - dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; - - for (i = 1; i <= lastdfa; ++i) { - int anum = dfaacc[i].dfaacc_state; - - tdata[i] = anum; - - if (trace && anum) - fprintf(stderr, _("state # %d accepts: [%d]\n"), - i, anum); - } - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - return tbl; -} - - -/* genftbl - generate full transition table */ - -void -genftbl() -{ - int i; - int end_of_buffer_action = num_rules + 1; - - out_str_dec(long_align ? get_int32_decl() : get_int16_decl(), - "yy_accept", lastdfa + 1); - - dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; - - for (i = 1; i <= lastdfa; ++i) { - int anum = dfaacc[i].dfaacc_state; - - mkdata(anum); - - if (trace && anum) - fprintf(stderr, _("state # %d accepts: [%d]\n"), - i, anum); - } - - dataend(); - - if (useecs) - genecs(); - - /* - * Don't have to dump the actual full table entries - they were - * created on-the-fly. - */ -} - - -/* Generate the code to find the next compressed-table state. */ - -void -gen_next_compressed_state(char_map) - char *char_map; -{ - indent_put2s("YY_CHAR yy_c = %s;", char_map); - - /* - * Save the backing-up info \before/ computing the next state because - * we always compute one more state than needed - we always proceed - * until we reach a jam state - */ - gen_backing_up(); - - indent_puts - ("while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )"); - indent_up(); - indent_puts("{"); - indent_puts("yy_current_state = (int) yy_def[yy_current_state];"); - - if (usemecs) { - /* - * We've arrange it so that templates are never chained to - * one another. This means we can afford to make a very - * simple test to see if we need to convert to yy_c's - * meta-equivalence class without worrying about erroneously - * looking up the meta-equivalence class twice - */ - do_indent(); - - /* lastdfa + 2 is the beginning of the templates */ - out_dec("if ( yy_current_state >= %d )\n", lastdfa + 2); - - indent_up(); - indent_puts("yy_c = yy_meta[(unsigned int) yy_c];"); - indent_down(); - } - indent_puts("}"); - indent_down(); - - indent_puts - ("yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];"); -} - - -/* Generate the code to find the next match. */ - -void -gen_next_match() -{ - /* - * NOTE - changes in here should be reflected in gen_next_state() and - * gen_NUL_trans(). - */ - char *char_map = useecs ? - "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)"; - - char *char_map_2 = useecs ? - "yy_ec[YY_SC_TO_UI(*++yy_cp)] " : "YY_SC_TO_UI(*++yy_cp)"; - - if (fulltbl) { - if (gentables) - indent_put2s - ("while ( (yy_current_state = yy_nxt[yy_current_state][ %s ]) > 0 )", - char_map); - else - indent_put2s - ("while ( (yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s ]) > 0 )", - char_map); - - indent_up(); - - if (num_backing_up > 0) { - indent_puts("{"); - gen_backing_up(); - outc('\n'); - } - indent_puts("++yy_cp;"); - - if (num_backing_up > 0) - indent_puts("}"); - - indent_down(); - - outc('\n'); - indent_puts("yy_current_state = -yy_current_state;"); - } else if (fullspd) { - indent_puts("{"); - indent_puts - ("yyconst struct yy_trans_info *yy_trans_info;\n"); - indent_puts("YY_CHAR yy_c;\n"); - indent_put2s("for ( yy_c = %s;", char_map); - indent_puts - (" (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->"); - indent_puts("yy_verify == yy_c;"); - indent_put2s(" yy_c = %s )", char_map_2); - - indent_up(); - - if (num_backing_up > 0) - indent_puts("{"); - - indent_puts("yy_current_state += yy_trans_info->yy_nxt;"); - - if (num_backing_up > 0) { - outc('\n'); - gen_backing_up(); - indent_puts("}"); - } - indent_down(); - indent_puts("}"); - } else { /* compressed */ - indent_puts("do"); - - indent_up(); - indent_puts("{"); - - gen_next_state(false); - - indent_puts("++yy_cp;"); - - - indent_puts("}"); - indent_down(); - - do_indent(); - - if (interactive) - out_dec("while ( yy_base[yy_current_state] != %d );\n", jambase); - else - out_dec("while ( yy_current_state != %d );\n", - jamstate); - - if (!reject && !interactive) { - /* - * Do the guaranteed-needed backing up to figure out - * the match. - */ - indent_puts - ("yy_cp = YY_G(yy_last_accepting_cpos);"); - indent_puts - ("yy_current_state = YY_G(yy_last_accepting_state);"); - } - } -} - - -/* Generate the code to find the next state. */ - -void -gen_next_state(worry_about_NULs) - int worry_about_NULs; -{ /* NOTE - changes in here should be reflected - * in gen_next_match() */ - char char_map[256]; - - if (worry_about_NULs && !nultrans) { - if (useecs) - snprintf(char_map, sizeof(char_map), - "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)", - NUL_ec); - else - snprintf(char_map, sizeof(char_map), - "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)", - NUL_ec); - } else - strlcpy(char_map, useecs ? - "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)", - sizeof char_map); - - if (worry_about_NULs && nultrans) { - if (!fulltbl && !fullspd) - /* Compressed tables back up *before* they match. */ - gen_backing_up(); - - indent_puts("if ( *yy_cp )"); - indent_up(); - indent_puts("{"); - } - if (fulltbl) { - if (gentables) - indent_put2s - ("yy_current_state = yy_nxt[yy_current_state][%s];", - char_map); - else - indent_put2s - ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s];", - char_map); - } else if (fullspd) - indent_put2s - ("yy_current_state += yy_current_state[%s].yy_nxt;", - char_map); - - else - gen_next_compressed_state(char_map); - - if (worry_about_NULs && nultrans) { - - indent_puts("}"); - indent_down(); - indent_puts("else"); - indent_up(); - indent_puts - ("yy_current_state = yy_NUL_trans[yy_current_state];"); - indent_down(); - } - if (fullspd || fulltbl) - gen_backing_up(); - - if (reject) - indent_puts("*YY_G(yy_state_ptr)++ = yy_current_state;"); -} - - -/* Generate the code to make a NUL transition. */ - -void -gen_NUL_trans() -{ /* NOTE - changes in here should be reflected - * in gen_next_match() */ - /* - * Only generate a definition for "yy_cp" if we'll generate code that - * uses it. Otherwise lint and the like complain. - */ - int need_backing_up = (num_backing_up > 0 && !reject); - - if (need_backing_up && (!nultrans || fullspd || fulltbl)) - /* - * We're going to need yy_cp lying around for the call below - * to gen_backing_up(). - */ - indent_puts("char *yy_cp = YY_G(yy_c_buf_p);"); - - outc('\n'); - - if (nultrans) { - indent_puts - ("yy_current_state = yy_NUL_trans[yy_current_state];"); - indent_puts("yy_is_jam = (yy_current_state == 0);"); - } else if (fulltbl) { - do_indent(); - if (gentables) - out_dec("yy_current_state = yy_nxt[yy_current_state][%d];\n", NUL_ec); - else - out_dec("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %d];\n", NUL_ec); - indent_puts("yy_is_jam = (yy_current_state <= 0);"); - } else if (fullspd) { - do_indent(); - out_dec("int yy_c = %d;\n", NUL_ec); - - indent_puts - ("yyconst struct yy_trans_info *yy_trans_info;\n"); - indent_puts - ("yy_trans_info = &yy_current_state[(unsigned int) yy_c];"); - indent_puts("yy_current_state += yy_trans_info->yy_nxt;"); - - indent_puts - ("yy_is_jam = (yy_trans_info->yy_verify != yy_c);"); - } else { - char NUL_ec_str[20]; - - snprintf(NUL_ec_str, sizeof(NUL_ec_str), "%d", NUL_ec); - gen_next_compressed_state(NUL_ec_str); - - do_indent(); - out_dec("yy_is_jam = (yy_current_state == %d);\n", - jamstate); - - if (reject) { - /* - * Only stack this state if it's a transition we - * actually make. If we stack it on a jam, then the - * state stack and yy_c_buf_p get out of sync. - */ - indent_puts("if ( ! yy_is_jam )"); - indent_up(); - indent_puts - ("*YY_G(yy_state_ptr)++ = yy_current_state;"); - indent_down(); - } - } - - /* - * If we've entered an accepting state, back up; note that compressed - * tables have *already* done such backing up, so we needn't bother - * with it again. - */ - if (need_backing_up && (fullspd || fulltbl)) { - outc('\n'); - indent_puts("if ( ! yy_is_jam )"); - indent_up(); - indent_puts("{"); - gen_backing_up(); - indent_puts("}"); - indent_down(); - } -} - - -/* Generate the code to find the start state. */ - -void -gen_start_state() -{ - if (fullspd) { - if (bol_needed) { - indent_puts - ("yy_current_state = yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];"); - } else - indent_puts - ("yy_current_state = yy_start_state_list[YY_G(yy_start)];"); - } else { - indent_puts("yy_current_state = YY_G(yy_start);"); - - if (bol_needed) - indent_puts("yy_current_state += YY_AT_BOL();"); - - if (reject) { - /* Set up for storing up states. */ - outn("m4_ifdef( [[M4_YY_USES_REJECT]],\n[["); - indent_puts - ("YY_G(yy_state_ptr) = YY_G(yy_state_buf);"); - indent_puts - ("*YY_G(yy_state_ptr)++ = yy_current_state;"); - outn("]])"); - } - } -} - - -/* gentabs - generate data statements for the transition tables */ - -void -gentabs() -{ - int i, j, k, *accset, nacc, *acc_array, total_states; - int end_of_buffer_action = num_rules + 1; - struct yytbl_data *yyacc_tbl = 0, *yymeta_tbl = 0, *yybase_tbl = 0, *yydef_tbl = 0, - *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl = 0; - flex_int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0, *yynxt_data = 0, - *yychk_data = 0, *yyacclist_data = 0; - flex_int32_t yybase_curr = 0, yyacclist_curr = 0, yyacc_curr = 0; - - acc_array = allocate_integer_array(current_max_dfas); - nummt = 0; - - /* - * The compressed table format jams by entering the "jam state", - * losing information about the previous state in the process. In - * order to recover the previous state, we effectively need to keep - * backing-up information. - */ - ++num_backing_up; - - if (reject) { - /* - * Write out accepting list and pointer list. - * - * First we generate the "yy_acclist" array. In the process, we - * compute the indices that will go into the "yy_accept" - * array, and save the indices in the dfaacc array. - */ - int EOB_accepting_list[2]; - - /* Set up accepting structures for the End Of Buffer state. */ - EOB_accepting_list[0] = 0; - EOB_accepting_list[1] = end_of_buffer_action; - accsiz[end_of_buffer_state] = 1; - dfaacc[end_of_buffer_state].dfaacc_set = - EOB_accepting_list; - - out_str_dec(long_align ? get_int32_decl() : - get_int16_decl(), "yy_acclist", MAX(numas, - 1) + 1); - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - - yyacclist_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yyacclist_tbl, YYTD_ID_ACCLIST); - yyacclist_tbl->td_lolen = MAX(numas, 1) + 1; - yyacclist_tbl->td_data = yyacclist_data = - calloc(yyacclist_tbl->td_lolen, sizeof(flex_int32_t)); - yyacclist_curr = 1; - - j = 1; /* index into "yy_acclist" array */ - - for (i = 1; i <= lastdfa; ++i) { - acc_array[i] = j; - - if (accsiz[i] != 0) { - accset = dfaacc[i].dfaacc_set; - nacc = accsiz[i]; - - if (trace) - fprintf(stderr, - _("state # %d accepts: "), - i); - - for (k = 1; k <= nacc; ++k) { - int accnum = accset[k]; - - ++j; - - if (variable_trailing_context_rules - && !(accnum & - YY_TRAILING_HEAD_MASK) - && accnum > 0 - && accnum <= num_rules - && rule_type[accnum] == - RULE_VARIABLE) { - /* - * Special hack to flag - * accepting number as part - * of trailing context rule. - */ - accnum |= YY_TRAILING_MASK; - } - mkdata(accnum); - yyacclist_data[yyacclist_curr++] = accnum; - - if (trace) { - fprintf(stderr, "[%d]", - accset[k]); - - if (k < nacc) - fputs(", ", - stderr); - else - putc('\n', - stderr); - } - } - } - } - - /* add accepting number for the "jam" state */ - acc_array[i] = j; - - dataend(); - if (tablesext) { - yytbl_data_compress(yyacclist_tbl); - if (yytbl_data_fwrite(&tableswr, yyacclist_tbl) < 0) - flexerror(_("Could not write yyacclist_tbl")); - yytbl_data_destroy(yyacclist_tbl); - yyacclist_tbl = NULL; - } - } else { - dfaacc[end_of_buffer_state].dfaacc_state = - end_of_buffer_action; - - for (i = 1; i <= lastdfa; ++i) - acc_array[i] = dfaacc[i].dfaacc_state; - - /* add accepting number for jam state */ - acc_array[i] = 0; - } - - /* Begin generating yy_accept */ - - /* - * Spit out "yy_accept" array. If we're doing "reject", it'll be - * pointers into the "yy_acclist" array. Otherwise it's actual - * accepting numbers. In either case, we just dump the numbers. - */ - - /* - * "lastdfa + 2" is the size of "yy_accept"; includes room for C - * arrays beginning at 0 and for "jam" state. - */ - k = lastdfa + 2; - - if (reject) - /* - * We put a "cap" on the table associating lists of accepting - * numbers with state numbers. This is needed because we - * tell where the end of an accepting list is by looking at - * where the list for the next state starts. - */ - ++k; - - out_str_dec(long_align ? get_int32_decl() : get_int16_decl(), - "yy_accept", k); - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - - yyacc_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yyacc_tbl, YYTD_ID_ACCEPT); - yyacc_tbl->td_lolen = k; - yyacc_tbl->td_data = yyacc_data = - calloc(yyacc_tbl->td_lolen, sizeof(flex_int32_t)); - yyacc_curr = 1; - - for (i = 1; i <= lastdfa; ++i) { - mkdata(acc_array[i]); - yyacc_data[yyacc_curr++] = acc_array[i]; - - if (!reject && trace && acc_array[i]) - fprintf(stderr, _("state # %d accepts: [%d]\n"), - i, acc_array[i]); - } - - /* Add entry for "jam" state. */ - mkdata(acc_array[i]); - yyacc_data[yyacc_curr++] = acc_array[i]; - - if (reject) { - /* Add "cap" for the list. */ - mkdata(acc_array[i]); - yyacc_data[yyacc_curr++] = acc_array[i]; - } - dataend(); - if (tablesext) { - yytbl_data_compress(yyacc_tbl); - if (yytbl_data_fwrite(&tableswr, yyacc_tbl) < 0) - flexerror(_("Could not write yyacc_tbl")); - yytbl_data_destroy(yyacc_tbl); - yyacc_tbl = NULL; - } - /* End generating yy_accept */ - - if (useecs) { - - genecs(); - if (tablesext) { - struct yytbl_data *tbl; - - tbl = mkecstbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_("Could not write ecstbl")); - yytbl_data_destroy(tbl); - tbl = 0; - } - } - if (usemecs) { - /* Begin generating yy_meta */ - /* - * Write out meta-equivalence classes (used to index - * templates with). - */ - flex_int32_t *yymecs_data = NULL; - yymeta_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yymeta_tbl, YYTD_ID_META); - yymeta_tbl->td_lolen = numecs + 1; - yymeta_tbl->td_data = yymecs_data = - calloc(yymeta_tbl->td_lolen, - sizeof(flex_int32_t)); - - if (trace) - fputs(_("\n\nMeta-Equivalence Classes:\n"), - stderr); - - out_str_dec(get_int32_decl(), "yy_meta", numecs + 1); - buf_prints(&yydmap_buf, - "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", - "flex_int32_t"); - - for (i = 1; i <= numecs; ++i) { - if (trace) - fprintf(stderr, "%d = %d\n", - i, ABS(tecbck[i])); - - mkdata(ABS(tecbck[i])); - yymecs_data[i] = ABS(tecbck[i]); - } - - dataend(); - if (tablesext) { - yytbl_data_compress(yymeta_tbl); - if (yytbl_data_fwrite(&tableswr, yymeta_tbl) < 0) - flexerror(_ - ("Could not write yymeta_tbl")); - yytbl_data_destroy(yymeta_tbl); - yymeta_tbl = NULL; - } - /* End generating yy_meta */ - } - total_states = lastdfa + numtemps; - - /* Begin generating yy_base */ - out_str_dec((tblend >= INT16_MAX || long_align) ? - get_int32_decl() : get_int16_decl(), - "yy_base", total_states + 1); - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", - (tblend >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - yybase_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yybase_tbl, YYTD_ID_BASE); - yybase_tbl->td_lolen = total_states + 1; - yybase_tbl->td_data = yybase_data = - calloc(yybase_tbl->td_lolen, - sizeof(flex_int32_t)); - yybase_curr = 1; - - for (i = 1; i <= lastdfa; ++i) { - int d = def[i]; - - if (base[i] == JAMSTATE) - base[i] = jambase; - - if (d == JAMSTATE) - def[i] = jamstate; - - else if (d < 0) { - /* Template reference. */ - ++tmpuses; - def[i] = lastdfa - d + 1; - } - mkdata(base[i]); - yybase_data[yybase_curr++] = base[i]; - } - - /* Generate jam state's base index. */ - mkdata(base[i]); - yybase_data[yybase_curr++] = base[i]; - - for (++i /* skip jam state */ ; i <= total_states; ++i) { - mkdata(base[i]); - yybase_data[yybase_curr++] = base[i]; - def[i] = jamstate; - } - - dataend(); - if (tablesext) { - yytbl_data_compress(yybase_tbl); - if (yytbl_data_fwrite(&tableswr, yybase_tbl) < 0) - flexerror(_("Could not write yybase_tbl")); - yytbl_data_destroy(yybase_tbl); - yybase_tbl = NULL; - } - /* End generating yy_base */ - - - /* Begin generating yy_def */ - out_str_dec((total_states >= INT16_MAX || long_align) ? - get_int32_decl() : get_int16_decl(), - "yy_def", total_states + 1); - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - - yydef_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yydef_tbl, YYTD_ID_DEF); - yydef_tbl->td_lolen = total_states + 1; - yydef_tbl->td_data = yydef_data = - calloc(yydef_tbl->td_lolen, sizeof(flex_int32_t)); - - for (i = 1; i <= total_states; ++i) { - mkdata(def[i]); - yydef_data[i] = def[i]; - } - - dataend(); - if (tablesext) { - yytbl_data_compress(yydef_tbl); - if (yytbl_data_fwrite(&tableswr, yydef_tbl) < 0) - flexerror(_("Could not write yydef_tbl")); - yytbl_data_destroy(yydef_tbl); - yydef_tbl = NULL; - } - /* End generating yy_def */ - - - /* Begin generating yy_nxt */ - out_str_dec((total_states >= INT16_MAX || long_align) ? - get_int32_decl() : get_int16_decl(), "yy_nxt", - tblend + 1); - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - - yynxt_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yynxt_tbl, YYTD_ID_NXT); - yynxt_tbl->td_lolen = tblend + 1; - yynxt_tbl->td_data = yynxt_data = - calloc(yynxt_tbl->td_lolen, sizeof(flex_int32_t)); - - for (i = 1; i <= tblend; ++i) { - /* - * Note, the order of the following test is important. If - * chk[i] is 0, then nxt[i] is undefined. - */ - if (chk[i] == 0 || nxt[i] == 0) - nxt[i] = jamstate; /* new state is the JAM state */ - - mkdata(nxt[i]); - yynxt_data[i] = nxt[i]; - } - - dataend(); - if (tablesext) { - yytbl_data_compress(yynxt_tbl); - if (yytbl_data_fwrite(&tableswr, yynxt_tbl) < 0) - flexerror(_("Could not write yynxt_tbl")); - yytbl_data_destroy(yynxt_tbl); - yynxt_tbl = NULL; - } - /* End generating yy_nxt */ - - /* Begin generating yy_chk */ - out_str_dec((total_states >= INT16_MAX || long_align) ? - get_int32_decl() : get_int16_decl(), "yy_chk", - tblend + 1); - - buf_prints(&yydmap_buf, - "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - - yychk_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yychk_tbl, YYTD_ID_CHK); - yychk_tbl->td_lolen = tblend + 1; - yychk_tbl->td_data = yychk_data = - calloc(yychk_tbl->td_lolen, sizeof(flex_int32_t)); - - for (i = 1; i <= tblend; ++i) { - if (chk[i] == 0) - ++nummt; - - mkdata(chk[i]); - yychk_data[i] = chk[i]; - } - - dataend(); - if (tablesext) { - yytbl_data_compress(yychk_tbl); - if (yytbl_data_fwrite(&tableswr, yychk_tbl) < 0) - flexerror(_("Could not write yychk_tbl")); - yytbl_data_destroy(yychk_tbl); - yychk_tbl = NULL; - } - /* End generating yy_chk */ - - free(acc_array); -} - - -/* Write out a formatted string (with a secondary string argument) at the - * current indentation level, adding a final newline. - */ - -void -indent_put2s(fmt, arg) - const char *fmt, *arg; -{ - do_indent(); - out_str(fmt, arg); - outn(""); -} - - -/* Write out a string at the current indentation level, adding a final - * newline. - */ - -void -indent_puts(str) - const char *str; -{ - do_indent(); - outn(str); -} - - -/* make_tables - generate transition tables and finishes generating output file - */ - -void -make_tables() -{ - int i; - int did_eof_rule = false; - struct yytbl_data *yynultrans_tbl; - - - skelout(); /* %% [2.0] - break point in skel */ - - /* - * First, take care of YY_DO_BEFORE_ACTION depending on yymore being - * used. - */ - set_indent(1); - - if (yymore_used && !yytext_is_array) { - indent_puts("YY_G(yytext_ptr) -= YY_G(yy_more_len); \\"); - indent_puts - ("yyleng = (size_t) (yy_cp - YY_G(yytext_ptr)); \\"); - } else - indent_puts("yyleng = (size_t) (yy_cp - yy_bp); \\"); - - /* Now also deal with copying yytext_ptr to yytext if needed. */ - skelout(); /* %% [3.0] - break point in skel */ - if (yytext_is_array) { - if (yymore_used) - indent_puts - ("if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \\"); - else - indent_puts("if ( yyleng >= YYLMAX ) \\"); - - indent_up(); - indent_puts - ("YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\"); - indent_down(); - - if (yymore_used) { - indent_puts - ("yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\"); - indent_puts("yyleng += YY_G(yy_more_offset); \\"); - indent_puts - ("YY_G(yy_prev_more_offset) = YY_G(yy_more_offset); \\"); - indent_puts("YY_G(yy_more_offset) = 0; \\"); - } else { - indent_puts - ("yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\"); - } - } - set_indent(0); - - skelout(); /* %% [4.0] - break point in skel */ - - - /* This is where we REALLY begin generating the tables. */ - - out_dec("#define YY_NUM_RULES %d\n", num_rules); - out_dec("#define YY_END_OF_BUFFER %d\n", num_rules + 1); - - if (fullspd) { - /* - * Need to define the transet type as a size large enough to - * hold the biggest offset. - */ - int total_table_size = tblend + numecs + 1; - char *trans_offset_type = - (total_table_size >= INT16_MAX || long_align) ? - "flex_int32_t" : "flex_int16_t"; - - set_indent(0); - indent_puts("struct yy_trans_info"); - indent_up(); - indent_puts("{"); - - /* - * We require that yy_verify and yy_nxt must be of the same - * size int. - */ - indent_put2s("%s yy_verify;", trans_offset_type); - - /* - * In cases where its sister yy_verify *is* a "yes, there is - * a transition", yy_nxt is the offset (in records) to the - * next state. In most cases where there is no transition, - * the value of yy_nxt is irrelevant. If yy_nxt is the -1th - * record of a state, though, then yy_nxt is the action - * number for that state. - */ - - indent_put2s("%s yy_nxt;", trans_offset_type); - indent_puts("};"); - indent_down(); - } else { - /* - * We generate a bogus 'struct yy_trans_info' data type so we - * can guarantee that it is always declared in the skel. This - * is so we can compile "sizeof(struct yy_trans_info)" in any - * scanner. - */ - indent_puts - ("/* This struct is not used in this scanner,"); - indent_puts(" but its presence is necessary. */"); - indent_puts("struct yy_trans_info"); - indent_up(); - indent_puts("{"); - indent_puts("flex_int32_t yy_verify;"); - indent_puts("flex_int32_t yy_nxt;"); - indent_puts("};"); - indent_down(); - } - - if (fullspd) { - genctbl(); - if (tablesext) { - struct yytbl_data *tbl; - - tbl = mkctbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_("Could not write ftbl")); - yytbl_data_destroy(tbl); - - tbl = mkssltbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_("Could not write ssltbl")); - yytbl_data_destroy(tbl); - tbl = 0; - - if (useecs) { - tbl = mkecstbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_ - ("Could not write ecstbl")); - yytbl_data_destroy(tbl); - tbl = 0; - } - } - } else if (fulltbl) { - genftbl(); - if (tablesext) { - struct yytbl_data *tbl; - - tbl = mkftbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_("Could not write ftbl")); - yytbl_data_destroy(tbl); - tbl = 0; - - if (useecs) { - tbl = mkecstbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_ - ("Could not write ecstbl")); - yytbl_data_destroy(tbl); - tbl = 0; - } - } - } else - gentabs(); - - if (do_yylineno) { - - geneoltbl(); - - if (tablesext) { - struct yytbl_data *tbl; - - tbl = mkeoltbl(); - yytbl_data_compress(tbl); - if (yytbl_data_fwrite(&tableswr, tbl) < 0) - flexerror(_("Could not write eoltbl")); - yytbl_data_destroy(tbl); - tbl = 0; - } - } - /* - * Definitions for backing up. We don't need them if REJECT is being - * used because then we use an alternative backin-up technique - * instead. - */ - if (num_backing_up > 0 && !reject) { - if (!C_plus_plus && !reentrant) { - indent_puts - ("static yy_state_type yy_last_accepting_state;"); - indent_puts - ("static char *yy_last_accepting_cpos;\n"); - } - } - if (nultrans) { - flex_int32_t *yynultrans_data = NULL; - - /* Begin generating yy_NUL_trans */ - out_str_dec(get_state_decl(), "yy_NUL_trans", - lastdfa + 1); - buf_prints(&yydmap_buf, - "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", - (fullspd) ? "struct yy_trans_info*" : - "flex_int32_t"); - - yynultrans_tbl = calloc(1, sizeof(struct yytbl_data)); - yytbl_data_init(yynultrans_tbl, YYTD_ID_NUL_TRANS); - if (fullspd) - yynultrans_tbl->td_flags |= YYTD_PTRANS; - yynultrans_tbl->td_lolen = lastdfa + 1; - yynultrans_tbl->td_data = yynultrans_data = - calloc(yynultrans_tbl->td_lolen, - sizeof(flex_int32_t)); - - for (i = 1; i <= lastdfa; ++i) { - if (fullspd) { - out_dec(" &yy_transition[%d],\n", - base[i]); - yynultrans_data[i] = base[i]; - } else { - mkdata(nultrans[i]); - yynultrans_data[i] = nultrans[i]; - } - } - - dataend(); - if (tablesext) { - yytbl_data_compress(yynultrans_tbl); - if (yytbl_data_fwrite(&tableswr, yynultrans_tbl) < 0) - flexerror(_ - ("Could not write yynultrans_tbl")); - yytbl_data_destroy(yynultrans_tbl); - yynultrans_tbl = NULL; - } - /* End generating yy_NUL_trans */ - } - if (!C_plus_plus && !reentrant) { - indent_puts("extern int yy_flex_debug;"); - indent_put2s("int yy_flex_debug = %s;\n", - ddebug ? "1" : "0"); - } - if (ddebug) { /* Spit out table mapping rules to line - * numbers. */ - out_str_dec(long_align ? get_int32_decl() : - get_int16_decl(), "yy_rule_linenum", - num_rules); - for (i = 1; i < num_rules; ++i) - mkdata(rule_linenum[i]); - dataend(); - } - if (reject) { - outn("m4_ifdef( [[M4_YY_USES_REJECT]],\n[["); - /* Declare state buffer variables. */ - if (!C_plus_plus && !reentrant) { - outn("static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;"); - outn("static char *yy_full_match;"); - outn("static int yy_lp;"); - } - if (variable_trailing_context_rules) { - if (!C_plus_plus && !reentrant) { - outn("static int yy_looking_for_trail_begin = 0;"); - outn("static int yy_full_lp;"); - outn("static int *yy_full_state;"); - } - out_hex("#define YY_TRAILING_MASK 0x%x\n", - (unsigned int) YY_TRAILING_MASK); - out_hex("#define YY_TRAILING_HEAD_MASK 0x%x\n", - (unsigned int) YY_TRAILING_HEAD_MASK); - } - outn("#define REJECT \\"); - outn("{ \\"); - outn("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \\"); - outn("yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \\"); - - if (variable_trailing_context_rules) { - outn("YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \\"); - outn("YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \\"); - outn("yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \\"); - } - outn("++YY_G(yy_lp); \\"); - outn("goto find_rule; \\"); - - outn("}"); - outn("]])\n"); - } else { - outn("/* The intent behind this definition is that it'll catch"); - outn(" * any uses of REJECT which flex missed."); - outn(" */"); - outn("#define REJECT reject_used_but_not_detected"); - } - - if (yymore_used) { - if (!C_plus_plus) { - if (yytext_is_array) { - if (!reentrant) { - indent_puts("static int yy_more_offset = 0;"); - indent_puts("static int yy_prev_more_offset = 0;"); - } - } else if (!reentrant) { - indent_puts - ("static int yy_more_flag = 0;"); - indent_puts - ("static int yy_more_len = 0;"); - } - } - if (yytext_is_array) { - indent_puts - ("#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext M4_YY_CALL_LAST_ARG))"); - indent_puts("#define YY_NEED_STRLEN"); - indent_puts("#define YY_MORE_ADJ 0"); - indent_puts - ("#define YY_RESTORE_YY_MORE_OFFSET \\"); - indent_up(); - indent_puts("{ \\"); - indent_puts - ("YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\"); - indent_puts("yyleng -= YY_G(yy_more_offset); \\"); - indent_puts("}"); - indent_down(); - } else { - indent_puts - ("#define yymore() (YY_G(yy_more_flag) = 1)"); - indent_puts - ("#define YY_MORE_ADJ YY_G(yy_more_len)"); - indent_puts("#define YY_RESTORE_YY_MORE_OFFSET"); - } - } else { - indent_puts - ("#define yymore() yymore_used_but_not_detected"); - indent_puts("#define YY_MORE_ADJ 0"); - indent_puts("#define YY_RESTORE_YY_MORE_OFFSET"); - } - - if (!C_plus_plus) { - if (yytext_is_array) { - outn("#ifndef YYLMAX"); - outn("#define YYLMAX 8192"); - outn("#endif\n"); - if (!reentrant) { - outn("char yytext[YYLMAX];"); - outn("char *yytext_ptr;"); - } - } else { - if (!reentrant) - outn("char *yytext;"); - } - } - out(&action_array[defs1_offset]); - - line_directive_out(stdout, 0); - - skelout(); /* %% [5.0] - break point in skel */ - - if (!C_plus_plus) { - if (use_read) { - outn("\terrno=0; \\"); - outn("\twhile ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\"); - outn("\t{ \\"); - outn("\t\tif( errno != EINTR) \\"); - outn("\t\t{ \\"); - outn("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\"); - outn("\t\t\tbreak; \\"); - outn("\t\t} \\"); - outn("\t\terrno=0; \\"); - outn("\t\tclearerr(yyin); \\"); - outn("\t}\\"); - } else { - outn("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\"); - outn("\t\t{ \\"); - outn("\t\tint c = '*'; \\"); - outn("\t\tsize_t n; \\"); - outn("\t\tfor ( n = 0; n < max_size && \\"); - outn("\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\"); - outn("\t\t\tbuf[n] = (char) c; \\"); - outn("\t\tif ( c == '\\n' ) \\"); - outn("\t\t\tbuf[n++] = (char) c; \\"); - outn("\t\tif ( c == EOF && ferror( yyin ) ) \\"); - outn("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\"); - outn("\t\tresult = n; \\"); - outn("\t\t} \\"); - outn("\telse \\"); - outn("\t\t{ \\"); - outn("\t\terrno=0; \\"); - outn("\t\twhile ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \\"); - outn("\t\t\t{ \\"); - outn("\t\t\tif( errno != EINTR) \\"); - outn("\t\t\t\t{ \\"); - outn("\t\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\"); - outn("\t\t\t\tbreak; \\"); - outn("\t\t\t\t} \\"); - outn("\t\t\terrno=0; \\"); - outn("\t\t\tclearerr(yyin); \\"); - outn("\t\t\t} \\"); - outn("\t\t}\\"); - } - } - skelout(); /* %% [6.0] - break point in skel */ - - indent_puts("#define YY_RULE_SETUP \\"); - indent_up(); - if (bol_needed) { - indent_puts("if ( yyleng > 0 ) \\"); - indent_up(); - indent_puts("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \\"); - indent_puts("\t\t(yytext[yyleng - 1] == '\\n'); \\"); - indent_down(); - } - indent_puts("YY_USER_ACTION"); - indent_down(); - - skelout(); /* %% [7.0] - break point in skel */ - - /* Copy prolog to output file. */ - out(&action_array[prolog_offset]); - - line_directive_out(stdout, 0); - - skelout(); /* %% [8.0] - break point in skel */ - - set_indent(2); - - if (yymore_used && !yytext_is_array) { - indent_puts("YY_G(yy_more_len) = 0;"); - indent_puts("if ( YY_G(yy_more_flag) )"); - indent_up(); - indent_puts("{"); - indent_puts - ("YY_G(yy_more_len) = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);"); - indent_puts("YY_G(yy_more_flag) = 0;"); - indent_puts("}"); - indent_down(); - } - skelout(); /* %% [9.0] - break point in skel */ - - gen_start_state(); - - /* Note, don't use any indentation. */ - outn("yy_match:"); - gen_next_match(); - - skelout(); /* %% [10.0] - break point in skel */ - set_indent(2); - gen_find_action(); - - skelout(); /* %% [11.0] - break point in skel */ - outn("m4_ifdef( [[M4_YY_USE_LINENO]],[["); - indent_puts - ("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )"); - indent_up(); - indent_puts("{"); - indent_puts("yy_size_t yyl;"); - do_indent(); - out_str("for ( yyl = %s; yyl < yyleng; ++yyl )\n", - yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : - "YY_G(yy_more_len)") : "0"); - indent_up(); - indent_puts("if ( yytext[yyl] == '\\n' )"); - indent_up(); - indent_puts("M4_YY_INCR_LINENO();"); - indent_down(); - indent_down(); - indent_puts("}"); - indent_down(); - outn("]])"); - - skelout(); /* %% [12.0] - break point in skel */ - if (ddebug) { - indent_puts("if ( yy_flex_debug )"); - indent_up(); - - indent_puts("{"); - indent_puts("if ( yy_act == 0 )"); - indent_up(); - indent_puts(C_plus_plus ? - "std::cerr << \"--scanner backing up\\n\";" : - "fprintf( stderr, \"--scanner backing up\\n\" );"); - indent_down(); - - do_indent(); - out_dec("else if ( yy_act < %d )\n", num_rules); - indent_up(); - - if (C_plus_plus) { - indent_puts - ("std::cerr << \"--accepting rule at line \" << yy_rule_linenum[yy_act] <<"); - indent_puts - (" \"(\\\"\" << yytext << \"\\\")\\n\";"); - } else { - indent_puts - ("fprintf( stderr, \"--accepting rule at line %ld (\\\"%s\\\")\\n\","); - - indent_puts - (" (long)yy_rule_linenum[yy_act], yytext );"); - } - - indent_down(); - - do_indent(); - out_dec("else if ( yy_act == %d )\n", num_rules); - indent_up(); - - if (C_plus_plus) { - indent_puts - ("std::cerr << \"--accepting default rule (\\\"\" << yytext << \"\\\")\\n\";"); - } else { - indent_puts - ("fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\","); - indent_puts(" yytext );"); - } - - indent_down(); - - do_indent(); - out_dec("else if ( yy_act == %d )\n", num_rules + 1); - indent_up(); - - indent_puts(C_plus_plus ? - "std::cerr << \"--(end of buffer or a NUL)\\n\";" : - "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );"); - - indent_down(); - - do_indent(); - outn("else"); - indent_up(); - - if (C_plus_plus) { - indent_puts - ("std::cerr << \"--EOF (start condition \" << YY_START << \")\\n\";"); - } else { - indent_puts - ("fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );"); - } - - indent_down(); - - indent_puts("}"); - indent_down(); - } - /* Copy actions to output file. */ - skelout(); /* %% [13.0] - break point in skel */ - indent_up(); - gen_bu_action(); - out(&action_array[action_offset]); - - line_directive_out(stdout, 0); - - /* generate cases for any missing EOF rules */ - for (i = 1; i <= lastsc; ++i) - if (!sceof[i]) { - do_indent(); - out_str("case YY_STATE_EOF(%s):\n", scname[i]); - did_eof_rule = true; - } - if (did_eof_rule) { - indent_up(); - indent_puts("yyterminate();"); - indent_down(); - } - /* Generate code for handling NUL's, if needed. */ - - /* - * First, deal with backing up and setting up yy_cp if the scanner - * finds that it should JAM on the NUL. - */ - skelout(); /* %% [14.0] - break point in skel */ - set_indent(4); - - if (fullspd || fulltbl) - indent_puts("yy_cp = YY_G(yy_c_buf_p);"); - - else { /* compressed table */ - if (!reject && !interactive) { - /* - * Do the guaranteed-needed backing up to figure out - * the match. - */ - indent_puts - ("yy_cp = YY_G(yy_last_accepting_cpos);"); - indent_puts - ("yy_current_state = YY_G(yy_last_accepting_state);"); - } else - /* - * Still need to initialize yy_cp, though - * yy_current_state was set up by - * yy_get_previous_state(). - */ - indent_puts("yy_cp = YY_G(yy_c_buf_p);"); - } - - - /* Generate code for yy_get_previous_state(). */ - set_indent(1); - skelout(); /* %% [15.0] - break point in skel */ - - gen_start_state(); - - set_indent(2); - skelout(); /* %% [16.0] - break point in skel */ - gen_next_state(true); - - set_indent(1); - skelout(); /* %% [17.0] - break point in skel */ - gen_NUL_trans(); - - skelout(); /* %% [18.0] - break point in skel */ - skelout(); /* %% [19.0] - break point in skel */ - /* Update BOL and yylineno inside of input(). */ - if (bol_needed) { - indent_puts - ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\\n');"); - if (do_yylineno) { - indent_puts - ("if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )"); - indent_up(); - indent_puts("M4_YY_INCR_LINENO();"); - indent_down(); - } - } else if (do_yylineno) { - indent_puts("if ( c == '\\n' )"); - indent_up(); - indent_puts("M4_YY_INCR_LINENO();"); - indent_down(); - } - skelout(); - - /* Copy remainder of input to output. */ - - line_directive_out(stdout, 1); - - if (sectnum == 3) { - OUT_BEGIN_CODE(); - (void) flexscan(); /* copy remainder of input to output */ - OUT_END_CODE(); - } -} diff --git a/third_party/lex/lex.mk b/third_party/lex/lex.mk deleted file mode 100644 index ad1127ac..00000000 --- a/third_party/lex/lex.mk +++ /dev/null @@ -1,118 +0,0 @@ -#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ -#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ -# Description: -# lex generates state machines for tokenizing languages. - -PKGS += THIRD_PARTY_LEX - -THIRD_PARTY_LEX = \ - o/$(MODE)/third_party/lex/lex.com - -THIRD_PARTY_LEX_BINS = \ - $(THIRD_PARTY_LEX) \ - $(THIRD_PARTY_LEX).dbg - -THIRD_PARTY_LEX_OBJS = \ - o/$(MODE)/third_party/lex/buf.o \ - o/$(MODE)/third_party/lex/ccl.o \ - o/$(MODE)/third_party/lex/dfa.o \ - o/$(MODE)/third_party/lex/ecs.o \ - o/$(MODE)/third_party/lex/filter.o \ - o/$(MODE)/third_party/lex/gen.o \ - o/$(MODE)/third_party/lex/main.o \ - o/$(MODE)/third_party/lex/misc.o \ - o/$(MODE)/third_party/lex/nfa.o \ - o/$(MODE)/third_party/lex/options.o \ - o/$(MODE)/third_party/lex/parse.o \ - o/$(MODE)/third_party/lex/regex.o \ - o/$(MODE)/third_party/lex/scan.o \ - o/$(MODE)/third_party/lex/scanflags.o \ - o/$(MODE)/third_party/lex/scanopt.o \ - o/$(MODE)/third_party/lex/skel.o \ - o/$(MODE)/third_party/lex/sym.o \ - o/$(MODE)/third_party/lex/tables.o \ - o/$(MODE)/third_party/lex/tables_shared.o \ - o/$(MODE)/third_party/lex/tblcmp.o \ - o/$(MODE)/third_party/lex/yylex.o \ - o/$(MODE)/third_party/lex/buf.c.zip.o \ - o/$(MODE)/third_party/lex/ccl.c.zip.o \ - o/$(MODE)/third_party/lex/dfa.c.zip.o \ - o/$(MODE)/third_party/lex/ecs.c.zip.o \ - o/$(MODE)/third_party/lex/filter.c.zip.o \ - o/$(MODE)/third_party/lex/gen.c.zip.o \ - o/$(MODE)/third_party/lex/main.c.zip.o \ - o/$(MODE)/third_party/lex/misc.c.zip.o \ - o/$(MODE)/third_party/lex/nfa.c.zip.o \ - o/$(MODE)/third_party/lex/options.c.zip.o \ - o/$(MODE)/third_party/lex/parse.c.zip.o \ - o/$(MODE)/third_party/lex/regex.c.zip.o \ - o/$(MODE)/third_party/lex/scan.c.zip.o \ - o/$(MODE)/third_party/lex/scanflags.c.zip.o \ - o/$(MODE)/third_party/lex/scanopt.c.zip.o \ - o/$(MODE)/third_party/lex/skel.c.zip.o \ - o/$(MODE)/third_party/lex/sym.c.zip.o \ - o/$(MODE)/third_party/lex/tables.c.zip.o \ - o/$(MODE)/third_party/lex/tables_shared.c.zip.o \ - o/$(MODE)/third_party/lex/tblcmp.c.zip.o \ - o/$(MODE)/third_party/lex/yylex.c.zip.o - -THIRD_PARTY_LEX_DIRECTDEPS = \ - LIBC_ALG \ - LIBC_CALLS \ - LIBC_CALLS_HEFTY \ - LIBC_FMT \ - LIBC_LOG \ - LIBC_MATH \ - LIBC_MEM \ - LIBC_NEXGEN32E \ - LIBC_RUNTIME \ - LIBC_STDIO \ - LIBC_STR \ - LIBC_STUBS \ - LIBC_SYSV \ - LIBC_SYSV_CALLS \ - LIBC_UNICODE \ - LIBC_X \ - THIRD_PARTY_REGEX - -THIRD_PARTY_LEX_DEPS := \ - $(call uniq,$(foreach x,$(THIRD_PARTY_LEX_DIRECTDEPS),$($(x)))) - -$(THIRD_PARTY_LEX).pkg: \ - $(THIRD_PARTY_LEX_OBJS) \ - $(foreach x,$(THIRD_PARTY_LEX_DIRECTDEPS),$($(x)_A).pkg) - -$(THIRD_PARTY_LEX_OBJS): \ - DEFAULT_CPPFLAGS += \ - -DHAVE_CONFIG_H \ - -isystem third_party/lex - -$(THIRD_PARTY_LEX_OBJS): \ - OVERRIDE_CFLAGS += \ - $(OLD_CODE) \ - -O0 - -o/$(MODE)/third_party/lex/parse.o \ -o/$(MODE)/third_party/lex/misc.o \ -o/$(MODE)/third_party/lex/dfa.o: \ - DEFAULT_CPPFLAGS += \ - -DSTACK_FRAME_UNLIMITED - -o/$(MODE)/third_party/lex/scan.o: \ - DEFAULT_CFLAGS += \ - -w - -$(THIRD_PARTY_LEX).dbg: \ - $(THIRD_PARTY_LEX_DEPS) \ - $(THIRD_PARTY_LEX_OBJS) \ - $(THIRD_PARTY_LEX).pkg \ - $(CRT) \ - $(APE) - @$(APELINK) - -$(THIRD_PARTY_LEX_OBJS): \ - $(BUILD_FILES) \ - third_party/lex/lex.mk - -.PHONY: o/$(MODE)/third_party/lex -o/$(MODE)/third_party/lex: $(THIRD_PARTY_LEX_BINS) diff --git a/third_party/lex/lex.ms b/third_party/lex/lex.ms deleted file mode 100644 index bfa6baf6..00000000 --- a/third_party/lex/lex.ms +++ /dev/null @@ -1,2208 +0,0 @@ -.\" $OpenBSD: lex.ms,v 1.3 2004/04/06 10:00:32 jmc Exp $ -.\" -.\" Copyright (C) Caldera International Inc. 2001-2002. -.\" All rights reserved. -.\" -.\" 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 and documentation 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" 4. Neither the name of Caldera International, Inc. nor the names of other -.\" contributors may be used to endorse or promote products derived from -.\" this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, -.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" @(#)lex.ms 8.2 (Berkeley) 5/24/94 -.\" -.if n \{\ -.po 5n -.ll 70n -.\} -.EH 'PSD:16-%''Lex \- A Lexical Analyzer Generator' -.OH 'Lex \- A Lexical Analyzer Generator''PSD:16-%' -.hc ~ -.bd I 2 -.de TS -.br -.nf -.SP 1v -.ul 0 -.. -.de TE -.SP 1v -.fi -.. -.\".de PT -.\".if \\n%>1 'tl ''\s7LEX\s0\s9\(mi%\s0'' -.\".if \\n%>1 'sp -.\".. -.ND July 21, 1975 -.\".RP -.\".TM 75-1274-15 39199 39199-11 -.TL -Lex \- A Lexical Analyzer ~Generator~ -.AU ``MH 2C-569'' 6377 -M. E. Lesk and E. Schmidt -.AI -.\" .MH -.AB -.sp -.bd I 2 -.\".nr PS 8 -.\".nr VS 9 -.\".ps 8 -.\".vs 9p -Lex helps write programs whose control flow -is directed by instances of regular -expressions in the input stream. -It is well suited for editor-script type transformations and -for segmenting input in preparation for -a parsing routine. -.PP -Lex source is a table of regular expressions and corresponding program fragments. -The table is translated to a program -which reads an input stream, copying it to an output stream -and partitioning the input -into strings which match the given expressions. -As each such string is recognized the corresponding -program fragment is executed. -The recognition of the expressions -is performed by a deterministic finite automaton -generated by Lex. -The program fragments written by the user are executed in the order in which the -corresponding regular expressions occur in the input stream. -.\" .if n .if \n(tm .ig -.PP -The lexical analysis -programs written with Lex accept ambiguous specifications -and choose the longest -match possible at each input point. -If necessary, substantial look~ahead -is performed on the input, but the -input stream will be backed up to the -end of the current partition, so that the user -has general freedom to manipulate it. -.PP -Lex can generate analyzers in either C or C++. \** -.FS -Some versions of lex were able to produce Ratfor scanners. -Ratfor is a language which can be translated automatically to portable Fortran. -This implementation of lex does not support such scanners. -.FE -This manual, however, will only discuss generating analyzers -in C on the UNIX system. -For details on generating C++ scanners, see the manual page for lex(1). -Lex is designed to simplify -interfacing with Yacc, for those -with access to this compiler-compiler system. -\&.. -.\".nr PS 9 -.\".nr VS 11 -.AE -.\" .2C -.NH -Introduction. -.PP -Lex is a program generator designed for -lexical processing of character input streams. -It accepts a high-level, problem oriented specification -for character string matching, -and -produces a program in a general purpose language which recognizes -regular expressions. -The regular expressions are specified by the user in the -source specifications given to Lex. -The Lex written code recognizes these expressions -in an input stream and partitions the input stream into -strings matching the expressions. At the bound~aries -between strings -program sections -provided by the user are executed. -The Lex source file associates the regular expressions and the -program fragments. -As each expression appears in the input to the program written by Lex, -the corresponding fragment is executed. -.PP -.de MH -Bell Laboratories, Murray Hill, NJ 07974. -.. -The user supplies the additional code -beyond expression matching -needed to complete his tasks, possibly -including code written by other generators. -The program that recognizes the expressions is generated in the -general purpose programming language employed for the -user's program fragments. -Thus, a high level expression -language is provided to write the string expressions to be -matched while the user's freedom to write actions -is unimpaired. -This avoids forcing the user who wishes to use a string manipulation -language for input analysis to write processing programs in the same -and often inappropriate string handling language. -.PP -Lex is not a complete language, but rather a generator representing -a new language feature which can be added to -different programming languages, called ``host languages.'' -Just as general purpose languages -can produce code to run on different computer hardware, -Lex can write code in different host languages. -The host language is used for the output code generated by Lex -and also for the program fragments added by the user. -Compatible run-time libraries for the different host languages -are also provided. -This makes Lex adaptable to different environments and -different users. -Each application -may be directed to the combination of hardware and host language appropriate -to the task, the user's background, and the properties of local -implementations. -At present, the only supported host languages are C and C++, -although Fortran (in the form of Ratfor [2]) has been available -in the past. -Lex itself exists on UNIX, GCOS, and OS/370; but the -code generated by Lex may be taken anywhere the appropriate -compilers exist. -.PP -Lex turns the user's expressions and actions -(called -.ul -source -in this memo) into the host general-purpose language; -the generated program is named -.ul -yylex. -The -.ul -yylex -program -will recognize expressions -in a stream -(called -.ul -input -in this memo) -and perform the specified actions for each expression as it is detected. -See Figure 1. -.DS C -Source \(-> Lex \(-> yylex - - -Input \(-> yylex \(-> Output - - -An overview of Lex -Figure 1 -.DE -.PP -For a trivial example, consider a program to delete -from the input -all blanks or tabs at the ends of lines. -.DS I -%% -[ \et]+$ ; -.DE -.LP -is all that is required. -The program -contains a %% delimiter to mark the beginning of the rules, and -one rule. -This rule contains a regular expression -which matches one or more -instances of the characters blank or tab -(written \et for visibility, in accordance with the C language convention) -just prior to the end of a line. -The brackets indicate the character -class made of blank and tab; the + indicates ``one or more ...''; -and the $ indicates ``end of line,'' as in QED. -No action is specified, -so the program generated by Lex (yylex) will ignore these characters. -Everything else will be copied. -To change any remaining -string of blanks or tabs to a single blank, -add another rule: -.DS I -%% -[ \et]+$ ; -[ \et]+ printf(" "); -.DE -.LP -The finite automaton generated for this -source will scan for both rules at once, -observing at -the termination of the string of blanks or tabs -whether or not there is a newline character, and executing -the desired rule action. -The first rule matches all strings of blanks or tabs -at the end of lines, and the second -rule all remaining strings of blanks or tabs. -.PP -Lex can be used alone for simple transformations, or -for analysis and statistics gathering on a lexical level. -Lex can also be used with a parser generator -to perform the lexical analysis phase; it is particularly -easy to interface Lex and Yacc [3]. -Lex programs recognize only regular expressions; -Yacc writes parsers that accept a large class of context free grammars, -but require a lower level analyzer to recognize input tokens. -Thus, a combination of Lex and Yacc is often appropriate. -When used as a preprocessor for a later parser generator, -Lex is used to partition the input stream, -and the parser generator assigns structure to -the resulting pieces. -The flow of control -in such a case (which might be the first half of a compiler, -for example) is shown in Figure 2. -Additional programs, -written by other generators -or by hand, can -be added easily to programs written by Lex. -.\" .BS 2 -.ps 9 -.vs 11 -.DS C - lexical grammar - rules rules - \(da \(da - - Lex Yacc - - \(da \(da - -Input \(-> yylex \(-> yyparse \(-> Parsed input - - - Lex with Yacc - Figure 2 -.DE -.ps 10 -.vs 12 -.\" .BE -.LP -Yacc users -will realize that the name -.ul -yylex -is what Yacc expects its lexical analyzer to be named, -so that the use of this name by Lex simplifies -interfacing. -.PP -Lex generates a deterministic finite automaton from the regular expressions -in the source [4]. -The automaton is interpreted, rather than compiled, in order -to save space. -The result is still a fast analyzer. -In particular, the time taken by a Lex program -to recognize and partition an input stream is -proportional to the length of the input. -The number of Lex rules or -the complexity of the rules is -not important in determining speed, -unless rules which include -forward context require a significant amount of re~scanning. -What does increase with the number and complexity of rules -is the size of the finite -automaton, and therefore the size of the program -generated by Lex. -.PP -In the program written by Lex, the user's fragments -(representing the -.ul -actions -to be performed as each regular expression -is found) -are gathered -as cases of a switch. -The automaton interpreter directs the control flow. -Opportunity is provided for the user to insert either -declarations or additional statements in the routine containing -the actions, or to -add subroutines outside this action routine. -.PP -Lex is not limited to source which can -be interpreted on the basis of one character -look~ahead. -For example, -if there are two rules, one looking for -.I ab -and another for -.I abcdefg , -and the input stream is -.I abcdefh , -Lex will recognize -.I ab -and leave -the input pointer just before -.I "cd. . ." -Such backup is more costly -than the processing of simpler languages. -.NH -Lex Source. -.PP -The general format of Lex source is: -.DS I -{definitions} -%% -{rules} -%% -{user subroutines} -.DE -.LP -where the definitions and the user subroutines -are often omitted. -The second -.I %% -is optional, but the first is required -to mark the beginning of the rules. -The absolute minimum Lex program is thus -.DS I -%% -.DE -.LP -(no definitions, no rules) which translates into a program -which copies the input to the output unchanged. -.PP -In the outline of Lex programs shown above, the -.I -rules -.R -represent the user's control -decisions; they are a table, in which the left column -contains -.I -regular expressions -.R -(see section 3) -and the right column contains -.I -actions, -.R -program fragments to be executed when the expressions -are recognized. -Thus an individual rule might appear -.DS I -integer printf("found keyword INT"); -.DE -.LP -to look for the string -.I integer -in the input stream and -print the message ``found keyword INT'' whenever it appears. -In this example the host procedural language is C and -the C library function -.I -printf -.R -is used to print the string. -The end -of the expression is indicated by the first blank or tab character. -If the action is merely a single C expression, -it can just be given on the right side of the line; if it is -compound, or takes more than a line, it should be enclosed in -braces. -As a slightly more useful example, suppose it is desired to -change a number of words from British to American spelling. -Lex rules such as -.DS I -colour printf("color"); -mechanise printf("mechanize"); -petrol printf("gas"); -.DE -.LP -would be a start. These rules are not quite enough, -since -the word -.I petroleum -would become -.I gaseum ; -a way of dealing -with this will be described later. -.NH -Lex Regular Expressions. -.PP -The definitions of regular expressions are very similar to those -in QED [5]. -A regular -expression specifies a set of strings to be matched. -It contains text characters (which match the corresponding -characters in the strings being compared) -and operator characters (which specify -repetitions, choices, and other features). -The letters of the alphabet and the digits are -always text characters; thus the regular expression -.DS I -integer -.DE -.LP -matches the string -.ul -integer -wherever it appears -and the expression -.DS I -a57D -.DE -.LP -looks for the string -.ul -a57D. -.PP -.I -Operators. -.R -The operator characters are -.DS I -" \e [ ] ^ \- ? . \(** + | ( ) $ / { } % < > -.DE -.LP -and if they are to be used as text characters, an escape -should be used. -The quotation mark operator (") -indicates that whatever is contained between a pair of quotes -is to be taken as text characters. -Thus -.DS I -xyz"++" -.DE -.LP -matches the string -.I xyz++ -when it appears. Note that a part of a string may be quoted. -It is harmless but unnecessary to quote an ordinary -text character; the expression -.DS I -"xyz++" -.DE -.LP -is the same as the one above. -Thus by quoting every non-alphanumeric character -being used as a text character, the user can avoid remembering -the list above of current -operator characters, and is safe should further extensions to Lex -lengthen the list. -.PP -An operator character may also be turned into a text character -by preceding it with \e as in -.DS I -xyz\e+\e+ -.DE -.LP -which -is another, less readable, equivalent of the above expressions. -Another use of the quoting mechanism is to get a blank into -an expression; normally, as explained above, blanks or tabs end -a rule. -Any blank character not contained within [\|] (see below) must -be quoted. -Several normal C escapes with \e -are recognized: \en is newline, \et is tab, and \eb is backspace. -To enter \e itself, use \e\e. -Since newline is illegal in an expression, \en must be used; -it is not -required to escape tab and backspace. -Every character but blank, tab, newline and the list above is always -a text character. -.PP -.I -Character classes. -.R -Classes of characters can be specified using the operator pair [\|]. -The construction -.I [abc] -matches a -single character, which may be -.I a , -.I b , -or -.I c . -Within square brackets, -most operator meanings are ignored. -Only three characters are special: -these are \e \(mi and ^. The \(mi character -indicates ranges. For example, -.DS I -[a\(miz0\(mi9<>_] -.DE -.LP -indicates the character class containing all the lower case letters, -the digits, -the angle brackets, and underline. -.\" Ranges may be given in either order. -Using \(mi between any pair of characters which are -not both upper case letters, both lower case letters, or both digits -is implementation dependent. -.\" and will get a warning message. -(E.g., [0\-z] in ASCII is many more characters -than it is in EBCDIC). -If it is desired to include the -character \(mi in a character class, it should be first or -last; thus -.DS I -[\(mi+0\(mi9] -.DE -.LP -matches all the digits and the two signs. -.PP -In character classes, -the ^ operator must appear as the first character -after the left bracket; it indicates that the resulting string -is to be complemented with respect to the computer character set. -Thus -.DS I -[^abc] -.DE -.LP -matches all characters except a, b, or c, including -all special or control characters; or -.DS I -[^a\-zA\-Z] -.DE -.LP -is any character which is not a letter. -The \e character provides the usual escapes within -character class brackets. -.PP -.I -Arbitrary character. -.R -To match almost any character, the operator character -.DS I -\&. -.DE -.LP -is the class of all characters except newline. -Escaping into octal is possible although non-portable: -.DS I -[\e40\-\e176] -.DE -.LP -matches all printable characters in the ASCII character set, from octal -40 (blank) to octal 176 (tilde). -.PP -.I -Optional expressions. -.R -The operator -.I ? -indicates -an optional element of an expression. -Thus -.DS I -ab?c -.DE -.LP -matches either -.I ac -or -.I abc . -.PP -.I -Repeated expressions. -.R -Repetitions of classes are indicated by the operators -.I \(** -and -.I + . -.DS I -\f2a\(**\f1 -.DE -.LP -is any number of consecutive -.I a -characters, including zero; while -.DS I -a+ -.DE -.LP -is one or more instances of -.I a. -For example, -.DS I -[a\-z]+ -.DE -.LP -is all strings of lower case letters. -And -.DS -[A\(miZa\(miz][A\(miZa\(miz0\(mi9]\(** -.DE -.LP -indicates all alphanumeric strings with a leading -alphabetic character. -This is a typical expression for recognizing identifiers in -computer languages. -.PP -.I -Alternation and Grouping. -.R -The operator | -indicates alternation: -.DS I -(ab\||\|cd) -.DE -.LP -matches either -.ul -ab -or -.ul -cd. -Note that parentheses are used for grouping, although -they are -not necessary on the outside level; -.DS I -ab\||\|cd -.DE -.LP -would have sufficed. -Parentheses -can be used for more complex expressions: -.DS I -(ab\||\|cd+)?(ef)\(** -.DE -.LP -matches such strings as -.I abefef , -.I efefef , -.I cdef , -or -.I cddd\| ; -but not -.I abc , -.I abcd , -or -.I abcdef . -.PP -.I -Context sensitivity. -.R -Lex will recognize a small amount of surrounding -context. The two simplest operators for this are -.I ^ -and -.I $ . -If the first character of an expression is -.I ^ , -the expression will only be matched at the beginning -of a line (after a newline character, or at the beginning of -the input stream). -This can never conflict with the other meaning of -.I ^ , -complementation -of character classes, since that only applies within -the [\|] operators. -If the very last character is -.I $ , -the expression will only be matched at the end of a line (when -immediately followed by newline). -The latter operator is a special case of the -.I / -operator character, -which indicates trailing context. -The expression -.DS I -ab/cd -.DE -.LP -matches the string -.I ab , -but only if followed by -.ul -cd. -Thus -.DS I -ab$ -.DE -.LP -is the same as -.DS I -ab/\en -.DE -.LP -Left context is handled in Lex by -.I -start conditions -.R -as explained in section 10. If a rule is only to be executed -when the Lex automaton interpreter is in start condition -.I -x, -.R -the rule should be prefixed by -.DS I - -.DE -.LP -using the angle bracket operator characters. -If we considered ``being at the beginning of a line'' to be -start condition -.I ONE , -then the ^ operator -would be equivalent to -.DS I - -.DE -.LP -Start conditions are explained more fully later. -.PP -.I -Repetitions and Definitions. -.R -The operators {} specify -either repetitions (if they enclose numbers) -or -definition expansion (if they enclose a name). For example -.DS I -{digit} -.DE -.LP -looks for a predefined string named -.I digit -and inserts it -at that point in the expression. -The definitions are given in the first part of the Lex -input, before the rules. -In contrast, -.DS I -a{1,5} -.DE -.LP -looks for 1 to 5 occurrences of -.I a . -.PP -Finally, initial -.I % -is special, being the separator -for Lex source segments. -.NH -Lex Actions. -.PP -When an expression written as above is matched, Lex -executes the corresponding action. This section describes -some features of Lex which aid in writing actions. Note -that there is a default action, which -consists of copying the input to the output. This -is performed on all strings not otherwise matched. Thus -the Lex user who wishes to absorb the entire input, without -producing any output, must provide rules to match everything. -When Lex is being used with Yacc, this is the normal -situation. -One may consider that actions are what is done instead of -copying the input to the output; thus, in general, -a rule which merely copies can be omitted. -Also, a character combination -which is omitted from the rules -and which appears as input -is likely to be printed on the output, thus calling -attention to the gap in the rules. -.PP -One of the simplest things that can be done is to ignore -the input. Specifying a C null statement (`;') as an action -causes this result. A frequent rule is -.DS I -[ \et\en] ; -.DE -.LP -which causes the three spacing characters (blank, tab, and newline) -to be ignored. -.PP -Another easy way to avoid writing actions is the action character -|, which indicates that the action for this rule is the action -for the next rule. -The previous example could also have been written -.DS I -" " | -"\et" | -"\en" ; -.DE -.LP -with the same result, although in different style. -The quotes around \en and \et are not required. -.PP -In more complex actions, the user -will -often want to know the actual text that matched some expression -like -.I [a\(miz]+ . -Lex leaves this text in an external character -array named -.I -yytext. -.R -Thus, to print the name found, -a rule like -.DS I -[a\-z]+ printf("%s", yytext); -.DE -.LP -will print -the string in -.I -yytext. -.R -The C function -.I -printf -.R -accepts a format argument and data to be printed; -in this case, the format is ``print string'' (% indicating -data conversion, and -.I s -indicating string type), -and the data are the characters -in -.I -yytext. -.R -So this just places -the matched string -on the output. -This action -is so common that -it may be written as ECHO: -.DS I -[a\-z]+ ECHO; -.DE -.LP -is the same as the above. -Since the default action is just to -print the characters found, one might ask why -give a rule, like this one, which merely specifies -the default action? -Such rules are often required -to avoid matching some other rule -which is not desired. For example, if there is a rule -which matches -.I read -it will normally match the instances of -.I read -contained in -.I bread -or -.I readjust ; -to avoid -this, -a rule -of the form -.I [a\(miz]+ -is needed. -This is explained further below. -.PP -Sometimes it is more convenient to know the end of what -has been found; hence Lex also provides a count -.I -yyleng -.R -of the number of characters matched. -To count both the number -of words and the number of characters in words in the input, the user might write -.DS I -[a\-zA\-Z]+ {words++; chars += yyleng;} -.DE -.LP -which accumulates in -.ul -chars -the number -of characters in the words recognized. -The last character in the string matched can -be accessed by -.DS I -yytext[yyleng\-1] -.DE -.PP -Occasionally, a Lex -action may decide that a rule has not recognized the correct -span of characters. -Two routines are provided to aid with this situation. -First, -.I -yymore() -.R -can be called to indicate that the next input expression recognized is to be -tacked on to the end of this input. Normally, -the next input string would overwrite the current -entry in -.I -yytext. -.R -Second, -.I -yyless (n) -.R -may be called to indicate that not all the characters matched -by the currently successful expression are wanted right now. -The argument -.I -n -.R -indicates the number of characters -in -.I -yytext -.R -to be retained. -Further characters previously matched -are -returned to the input. This provides the same sort of -look~ahead offered by the / operator, -but in a different form. -.PP -.I -Example: -.R -Consider a language which defines -a string as a set of characters between quotation (") marks, and provides that -to include a " in a string it must be preceded by a \e. The -regular expression which matches that is somewhat confusing, -so that it might be preferable to write -.DS I -\e"[^"]\(** { - if (yytext[yyleng\-1] == \(fm\e\e\(fm) - yymore(); - else - ... normal user processing - } -.DE -.LP -which will, when faced with a string such as -.I -"abc\e"def\|" -.R -first match -the five characters -\fI"abc\e\|\fR; -then -the call to -.I yymore() -will -cause the next part of the string, -\fI"def\|\fR, -to be tacked on the end. -Note that the final quote terminating the string should be picked -up in the code labeled ``normal processing''. -.PP -The function -.I -yyless() -.R -might be used to reprocess -text in various circumstances. Consider the C problem of distinguishing -the ambiguity of ``=\(mia''. -Suppose it is desired to treat this as ``=\(mi a'' -but print a message. A rule might be -.ps 9 -.vs 11 -.DS I -=\(mi[a\-zA\-Z] { - printf("Op (=\(mi) ambiguous\en"); - yyless(yyleng\-1); - ... action for =\(mi ... - } -.DE -.ps 10 -.vs 12 -which prints a message, returns the letter after the -operator to the input stream, and treats the operator as ``=\(mi''. -Alternatively it might be desired to treat this as ``= \(mia''. -To do this, just return the minus -sign as well as the letter to the input: -.ps 9 -.vs 11 -.DS I -=\(mi[a\-zA\-Z] { - printf("Op (=\(mi) ambiguous\en"); - yyless(yyleng\-2); - ... action for = ... - } -.DE -.ps 10 -.vs 12 -will perform the other interpretation. -Note that the expressions for the two cases might more easily -be written -.DS I -=\(mi/[A\-Za\-z] -.DE -.LP -in the first case and -.DS I -=/\-[A\-Za\-z] -.DE -.LP -in the second; -no backup would be required in the rule action. -It is not necessary to recognize the whole identifier -to observe the ambiguity. -The -possibility of ``=\(mi3'', however, makes -.DS I -=\(mi/[^ \et\en] -.DE -a still better rule. -.PP -In addition to these routines, Lex also permits -access to the I/O routines -it uses. \** -.FS -Note: The output() routine is not supported in this version of Lex. -See yyout instead. -.FE -They are: -.IP 1) -.I -input() -.R -which returns the next input character; and -.IP 2) -.I -unput(c) -.R -pushes the character -.I -c -.R -back onto the input stream to be read later by -.I -input(). -.R -.LP -By default these routines are provided as macro definitions, -but the user can override them and supply private versions. -These routines -define the relationship between external files and -internal characters, and must all be retained -or modified consistently. -They may be redefined, to -cause input or output to be transmitted to or from strange -places, including other programs or internal memory; -but the character set used must be consistent in all routines; -a value of zero returned by -.I -input -.R -must mean end of file; and -the relationship between -.I -unput -.R -and -.I -input -.R -must be retained -or the Lex look~ahead will not work. -Lex does not look ahead at all if it does not have to, -but every rule ending in -.ft I -+ \(** ? -.ft R -or -.ft I -$ -.ft R -or containing -.ft I -/ -.ft R -implies look~ahead. -Look~ahead is also necessary to match an expression that is a prefix -of another expression. -See below for a discussion of the character set used by Lex. -The standard Lex library imposes -a 100 character limit on backup. -.PP -Another Lex library routine that the user will sometimes want -to redefine is -.I -yywrap() -.R -which is called whenever Lex reaches an end-of-file. -If -.I -yywrap -.R -returns a 1, Lex continues with the normal wrapup on end of input. -Sometimes, however, it is convenient to arrange for more -input to arrive -from a new source. -In this case, the user should provide -a -.I -yywrap -.R -which -arranges for new input and -returns 0. This instructs Lex to continue processing. -The default -.I -yywrap -.R -always returns 1. -.PP -This routine is also a convenient place -to print tables, summaries, etc. at the end -of a program. Note that it is not -possible to write a normal rule which recognizes -end-of-file; the only access to this condition is -through -.I -yywrap. -.R -In fact, unless a private version of -.I -input() -.R -is supplied -a file containing nulls -cannot be handled, -since a value of 0 returned by -.I -input -.R -is taken to be end-of-file. -.PP -.NH -Ambiguous Source Rules. -.PP -Lex can handle ambiguous specifications. -When more than one expression can match the -current input, Lex chooses as follows: -.IP 1) -The longest match is preferred. -.IP 2) -Among rules which matched the same number of characters, -the rule given first is preferred. -.LP -Thus, suppose the rules -.DS I -integer keyword action ...; -[a\-z]+ identifier action ...; -.DE -.LP -to be given in that order. If the input is -.I integers , -it is taken as an identifier, because -.I [a\-z]+ -matches 8 characters while -.I integer -matches only 7. -If the input is -.I integer , -both rules match 7 characters, and -the keyword rule is selected because it was given first. -Anything shorter (e.g. \fIint\fR\|) will -not match the expression -.I integer -and so the identifier interpretation is used. -.PP -The principle of preferring the longest -match makes rules containing -expressions like -.I \&.\(** -dangerous. -For example, -.DS I -\&\(fm.\(**\(fm -.DE -.LP -might seem a good way of recognizing -a string in single quotes. -But it is an invitation for the program to read far -ahead, looking for a distant -single quote. -Presented with the input -.DS I -\&\(fmfirst\(fm quoted string here, \(fmsecond\(fm here -.DE -.LP -the above expression will match -.DS I -\&\(fmfirst\(fm quoted string here, \(fmsecond\(fm -.DE -.LP -which is probably not what was wanted. -A better rule is of the form -.DS I -\&\(fm[^\(fm\en]\(**\(fm -.DE -.LP -which, on the above input, will stop -after -.I \(fmfirst\(fm . -The consequences -of errors like this are mitigated by the fact -that the -.I \&. -operator will not match newline. -Thus expressions like -.I \&.\(** -stop on the -current line. -Don't try to defeat this with expressions like -.I (.|\en)+ -or -equivalents; -the Lex generated program will try to read -the entire input file, causing -internal buffer overflows. -.PP -Note that Lex is normally partitioning -the input stream, not searching for all possible matches -of each expression. -This means that each character is accounted for -once and only once. -For example, suppose it is desired to -count occurrences of both \fIshe\fR and \fIhe\fR in an input text. -Some Lex rules to do this might be -.DS I -she s++; -he h++; -\en | -\&. ; -.DE -.LP -where the last two rules ignore everything besides \fIhe\fR and \fIshe\fR. -Remember that . does not include newline. -Since \fIshe\fR includes \fIhe\fR, Lex will normally -.I -not -.R -recognize -the instances of \fIhe\fR included in \fIshe\fR, -since once it has passed a \fIshe\fR those characters are gone. -.PP -Sometimes the user would like to override this choice. The action -REJECT -means ``go do the next alternative.'' -It causes whatever rule was second choice after the current -rule to be executed. -The position of the input pointer is adjusted accordingly. -Suppose the user really wants to count the included instances of \fIhe\fR: -.DS I -she {s++; REJECT;} -he {h++; REJECT;} -\en | -\&. ; -.DE -.LP -these rules are one way of changing the previous example -to do just that. -After counting each expression, it is rejected; whenever appropriate, -the other expression will then be counted. In this example, of course, -the user could note that \fIshe\fR includes \fIhe\fR but not -vice versa, and omit the REJECT action on \fIhe\fR; -in other cases, however, it -would not be possible a priori to tell -which input characters -were in both classes. -.PP -Consider the two rules -.DS I -a[bc]+ { ... ; REJECT;} -a[cd]+ { ... ; REJECT;} -.DE -.LP -If the input is -.I ab , -only the first rule matches, -and on -.I ad -only the second matches. -The input string -.I accb -matches the first rule for four characters -and then the second rule for three characters. -In contrast, the input -.I accd -agrees with -the second rule for four characters and then the first -rule for three. -.PP -In general, REJECT is useful whenever -the purpose of Lex is not to partition the input -stream but to detect all examples of some items -in the input, and the instances of these items -may overlap or include each other. -Suppose a digram table of the input is desired; -normally the digrams overlap, that is the word -.I the -is considered to contain -both -.I th -and -.I he . -Assuming a two-dimensional array named -.ul -digram -to be incremented, the appropriate -source is -.DS I -%% -[a\-z][a\-z] { - digram[yytext[0]][yytext[1]]++; - REJECT; - } -\&. ; -\en ; -.DE -.LP -where the REJECT is necessary to pick up -a letter pair beginning at every character, rather than at every -other character. -.NH -Lex Source Definitions. -.PP -Remember the format of the Lex -source: -.DS I -{definitions} -%% -{rules} -%% -{user routines} -.DE -.LP -So far only the rules have been described. The user needs -additional options, -though, to define variables for use in his program and for use -by Lex. -These can go either in the definitions section -or in the rules section. -.PP -Remember that Lex is turning the rules into a program. -Any source not intercepted by Lex is copied -into the generated program. There are three classes -of such things. -.IP 1) -Any line which is not part of a Lex rule or action -which begins with a blank or tab is copied into -the Lex generated program. -Such source input prior to the first %% delimiter will be external -to any function in the code; if it appears immediately after the first -%%, -it appears in an appropriate place for declarations -in the function written by Lex which contains the actions. -This material must look like program fragments, -and should precede the first Lex rule. -.IP -As a side effect of the above, lines which begin with a blank -or tab, and which contain a comment, -are passed through to the generated program. -This can be used to include comments in either the Lex source or -the generated code. The comments should follow the host -language convention. -.IP 2) -Anything included between lines containing -only -.I %{ -and -.I %} -is -copied out as above. The delimiters are discarded. -This format permits entering text like preprocessor statements that -must begin in column 1, -or copying lines that do not look like programs. -.IP 3) -Anything after the second %% delimiter, regardless of formats, etc., -is copied out after the Lex output. -.PP -Definitions intended for Lex are given -before the first %% delimiter. Any line in this section -not contained between %{ and %}, and begining -in column 1, is assumed to define Lex substitution strings. -The format of such lines is -.DS I -name translation -.DE -.LP -and it -causes the string given as a translation to -be associated with the name. -The name and translation -must be separated by at least one blank or tab, and the name must begin with -a letter or an underscore (`_'). -The translation can then be called out -by the {name} syntax in a rule. -Using {D} for the digits and {E} for an exponent field, -for example, might abbreviate rules to recognize numbers: -.DS I -D [0\-9] -E [DEde][\-+]?{D}+ -%% -{D}+ printf("integer"); -{D}+"."{D}\(**({E})? | -{D}\(**"."{D}+({E})? | -{D}+{E} printf("real"); -.DE -.LP -Note the first two rules for real numbers; -both require a decimal point and contain -an optional exponent field, -but the first requires at least one digit before the -decimal point and the second requires at least one -digit after the decimal point. -To correctly handle the problem -posed by a Fortran expression such as -.I 35.EQ.I , -which does not contain a real number, a context-sensitive -rule such as -.DS I -[0\-9]+/"."EQ printf("integer"); -.DE -.LP -could be used in addition to the normal rule for integers. -.PP -The definitions -section may also contain other commands, including the -selection of a host language, a character set table, -a list of start conditions, or adjustments to the default -size of arrays within Lex itself for larger source programs. -These possibilities -are discussed below under ``Summary of Source Format,'' -section 12. -.NH -Usage. -.PP -There are two steps in -compiling a Lex source program. -First, the Lex source must be turned into a generated program -in the host general purpose language. -Then this program must be compiled and loaded, usually with -a library of Lex subroutines. -The generated program -is on a file named -.I lex.yy.c . -The I/O library is defined in terms of the C standard -library [6]. -.PP -The C programs generated by Lex are slightly different -on OS/370, because the -OS compiler is less powerful than the UNIX or GCOS compilers, -and does less at compile time. -C programs generated on GCOS and UNIX are the same. -.PP -.I -UNIX. -.R -The library is accessed by the loader flag -.I \-ll . -So an appropriate -set of commands is -.DS I -lex source -cc lex.yy.c \-ll -.DE -.LP -The resulting program is placed on the usual file -.I -a.out -.R -for later execution. -To use Lex with Yacc see below. -Although the default Lex I/O routines use the C standard library, -the Lex automata themselves do not do so; -if private versions of -.I -input, -output -.R -and -.I unput -are given, the library can be avoided. -.PP -.NH -Lex and Yacc. -.PP -If you want to use Lex with Yacc, note that what Lex writes is a program -named -.I -yylex(), -.R -the name required by Yacc for its analyzer. -Normally, the default main program on the Lex library -calls this routine, but if Yacc is loaded, and its main -program is used, Yacc will call -.I -yylex(). -.R -In this case each Lex rule should end with -.DS I -return(token); -.DE -.LP -where the appropriate token value is returned. -An easy way to get access -to Yacc's names for tokens is to -compile the Lex output file as part of -the Yacc output file by placing the line -.DS I -# include "lex.yy.c" -.DE -.LP -in the last section of Yacc input. -Supposing the grammar to be -named ``good'' and the lexical rules to be named ``better'' -the UNIX command sequence can just be: -.DS I -yacc good -lex better -cc y.tab.c \-ly \-ll -.DE -.LP -The Yacc library (\-ly) should be loaded before the Lex library, -to obtain a main program which invokes the Yacc parser. -The generations of Lex and Yacc programs can be done in -either order. -.NH -Examples. -.PP -As a trivial problem, consider copying an input file while -adding 3 to every positive number divisible by 7. -Here is a suitable Lex source program: -.DS I -%% - int k; -[0\-9]+ { - k = atoi(yytext); - if (k%7 == 0) - printf("%d", k+3); - else - printf("%d",k); - } -.DE -.LP -The rule [0\-9]+ recognizes strings of digits; -.I -atoi -.R -converts the digits to binary -and stores the result in -.ul -k. -The operator % (remainder) is used to check whether -.ul -k -is divisible by 7; if it is, -it is incremented by 3 as it is written out. -It may be objected that this program will alter such -input items as -.I 49.63 -or -.I X7 . -Furthermore, it increments the absolute value -of all negative numbers divisible by 7. -To avoid this, just add a few more rules after the active one, -as here: -.DS I -%% - int k; -\-?[0\-9]+ { - k = atoi(yytext); - printf("%d", - k%7 == 0 ? k+3 : k); - } -\-?[0\-9.]+ ECHO; -[A-Za-z][A-Za-z0-9]+ ECHO; -.DE -.LP -Numerical strings containing -a ``.'' or preceded by a letter will be picked up by -one of the last two rules, and not changed. -The -.I if\-else -has been replaced by -a C conditional expression to save space; -the form -.ul -a?b:c -means ``if -.I a -then -.I b -else -.I c ''. -.PP -For an example of statistics gathering, here -is a program which histograms the lengths -of words, where a word is defined as a string of letters. -.DS - int lengs[100]; -%% -[a\-z]+ lengs[yyleng]++; -\&. | -\en ; -%% -yywrap() -{ -int i; -printf("Length No. words\en"); -for(i=0; i<100; i++) - if (lengs[i] > 0) - printf("%5d%10d\en",i,lengs[i]); -return(1); -} -.DE -.LP -This program -accumulates the histogram, while producing no output. At the end -of the input it prints the table. -The final statement -.I -return(1); -.R -indicates that Lex is to perform wrapup. If -.I -yywrap -.R -returns zero (false) -it implies that further input is available -and the program is -to continue reading and processing. -To provide a -.I -yywrap -.R -that never -returns true causes an infinite loop. -.PP -As a larger example, -here are some parts of a program written by N. L. Schryer -to convert double precision Fortran to single precision Fortran. -Because Fortran does not distinguish upper and lower case letters, -this routine begins by defining a set of classes including -both cases of each letter: -.DS I -a [aA] -b [bB] -c [cC] -\&... -z [zZ] -.DE -.LP -An additional class recognizes white space: -.DS I -W [ \et]\(** -.DE -.LP -The first rule changes -``double precision'' to ``real'', or ``DOUBLE PRECISION'' to ``REAL''. -.DS I -{d}{o}{u}{b}{l}{e}{W}{p}{r}{e}{c}{i}{s}{i}{o}{n} { - printf(yytext[0]==\(fmd\(fm? "real" : "REAL"); - } -.DE -.LP -Care is taken throughout this program to preserve the case -(upper or lower) -of the original program. -The conditional operator is used to -select the proper form of the keyword. -The next rule copies continuation card indications to -avoid confusing them with constants: -.DS I -^" "[^ 0] ECHO; -.DE -.LP -In the regular expression, the quotes surround the -blanks. -It is interpreted as -``beginning of line, then five blanks, then -anything but blank or zero.'' -Note the two different meanings of -.I ^ . -There follow some rules to change double precision -constants to ordinary floating constants. -.DS I -[0\-9]+{W}{d}{W}[+\-]?{W}[0\-9]+ | -[0\-9]+{W}"."{W}{d}{W}[+\-]?{W}[0\-9]+ | -"."{W}[0\-9]+{W}{d}{W}[+\-]?{W}[0\-9]+ { - /\(** convert constants \(**/ - for(p=yytext; \(**p != 0; p++) - { - if (\(**p == \(fmd\(fm || \(**p == \(fmD\(fm) - \(**p=+ \(fme\(fm\- \(fmd\(fm; - ECHO; - } -.DE -.LP -After the floating point constant is recognized, it is -scanned by the -.ul -for -loop -to find the letter -.I d -or -.I D . -The program than adds -.I \(fme\(fm\-\(fmd\(fm , -which converts -it to the next letter of the alphabet. -The modified constant, now single-precision, -is written out again. -There follow a series of names which must be respelled to remove -their initial \fId\fR. -By using the -array -.I -yytext -.R -the same action suffices for all the names (only a sample of -a rather long list is given here). -.DS I -{d}{s}{i}{n} | -{d}{c}{o}{s} | -{d}{s}{q}{r}{t} | -{d}{a}{t}{a}{n} | -\&... -{d}{f}{l}{o}{a}{t} printf("%s",yytext+1); -.DE -.LP -Another list of names must have initial \fId\fR changed to initial \fIa\fR: -.DS I -{d}{l}{o}{g} | -{d}{l}{o}{g}10 | -{d}{m}{i}{n}1 | -{d}{m}{a}{x}1 { - yytext[0] =+ \(fma\(fm \- \(fmd\(fm; - ECHO; - } -.DE -.LP -And one routine -must have initial \fId\fR changed to initial \fIr\fR: -.DS I -{d}1{m}{a}{c}{h} {yytext[0] =+ \(fmr\(fm \- \(fmd\(fm; - ECHO; - } -.DE -.LP -To avoid such names as \fIdsinx\fR being detected as instances -of \fIdsin\fR, some final rules pick up longer words as identifiers -and copy some surviving characters: -.DS I -[A\-Za\-z][A\-Za\-z0\-9]\(** | -[0\-9]+ | -\en | -\&. ECHO; -.DE -.LP -Note that this program is not complete; it -does not deal with the spacing problems in Fortran or -with the use of keywords as identifiers. -.br -.NH -Left Context Sensitivity. -.PP -Sometimes -it is desirable to have several sets of lexical rules -to be applied at different times in the input. -For example, a compiler preprocessor might distinguish -preprocessor statements and analyze them differently -from ordinary statements. -This requires -sensitivity -to prior context, and there are several ways of handling -such problems. -The \fI^\fR operator, for example, is a prior context operator, -recognizing immediately preceding left context just as \fI$\fR recognizes -immediately following right context. -Adjacent left context could be extended, to produce a facility similar to -that for adjacent right context, but it is unlikely -to be as useful, since often the relevant left context -appeared some time earlier, such as at the beginning of a line. -.PP -This section describes three means of dealing -with different environments: a simple use of flags, -when only a few rules change from one environment to another, -the use of -.I -start conditions -.R -on rules, -and the possibility of making multiple lexical analyzers all run -together. -In each case, there are rules which recognize the need to change the -environment in which the -following input text is analyzed, and set some parameter -to reflect the change. This may be a flag explicitly tested by -the user's action code; such a flag is the simplest way of dealing -with the problem, since Lex is not involved at all. -It may be more convenient, -however, -to have Lex remember the flags as initial conditions on the rules. -Any rule may be associated with a start condition. It will only -be recognized when Lex is in -that start condition. -The current start condition may be changed at any time. -Finally, if the sets of rules for the different environments -are very dissimilar, -clarity may be best achieved by writing several distinct lexical -analyzers, and switching from one to another as desired. -.PP -Consider the following problem: copy the input to the output, -changing the word \fImagic\fR to \fIfirst\fR on every line which began -with the letter \fIa\fR, changing \fImagic\fR to \fIsecond\fR on every line -which began with the letter \fIb\fR, and changing -\fImagic\fR to \fIthird\fR on every line which began -with the letter \fIc\fR. All other words and all other lines -are left unchanged. -.PP -These rules are so simple that the easiest way -to do this job is with a flag: -.DS - int flag; -%% -^a {flag = \(fma\(fm; ECHO;} -^b {flag = \(fmb\(fm; ECHO;} -^c {flag = \(fmc\(fm; ECHO;} -\en {flag = 0 ; ECHO;} -magic { - switch (flag) - { - case \(fma\(fm: printf("first"); break; - case \(fmb\(fm: printf("second"); break; - case \(fmc\(fm: printf("third"); break; - default: ECHO; break; - } - } -.DE -.LP -should be adequate. -.PP -To handle the same problem with start conditions, each -start condition must be introduced to Lex in the definitions section -with a line reading -.DS I -%s name1 name2 ... -.DE -.LP -or -.DS I -%x name1 name2 ... -.DE -.LP -where the conditions may be named in any order. -`%s' denotes \fIinclusive\fR start conditions and `%x' denotes -\fIexclusive\fR start conditions. -The conditions may be referenced at the -head of a rule with the <> brackets: -.DS I -expression -.DE -.LP -is a rule which is only recognized when Lex is in the -start condition \fIname1\fR. -To enter a start condition, -execute the action statement -.DS I -BEGIN name1; -.DE -.LP -which changes the start condition to \fIname1\fR. -Until the next BEGIN action is executed, rules with the given -start condition will be active and rules with other start conditions -will be inactive. If the start condition is inclusive, then -rules with no start conditions at all will also be active. If it is -exclusive, then only rules qualified with the start condition will be active. -.PP -To resume the normal state, -.DS I -BEGIN 0; -.DE -.LP -resets the initial condition -of the Lex automaton interpreter. -A rule may be active in several -start conditions: -.DS I - -.DE -.LP -is a legal prefix. -.PP -The same example as before can be written: -.DS I -%START AA BB CC -%% -^a {ECHO; BEGIN AA;} -^b {ECHO; BEGIN BB;} -^c {ECHO; BEGIN CC;} -\en {ECHO; BEGIN 0;} -magic printf("first"); -magic printf("second"); -magic printf("third"); -.DE -.LP -where the logic is exactly the same as in the previous -method of handling the problem, but Lex does the work -rather than the user's code. -.\" .NH -.\" Character Set. -.\" .PP -.\" The programs generated by Lex handle -.\" character I/O only through the routines -.\" .I -.\" input, -.\" output, -.\" .R -.\" and -.\" .I -.\" unput. -.\" .R -.\" Thus the character representation -.\" provided in these routines -.\" is accepted by Lex and employed to return -.\" values in -.\" .I -.\" yytext. -.\" .R -.\" For internal use -.\" a character is represented as a small integer -.\" which, if the standard library is used, -.\" has a value equal to the integer value of the bit -.\" pattern representing the character on the host computer. -.\" Normally, the letter -.\" .I a -.\" is represented as the same form as the character constant -.\" .I \(fma\(fm . -.\" If this interpretation is changed, by providing I/O -.\" routines which translate the characters, -.\" Lex must be told about -.\" it, by giving a translation table. -.\" This table must be in the definitions section, -.\" and must be bracketed by lines containing only -.\" ``%T''. -.\" The table contains lines of the form -.\" .DS I -.\" {integer} {character string} -.\" .DE -.\" .LP -.\" which indicate the value associated with each character. -.\" Thus the next example -.\" .DS I -.\" %T -.\" 1 Aa -.\" 2 Bb -.\" \&... -.\" 26 Zz -.\" 27 \en -.\" 28 + -.\" 29 \- -.\" 30 0 -.\" 31 1 -.\" \&... -.\" 39 9 -.\" %T -.\" .DE -.\" .LP 1 -.\" Sample character table. -.\" maps the lower and upper case letters together into the integers 1 through 26, -.\" newline into 27, + and \- into 28 and 29, and the -.\" digits into 30 through 39. -.\" Note the escape for newline. -.\" If a table is supplied, every character that is to appear either -.\" in the rules or in any valid input must be included -.\" in the table. -.\" No character -.\" may be assigned the number 0, and no character may be -.\" assigned a bigger number than the size of the hardware character set. -.NH -Summary of Source Format. -.PP -The general form of a Lex source file is: -.DS I -{definitions} -%% -{rules} -%% -{user subroutines} -.DE -.LP -The definitions section contains -a combination of -.IP 1) -Definitions, in the form ``name space translation''. -.IP 2) -Included code, in the form ``space code''. -.IP 3) -Included code, in the form -.DS I -%{ -code -%} -.DE -.ns -.IP 4) -Start conditions, given in the form -.DS I -%s name1 name2 ... -.DE -.\" .ns -.\" .IP 5) -.\" Character set tables, in the form -.\" .DS I -.\" %T -.\" number space character-string -.\" \&... -.\" %T -.\" .DE -.\" .ns -.\" .IP 5) -.\" Changes to internal array sizes, in the form -.\" .DS I -.\" %\fIx\fR\0\0\fInnn\fR -.\" .DE -.\" .LP -.\" where \fInnn\fR is a decimal integer representing an array size -.\" and \fIx\fR selects the parameter as follows: -.\" .DS I -.\" Letter Parameter -.\" p positions -.\" n states -.\" e tree nodes -.\" a transitions -.\" k packed character classes -.\" o output array size -.\" .DE -.LP -Lines in the rules section have the form ``expression action'' -where the action may be continued on succeeding -lines by using braces to delimit it. -.PP -Regular expressions in Lex use the following -operators: -.br -.DS I -x the character "x" -"x" an "x", even if x is an operator. -\ex an "x", even if x is an operator. -[xy] the character x or y. -[x\-z] the characters x, y or z. -[^x] any character but x. -\&. any character but newline. -^x an x at the beginning of a line. -x an x when Lex is in start condition y. -x$ an x at the end of a line. -x? an optional x. -x\(** 0,1,2, ... instances of x. -x+ 1,2,3, ... instances of x. -x|y an x or a y. -(x) an x. -x/y an x but only if followed by y. -{xx} the translation of xx from the - definitions section. -x{m,n} \fIm\fR through \fIn\fR occurrences of x -.DE -.\" .NH -.\" Caveats and Bugs. -.\" .PP -.\" There are pathological expressions which -.\" produce exponential growth of the tables when -.\" converted to deterministic machines; -.\" fortunately, they are rare. -.\" .PP -.\" REJECT does not rescan the input; instead it remembers the results of the previous -.\" scan. This means that if a rule with trailing context is found, and -.\" REJECT executed, the user -.\" must not have used -.\" .ul -.\" unput -.\" to change the characters forthcoming -.\" from the input stream. -.\" This is the only restriction on the user's ability to manipulate -.\" the not-yet-processed input. -.\" .PP -.\" .NH -.\" Acknowledgments. -.\" .PP -.\" As should -.\" be obvious from the above, the outside of Lex -.\" is patterned -.\" on Yacc and the inside on Aho's string matching routines. -.\" Therefore, both S. C. Johnson and A. V. Aho -.\" are really originators -.\" of much of Lex, -.\" as well as debuggers of it. -.\" Many thanks are due to both. -.\" .PP -.\" The code of the current version of Lex was designed, written, -.\" and debugged by Eric Schmidt. -.\" .SG MH-1274-MEL-unix -.\" .sp 1 -.\" .2C -.NH -References. -.sp 1v -.IP 1. -B. W. Kernighan and D. M. Ritchie, -.I -The C Programming Language, -.R -Prentice-Hall, N. J. (1978). -.IP 2. -B. W. Kernighan, -.I -Ratfor: A Preprocessor for a Rational Fortran, -.R -Software \- Practice and Experience, -\fB5\fR, pp. 395-496 (1975). -.IP 3. -S. C. Johnson, -.I -Yacc: Yet Another Compiler Compiler, -.R -Computing Science Technical Report No. 32, -1975, -.MH -.\" .if \n(tm (also TM 75-1273-6) -.IP 4. -A. V. Aho and M. J. Corasick, -.I -Efficient String Matching: An Aid to Bibliographic Search, -.R -Comm. ACM -.B -18, -.R -333-340 (1975). -.IP 5. -B. W. Kernighan, D. M. Ritchie and K. L. Thompson, -.I -QED Text Editor, -.R -Computing Science Technical Report No. 5, -1972, -.MH -.IP 6. -D. M. Ritchie, -private communication. -See also -M. E. Lesk, -.I -The Portable C Library, -.R -Computing Science Technical Report No. 31, -.MH -.\" .if \n(tm (also TM 75-1274-11) diff --git a/third_party/lex/libmain.c b/third_party/lex/libmain.c deleted file mode 100644 index 3bd417d7..00000000 --- a/third_party/lex/libmain.c +++ /dev/null @@ -1,18 +0,0 @@ -#if 0 -/*─────────────────────────────────────────────────────────────────╗ -│ To the extent possible under law, Justine Tunney has waived │ -│ all copyright and related or neighboring rights to this file, │ -│ as it is written in the following disclaimers: │ -│ • http://unlicense.org/ │ -│ • http://creativecommons.org/publicdomain/zero/1.0/ │ -╚─────────────────────────────────────────────────────────────────*/ -#endif - -int yylex(); - -int main(int argc, char *argv[]) { - for (;;) { - if (!yylex()) break; - } - return 0; -} diff --git a/third_party/lex/libyywrap.c b/third_party/lex/libyywrap.c deleted file mode 100644 index 3a6bd1f7..00000000 --- a/third_party/lex/libyywrap.c +++ /dev/null @@ -1,31 +0,0 @@ -/* clang-format off */ -/* $OpenBSD: libyywrap.c,v 1.9 2015/11/19 22:52:40 tedu Exp $ */ - -/* libyywrap - flex run-time support library "yywrap" function */ - -/* 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. */ - -int -yywrap(void) -{ - return 1; -} diff --git a/third_party/lex/main.c b/third_party/lex/main.c deleted file mode 100644 index dc518540..00000000 --- a/third_party/lex/main.c +++ /dev/null @@ -1,1826 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -asm(".include \"third_party/lex/COPYING\""); - -/* $OpenBSD: main.c,v 1.27 2017/01/21 08:33:07 krw Exp $ */ - -/* flex - tool to generate fast lexical analyzers */ - -/* 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. */ - - - -#include "flexdef.h" -#include "version.h" -#include "options.h" -#include "libc/calls/calls.h" -#include "libc/fmt/fmt.h" -#include "libc/str/str.h" -#include "libc/mem/mem.h" -#include "libc/math.h" -#include "libc/fmt/conv.h" -#include "libc/log/log.h" -#include "libc/runtime/gc.h" -#include "libc/x/x.h" -#include "libc/runtime/runtime.h" -#include "libc/x/x.h" -#include "libc/bits/safemacros.internal.h" -#include "libc/bits/safemacros.internal.h" -#include "tables.h" - -static char flex_version[] = FLEX_VERSION; - -/* declare functions that have forward references */ - -void flexinit PROTO((int, char **)); -void readin PROTO((void)); -void set_up_initial_allocations PROTO((void)); -static char *basename2 PROTO((char *path, int should_strip_ext)); - - -/* these globals are all defined and commented in flexdef.h */ -int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; -int interactive, lex_compat, posix_compat, do_yylineno, useecs, fulltbl, - usemecs; -int fullspd, gen_line_dirs, performance_report, backing_up_report; -int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap, csize; -int reentrant, bison_bridge_lval, bison_bridge_lloc; -int yymore_used, reject, real_reject, continued_action, in_rule; -int yymore_really_used, reject_really_used; -int datapos, dataline, linenum; -FILE *skelfile = NULL; -int skel_ind = 0; -char *action_array; -int action_size, defs1_offset, prolog_offset, action_offset, action_index; -char *infilename = NULL, *outfilename = NULL, *headerfilename = NULL; -int did_outfilename; -char *prefix, *yyclass, *extra_type = NULL; -int do_stdinit, use_stdout; -int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; -int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; -int maximum_mns, current_mns, current_max_rules; -int num_rules, num_eof_rules, default_rule, lastnfa; -int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; -int *accptnum, *assoc_rule, *state_type; -int *rule_type, *rule_linenum, *rule_useful; -int current_state_type; -int variable_trailing_context_rules; -int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; -int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; -int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1]; -int tecbck[CSIZE + 1]; -int lastsc, *scset, *scbol, *scxclu, *sceof; -int current_max_scs; -char **scname; -int current_max_dfa_size, current_max_xpairs; -int current_max_template_xpairs, current_max_dfas; -int lastdfa, *nxt, *chk, *tnxt; -int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; -union dfaacc_union *dfaacc; -int *accsiz, *dhash, numas; -int numsnpairs, jambase, jamstate; -int lastccl, *cclmap, *ccllen, *cclng, cclreuse; -int current_maxccls, current_max_ccl_tbl_size; -u_char *ccltbl; -char nmstr[MAXLINE]; -int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; -int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; -int num_backing_up, bol_needed; -FILE *backing_up_file; -int end_of_buffer_state; -char **input_files; -int num_input_files; -jmp_buf flex_main_jmp_buf; -bool *rule_has_nl, *ccl_has_nl; -int nlch = '\n'; -bool ansi_func_defs, ansi_func_protos; - -bool tablesext, tablesverify, gentables; -char *tablesfilename = 0, *tablesname = 0; -struct yytbl_writer tableswr; - -/* Make sure program_name is initialized so we don't crash if writing - * out an error message before getting the program name from argv[0]. - */ -char *program_name = "flex"; - -static const char *outfile_template = "lex.%s.%s"; -static const char *backing_name = "lex.backup"; -static const char *tablesfile_template = "lex.%s.tables"; - -/* From scan.l */ -extern FILE *yyout; - -static char outfile_path[MAXLINE]; -static int outfile_created = 0; -static char *skelname = NULL; -static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */ -const char *escaped_qstart = "[[]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[]]"; -const char *escaped_qend = "[[]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[]]"; - -/* For debugging. The max number of filters to apply to skeleton. */ -static int preproc_level = 1000; - -int flex_main PROTO((int argc, char *argv[])); -int main PROTO((int argc, char *argv[])); - -int -flex_main(argc, argv) - int argc; - char *argv[]; -{ - int i, exit_status, child_status; - - /* - * Set a longjmp target. Yes, I know it's a hack, but it gets worse: - * The return value of setjmp, if non-zero, is the desired exit code - * PLUS ONE. For example, if you want 'main' to return with code '2', - * then call longjmp() with an argument of 3. This is because it is - * invalid to specify a value of 0 to longjmp. FLEX_EXIT(n) should be - * used instead of exit(n); - */ - exit_status = setjmp(flex_main_jmp_buf); - if (exit_status) { - if (stdout && !_stdout_closed && !ferror(stdout)) { - fflush(stdout); - fclose(stdout); - } - while (wait(&child_status) > 0) { - if (!WIFEXITED(child_status) - || WEXITSTATUS(child_status) != 0) { - /* - * report an error of a child - */ - if (exit_status <= 1) - exit_status = 2; - - } - } - return exit_status - 1; - } - flexinit(argc, argv); - - readin(); - - skelout(); - /* %% [1.5] DFA */ - ntod(); - - for (i = 1; i <= num_rules; ++i) - if (!rule_useful[i] && i != default_rule) - line_warning(_("rule cannot be matched"), - rule_linenum[i]); - - if (spprdflt && !reject && rule_useful[default_rule]) - line_warning(_ - ("-s option given but default rule can be matched"), - rule_linenum[default_rule]); - - /* Generate the C state transition tables from the DFA. */ - make_tables(); - - /* - * Note, flexend does not return. It exits with its argument as - * status. - */ - flexend(0); - - return 0; /* keep compilers/lint happy */ -} - -/* Wrapper around flex_main, so flex_main can be built as a library. */ -int -main(argc, argv) - int argc; - char *argv[]; -{ -#if ENABLE_NLS -#if HAVE_LOCALE_H - setlocale(LC_MESSAGES, ""); - setlocale(LC_CTYPE, ""); - textdomain(PACKAGE); - bindtextdomain(PACKAGE, LOCALEDIR); -#endif -#endif - - pledge("stdio rpath wpath cpath proc exec", NULL); - return flex_main(argc, argv); -} - -/* check_options - check user-specified options */ - -void -check_options() -{ - int i; - - if (lex_compat) { - if (C_plus_plus) - flexerror(_("Can't use -+ with -l option")); - - if (fulltbl || fullspd) - flexerror(_("Can't use -f or -F with -l option")); - - if (reentrant || bison_bridge_lval) - flexerror(_ - ("Can't use --reentrant or --bison-bridge with -l option")); - - yytext_is_array = true; - do_yylineno = true; - use_read = false; - } -#if 0 - /* This makes no sense whatsoever. I'm removing it. */ - if (do_yylineno) - /* This should really be "maintain_backup_tables = true" */ - reject_really_used = true; -#endif - - if (csize == unspecified) { - if ((fulltbl || fullspd) && !useecs) - csize = DEFAULT_CSIZE; - else - csize = CSIZE; - } - if (interactive == unspecified) { - if (fulltbl || fullspd) - interactive = false; - else - interactive = true; - } - if (fulltbl || fullspd) { - if (usemecs) - flexerror(_ - ("-Cf/-CF and -Cm don't make sense together")); - - if (interactive) - flexerror(_("-Cf/-CF and -I are incompatible")); - - if (lex_compat) - flexerror(_ - ("-Cf/-CF are incompatible with lex-compatibility mode")); - - - if (fulltbl && fullspd) - flexerror(_ - ("-Cf and -CF are mutually exclusive")); - } - if (C_plus_plus && fullspd) - flexerror(_("Can't use -+ with -CF option")); - - if (C_plus_plus && yytext_is_array) { - lexwarn(_("%array incompatible with -+ option")); - yytext_is_array = false; - } - if (C_plus_plus && (reentrant)) - flexerror(_("Options -+ and --reentrant are mutually exclusive.")); - - if (C_plus_plus && bison_bridge_lval) - flexerror(_("bison bridge not supported for the C++ scanner.")); - - - if (useecs) { /* Set up doubly-linked equivalence classes. */ - - /* - * We loop all the way up to csize, since ecgroup[csize] is - * the position used for NUL characters. - */ - ecgroup[1] = NIL; - - for (i = 2; i <= csize; ++i) { - ecgroup[i] = i - 1; - nextecm[i - 1] = i; - } - - nextecm[csize] = NIL; - } else { - /* Put everything in its own equivalence class. */ - for (i = 1; i <= csize; ++i) { - ecgroup[i] = i; - nextecm[i] = BAD_SUBSCRIPT; /* to catch errors */ - } - } - - if (!ansi_func_defs) - buf_m4_define(&m4defs_buf, "M4_YY_NO_ANSI_FUNC_DEFS", NULL); - - if (!ansi_func_protos) - buf_m4_define(&m4defs_buf, "M4_YY_NO_ANSI_FUNC_PROTOS", NULL); - - if (extra_type) - buf_m4_define(&m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type); - - if (!use_stdout) { - FILE *prev_stdout; - - if (!did_outfilename) { - char *suffix; - - if (C_plus_plus) - suffix = "cc"; - else - suffix = "c"; - - snprintf(outfile_path, sizeof(outfile_path), outfile_template, - prefix, suffix); - - outfilename = outfile_path; - } - prev_stdout = freopen(outfilename, "w+", stdout); - - if (prev_stdout == NULL) - lerrsf(_("could not create %s"), outfilename); - - outfile_created = 1; - } - /* Setup the filter chain. */ - output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); - filter_create_ext(output_chain, firstnonnull(getenv("M4"), gc(xasprintf("o/%s/third_party/m4/m4.com.dbg", nulltoempty(getenv("MODE"))))), "-P", "-g", 0); - filter_create_int(output_chain, filter_fix_linedirs, NULL); - - /* For debugging, only run the requested number of filters. */ - if (preproc_level > 0) { - filter_truncate(output_chain, preproc_level); - filter_apply_chain(output_chain); - } - yyout = stdout; - - - /* always generate the tablesverify flag. */ - buf_m4_define(&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); - if (tablesext) - gentables = false; - - if (tablesverify) - /* force generation of C tables. */ - gentables = true; - - - if (tablesext) { - FILE *tablesout; - struct yytbl_hdr hdr; - char *pname = 0; - int nbytes = 0; - - buf_m4_define(&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL); - - if (!tablesfilename) { - nbytes = strlen(prefix) + strlen(tablesfile_template) + 2; - tablesfilename = pname = (char *) calloc(nbytes, 1); - snprintf(pname, nbytes, tablesfile_template, prefix); - } - if ((tablesout = fopen(tablesfilename, "w")) == NULL) - lerrsf(_("could not create %s"), tablesfilename); - free(pname); - tablesfilename = 0; - - yytbl_writer_init(&tableswr, tablesout); - - nbytes = strlen(prefix) + strlen("tables") + 2; - tablesname = (char *) calloc(nbytes, 1); - snprintf(tablesname, nbytes, "%stables", prefix); - yytbl_hdr_init(&hdr, flex_version, tablesname); - - if (yytbl_hdr_fwrite(&tableswr, &hdr) <= 0) - flexerror(_("could not write tables header")); - } - if (skelname && (skelfile = fopen(skelname, "r")) == NULL) - lerrsf(_("can't open skeleton file %s"), skelname); - - if (reentrant) { - buf_m4_define(&m4defs_buf, "M4_YY_REENTRANT", NULL); - if (yytext_is_array) - buf_m4_define(&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL); - } - if (bison_bridge_lval) - buf_m4_define(&m4defs_buf, "M4_YY_BISON_LVAL", NULL); - - if (bison_bridge_lloc) - buf_m4_define(&m4defs_buf, "", NULL); - - buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix); - - if (did_outfilename) - line_directive_out(stdout, 0); - - if (do_yylineno) - buf_m4_define(&m4defs_buf, "M4_YY_USE_LINENO", NULL); - - /* Create the alignment type. */ - buf_strdefine(&userdef_buf, "YY_INT_ALIGNED", - long_align ? "long int" : "short int"); - - /* Define the start condition macros. */ - { - struct Buf tmpbuf; - buf_init(&tmpbuf, sizeof(char)); - for (i = 1; i <= lastsc; i++) { - char *str, *fmt = "#define %s %d\n"; - size_t strsz; - - str = (char *) malloc(strsz = strlen(fmt) + strlen(scname[i]) + (int) (1 + log10(i)) + 2); - if (!str) - flexfatal(_("allocation of macro definition failed")); - snprintf(str, strsz, fmt, scname[i], i - 1); - buf_strappend(&tmpbuf, str); - free(str); - } - buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); - buf_destroy(&tmpbuf); - } - - /* This is where we begin writing to the file. */ - - /* Dump the %top code. */ - if (top_buf.elts) - outn((char *) top_buf.elts); - - /* Dump the m4 definitions. */ - buf_print_strings(&m4defs_buf, stdout); - m4defs_buf.nelts = 0; /* memory leak here. */ - - /* Place a bogus line directive, it will be fixed in the filter. */ - outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n"); - - /* Dump the user defined preproc directives. */ - if (userdef_buf.elts) - outn((char *) (userdef_buf.elts)); - - skelout(); - /* %% [1.0] */ -} - -/* flexend - terminate flex - * - * note - * This routine does not return. - */ - -void -flexend(exit_status) - int exit_status; - -{ - static int called_before = -1; /* prevent infinite recursion. */ - int tblsiz; - - if (++called_before) - FLEX_EXIT(exit_status); - - if (skelfile != NULL) { - if (ferror(skelfile)) - lerrsf(_("input error reading skeleton file %s"), - skelname); - - else if (fclose(skelfile)) - lerrsf(_("error closing skeleton file %s"), - skelname); - } -#if 0 - fprintf(header_out, - "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n"); - fprintf(header_out, - "/* Beware! Start conditions are not prefixed. */\n"); - - /* Special case for "INITIAL" */ - fprintf(header_out, - "#undef INITIAL\n#define INITIAL 0\n"); - for (i = 2; i <= lastsc; i++) - fprintf(header_out, "#define %s %d\n", scname[i], i - 1); - fprintf(header_out, - "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); - - /* - * Kill ALL flex-related macros. This is so the user can #include - * more than one generated header file. - */ - fprintf(header_out, "#ifndef YY_HEADER_NO_UNDEFS\n"); - fprintf(header_out, - "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n"); - - { - const char *undef_list[] = { - - "BEGIN", - "ECHO", - "EOB_ACT_CONTINUE_SCAN", - "EOB_ACT_END_OF_FILE", - "EOB_ACT_LAST_MATCH", - "FLEX_SCANNER", - "FLEX_STD", - "REJECT", - "YYFARGS0", - "YYFARGS1", - "YYFARGS2", - "YYFARGS3", - "YYLMAX", - "YYSTATE", - "YY_AT_BOL", - "YY_BREAK", - "YY_BUFFER_EOF_PENDING", - "YY_BUFFER_NEW", - "YY_BUFFER_NORMAL", - "YY_BUF_SIZE", - "M4_YY_CALL_LAST_ARG", - "M4_YY_CALL_ONLY_ARG", - "YY_CURRENT_BUFFER", - "YY_DECL", - "M4_YY_DECL_LAST_ARG", - "M4_YY_DEF_LAST_ARG", - "M4_YY_DEF_ONLY_ARG", - "YY_DO_BEFORE_ACTION", - "YY_END_OF_BUFFER", - "YY_END_OF_BUFFER_CHAR", - "YY_EXIT_FAILURE", - "YY_EXTRA_TYPE", - "YY_FATAL_ERROR", - "YY_FLEX_DEFINED_ECHO", - "YY_FLEX_LEX_COMPAT", - "YY_FLEX_MAJOR_VERSION", - "YY_FLEX_MINOR_VERSION", - "YY_FLEX_SUBMINOR_VERSION", - "YY_FLUSH_BUFFER", - "YY_G", - "YY_INPUT", - "YY_INTERACTIVE", - "YY_INT_ALIGNED", - "YY_LAST_ARG", - "YY_LESS_LINENO", - "YY_LEX_ARGS", - "YY_LEX_DECLARATION", - "YY_LEX_PROTO", - "YY_MAIN", - "YY_MORE_ADJ", - "YY_NEED_STRLEN", - "YY_NEW_FILE", - "YY_NULL", - "YY_NUM_RULES", - "YY_ONLY_ARG", - "YY_PARAMS", - "YY_PROTO", - "M4_YY_PROTO_LAST_ARG", - "M4_YY_PROTO_ONLY_ARG void", - "YY_READ_BUF_SIZE", - "YY_REENTRANT", - "YY_RESTORE_YY_MORE_OFFSET", - "YY_RULE_SETUP", - "YY_SC_TO_UI", - "YY_SKIP_YYWRAP", - "YY_START", - "YY_START_STACK_INCR", - "YY_STATE_EOF", - "YY_STDINIT", - "YY_TRAILING_HEAD_MASK", - "YY_TRAILING_MASK", - "YY_USER_ACTION", - "YY_USE_CONST", - "YY_USE_PROTOS", - "unput", - "yyTABLES_NAME", - "yy_create_buffer", - "yy_delete_buffer", - "yy_flex_debug", - "yy_flush_buffer", - "yy_init_buffer", - "yy_load_buffer_state", - "yy_new_buffer", - "yy_scan_buffer", - "yy_scan_bytes", - "yy_scan_string", - "yy_set_bol", - "yy_set_interactive", - "yy_switch_to_buffer", - "yypush_buffer_state", - "yypop_buffer_state", - "yyensure_buffer_stack", - "yyalloc", - "yyconst", - "yyextra", - "yyfree", - "yyget_debug", - "yyget_extra", - "yyget_in", - "yyget_leng", - "yyget_lineno", - "yyget_lloc", - "yyget_lval", - "yyget_out", - "yyget_text", - "yyin", - "yyleng", - "yyless", - "yylex", - "yylex_destroy", - "yylex_init", - "yylex_init_extra", - "yylineno", - "yylloc", - "yylval", - "yymore", - "yyout", - "yyrealloc", - "yyrestart", - "yyset_debug", - "yyset_extra", - "yyset_in", - "yyset_lineno", - "yyset_lloc", - "yyset_lval", - "yyset_out", - "yytables_destroy", - "yytables_fload", - "yyterminate", - "yytext", - "yytext_ptr", - "yywrap", - - /* must be null-terminated */ - NULL}; - - - for (i = 0; undef_list[i] != NULL; i++) - fprintf(header_out, "#undef %s\n", undef_list[i]); - } - - /* undef any of the auto-generated symbols. */ - for (i = 0; i < defs_buf.nelts; i++) { - - /* don't undef start conditions */ - if (sclookup(((char **) defs_buf.elts)[i]) > 0) - continue; - fprintf(header_out, "#undef %s\n", - ((char **) defs_buf.elts)[i]); - } - - fprintf(header_out, - "#endif /* !YY_HEADER_NO_UNDEFS */\n"); - fprintf(header_out, "\n"); - fprintf(header_out, "#undef %sIN_HEADER\n", prefix); - fprintf(header_out, "#endif /* %sHEADER_H */\n", prefix); - - if (ferror(header_out)) - lerrsf(_("error creating header file %s"), - headerfilename); - fflush(header_out); - fclose(header_out); -#endif - - if (exit_status != 0 && outfile_created) { - if (ferror(stdout)) - lerrsf(_("error writing output file %s"), - outfilename); - - else if ((_stdout_closed = 1) && fclose(stdout)) - lerrsf(_("error closing output file %s"), - outfilename); - - else if (unlink(outfilename)) - lerrsf(_("error deleting output file %s"), - outfilename); - } - if (backing_up_report && backing_up_file) { - if (num_backing_up == 0) - fprintf(backing_up_file, _("No backing up.\n")); - else if (fullspd || fulltbl) - fprintf(backing_up_file, - _ - ("%d backing up (non-accepting) states.\n"), - num_backing_up); - else - fprintf(backing_up_file, - _("Compressed tables always back up.\n")); - - if (ferror(backing_up_file)) - lerrsf(_("error writing backup file %s"), - backing_name); - - else if (fclose(backing_up_file)) - lerrsf(_("error closing backup file %s"), - backing_name); - } - if (printstats) { - fprintf(stderr, _("%s version %s usage statistics:\n"), - program_name, flex_version); - - fprintf(stderr, _(" scanner options: -")); - - if (C_plus_plus) - putc('+', stderr); - if (backing_up_report) - putc('b', stderr); - if (ddebug) - putc('d', stderr); - if (sf_case_ins()) - putc('i', stderr); - if (lex_compat) - putc('l', stderr); - if (posix_compat) - putc('X', stderr); - if (performance_report > 0) - putc('p', stderr); - if (performance_report > 1) - putc('p', stderr); - if (spprdflt) - putc('s', stderr); - if (reentrant) - fputs("--reentrant", stderr); - if (bison_bridge_lval) - fputs("--bison-bridge", stderr); - if (bison_bridge_lloc) - fputs("--bison-locations", stderr); - if (use_stdout) - putc('t', stderr); - if (printstats) - putc('v', stderr); /* always true! */ - if (nowarn) - putc('w', stderr); - if (interactive == false) - putc('B', stderr); - if (interactive == true) - putc('I', stderr); - if (!gen_line_dirs) - putc('L', stderr); - if (trace) - putc('T', stderr); - - if (csize == unspecified) - /* - * We encountered an error fairly early on, so csize - * never got specified. Define it now, to prevent - * bogus table sizes being written out below. - */ - csize = 256; - - if (csize == 128) - putc('7', stderr); - else - putc('8', stderr); - - fprintf(stderr, " -C"); - - if (long_align) - putc('a', stderr); - if (fulltbl) - putc('f', stderr); - if (fullspd) - putc('F', stderr); - if (useecs) - putc('e', stderr); - if (usemecs) - putc('m', stderr); - if (use_read) - putc('r', stderr); - - if (did_outfilename) - fprintf(stderr, " -o%s", outfilename); - - if (skelname) - fprintf(stderr, " -S%s", skelname); - - if (strcmp(prefix, "yy")) - fprintf(stderr, " -P%s", prefix); - - putc('\n', stderr); - - fprintf(stderr, _(" %d/%d NFA states\n"), - lastnfa, current_mns); - fprintf(stderr, _(" %d/%d DFA states (%d words)\n"), - lastdfa, current_max_dfas, totnst); - fprintf(stderr, _(" %d rules\n"), - num_rules + num_eof_rules - - 1 /* - 1 for def. rule */ ); - - if (num_backing_up == 0) - fprintf(stderr, _(" No backing up\n")); - else if (fullspd || fulltbl) - fprintf(stderr, - _ - (" %d backing-up (non-accepting) states\n"), - num_backing_up); - else - fprintf(stderr, - _ - (" Compressed tables always back-up\n")); - - if (bol_needed) - fprintf(stderr, - _(" Beginning-of-line patterns used\n")); - - fprintf(stderr, _(" %d/%d start conditions\n"), lastsc, - current_max_scs); - fprintf(stderr, - _ - (" %d epsilon states, %d double epsilon states\n"), - numeps, eps2); - - if (lastccl == 0) - fprintf(stderr, _(" no character classes\n")); - else - fprintf(stderr, - _ - (" %d/%d character classes needed %d/%d words of storage, %d reused\n"), - lastccl, current_maxccls, - cclmap[lastccl] + ccllen[lastccl], - current_max_ccl_tbl_size, cclreuse); - - fprintf(stderr, _(" %d state/nextstate pairs created\n"), - numsnpairs); - fprintf(stderr, - _(" %d/%d unique/duplicate transitions\n"), - numuniq, numdup); - - if (fulltbl) { - tblsiz = lastdfa * numecs; - fprintf(stderr, _(" %d table entries\n"), - tblsiz); - } else { - tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend; - - fprintf(stderr, - _(" %d/%d base-def entries created\n"), - lastdfa + numtemps, current_max_dfas); - fprintf(stderr, - _ - (" %d/%d (peak %d) nxt-chk entries created\n"), - tblend, current_max_xpairs, peakpairs); - fprintf(stderr, - _ - (" %d/%d (peak %d) template nxt-chk entries created\n"), - numtemps * nummecs, - current_max_template_xpairs, - numtemps * numecs); - fprintf(stderr, _(" %d empty table entries\n"), - nummt); - fprintf(stderr, _(" %d protos created\n"), - numprots); - fprintf(stderr, - _(" %d templates created, %d uses\n"), - numtemps, tmpuses); - } - - if (useecs) { - tblsiz = tblsiz + csize; - fprintf(stderr, - _ - (" %d/%d equivalence classes created\n"), - numecs, csize); - } - if (usemecs) { - tblsiz = tblsiz + numecs; - fprintf(stderr, - _ - (" %d/%d meta-equivalence classes created\n"), - nummecs, csize); - } - fprintf(stderr, - _ - (" %d (%d saved) hash collisions, %d DFAs equal\n"), - hshcol, hshsave, dfaeql); - fprintf(stderr, _(" %d sets of reallocations needed\n"), - num_reallocs); - fprintf(stderr, _(" %d total table entries needed\n"), - tblsiz); - } - FLEX_EXIT(exit_status); -} - - -/* flexinit - initialize flex */ - -void -flexinit(argc, argv) - int argc; - char **argv; -{ - int i, sawcmpflag, rv, optind; - char *arg; - scanopt_t sopt; - - printstats = syntaxerror = trace = spprdflt = false; - lex_compat = posix_compat = C_plus_plus = backing_up_report = - ddebug = fulltbl = false; - fullspd = long_align = nowarn = yymore_used = continued_action = - false; - do_yylineno = yytext_is_array = in_rule = reject = do_stdinit = - false; - yymore_really_used = reject_really_used = unspecified; - interactive = csize = unspecified; - do_yywrap = gen_line_dirs = usemecs = useecs = true; - reentrant = bison_bridge_lval = bison_bridge_lloc = false; - performance_report = 0; - did_outfilename = 0; - prefix = "yy"; - yyclass = 0; - use_read = use_stdout = false; - tablesext = tablesverify = false; - gentables = true; - tablesfilename = tablesname = NULL; - ansi_func_defs = ansi_func_protos = true; - - sawcmpflag = false; - - /* Initialize dynamic array for holding the rule actions. */ - action_size = 2048; /* default size of action array in bytes */ - action_array = allocate_character_array(action_size); - defs1_offset = prolog_offset = action_offset = action_index = 0; - action_array[0] = '\0'; - - /* Initialize any buffers. */ - buf_init(&userdef_buf, sizeof(char)); /* one long string */ - buf_init(&defs_buf, sizeof(char *)); /* list of strings */ - buf_init(&yydmap_buf, sizeof(char)); /* one long string */ - buf_init(&top_buf, sizeof(char)); /* one long string */ - - { - const char *m4defs_init_str[] = {"m4_changequote\n", - "m4_changequote([[, ]])\n"}; - buf_init(&m4defs_buf, sizeof(char *)); - buf_append(&m4defs_buf, &m4defs_init_str, 2); - } - - sf_init(); - - /* initialize regex lib */ - flex_init_regex(); - - /* Enable C++ if program name ends with '+'. */ - program_name = basename2(argv[0], 0); - - if (program_name[0] != '\0' && - program_name[strlen(program_name) - 1] == '+') - C_plus_plus = true; - - /* read flags */ - sopt = scanopt_init(flexopts, argc, argv, 0); - if (!sopt) { - /* This will only happen when flexopts array is altered. */ - fprintf(stderr, - _("Internal error. flexopts are malformed.\n")); - FLEX_EXIT(1); - } - while ((rv = scanopt(sopt, &arg, &optind)) != 0) { - - if (rv < 0) { - /* - * Scanopt has already printed an option-specific - * error message. - */ - fprintf(stderr, - _ - ("Try `%s --help' for more information.\n"), - program_name); - FLEX_EXIT(1); - } - switch ((enum flexopt_flag_t) rv) { - case OPT_CPLUSPLUS: - C_plus_plus = true; - break; - - case OPT_BATCH: - interactive = false; - break; - - case OPT_BACKUP: - backing_up_report = true; - break; - - case OPT_DONOTHING: - break; - - case OPT_COMPRESSION: - if (!sawcmpflag) { - useecs = false; - usemecs = false; - fulltbl = false; - sawcmpflag = true; - } - for (i = 0; arg && arg[i] != '\0'; i++) - switch (arg[i]) { - case 'a': - long_align = true; - break; - - case 'e': - useecs = true; - break; - - case 'F': - fullspd = true; - break; - - case 'f': - fulltbl = true; - break; - - case 'm': - usemecs = true; - break; - - case 'r': - use_read = true; - break; - - default: - lerrif(_ - ("unknown -C option '%c'"), - (int) arg[i]); - break; - } - break; - - case OPT_DEBUG: - ddebug = true; - break; - - case OPT_NO_DEBUG: - ddebug = false; - break; - - case OPT_FULL: - useecs = usemecs = false; - use_read = fulltbl = true; - break; - - case OPT_FAST: - useecs = usemecs = false; - use_read = fullspd = true; - break; - - case OPT_HELP: - usage(); - FLEX_EXIT(0); - - case OPT_INTERACTIVE: - interactive = true; - break; - - case OPT_CASE_INSENSITIVE: - sf_set_case_ins(true); - break; - - case OPT_LEX_COMPAT: - lex_compat = true; - break; - - case OPT_POSIX_COMPAT: - posix_compat = true; - break; - - case OPT_PREPROC_LEVEL: - preproc_level = strtol(arg, NULL, 0); - break; - - case OPT_MAIN: - buf_strdefine(&userdef_buf, "YY_MAIN", "1"); - do_yywrap = false; - break; - - case OPT_NO_MAIN: - buf_strdefine(&userdef_buf, "YY_MAIN", "0"); - break; - - case OPT_NO_LINE: - gen_line_dirs = false; - break; - - case OPT_OUTFILE: - outfilename = arg; - did_outfilename = 1; - break; - - case OPT_PREFIX: - prefix = arg; - break; - - case OPT_PERF_REPORT: - ++performance_report; - break; - - case OPT_BISON_BRIDGE: - bison_bridge_lval = true; - break; - - case OPT_BISON_BRIDGE_LOCATIONS: - bison_bridge_lval = bison_bridge_lloc = true; - break; - - case OPT_REENTRANT: - reentrant = true; - break; - - case OPT_NO_REENTRANT: - reentrant = false; - break; - - case OPT_SKEL: - skelname = arg; - break; - - case OPT_DEFAULT: - spprdflt = false; - break; - - case OPT_NO_DEFAULT: - spprdflt = true; - break; - - case OPT_STDOUT: - use_stdout = true; - break; - - case OPT_NO_UNISTD_H: - //buf_strdefine(&userdef_buf, "YY_NO_UNISTD_H", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_UNISTD_H", 0); - break; - - case OPT_TABLES_FILE: - tablesext = true; - tablesfilename = arg; - break; - - case OPT_TABLES_VERIFY: - tablesverify = true; - break; - - case OPT_TRACE: - trace = true; - break; - - case OPT_VERBOSE: - printstats = true; - break; - - case OPT_VERSION: - printf(_("%s %s\n"), program_name, flex_version); - FLEX_EXIT(0); - - case OPT_WARN: - nowarn = false; - break; - - case OPT_NO_WARN: - nowarn = true; - break; - - case OPT_7BIT: - csize = 128; - break; - - case OPT_8BIT: - csize = CSIZE; - break; - - case OPT_ALIGN: - long_align = true; - break; - - case OPT_NO_ALIGN: - long_align = false; - break; - - case OPT_ALWAYS_INTERACTIVE: - buf_m4_define(&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0); - break; - - case OPT_NEVER_INTERACTIVE: - buf_m4_define(&m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0); - break; - - case OPT_ARRAY: - yytext_is_array = true; - break; - - case OPT_POINTER: - yytext_is_array = false; - break; - - case OPT_ECS: - useecs = true; - break; - - case OPT_NO_ECS: - useecs = false; - break; - - case OPT_HEADER_FILE: - headerfilename = arg; - break; - - case OPT_META_ECS: - usemecs = true; - break; - - case OPT_NO_META_ECS: - usemecs = false; - break; - - case OPT_PREPROCDEFINE: - { - /* arg is "symbol" or "symbol=definition". */ - char *def2; - - for (def2 = arg; - *def2 != '\0' && *def2 != '='; ++def2); - - buf_strappend(&userdef_buf, "#define "); - if (*def2 == '\0') { - buf_strappend(&userdef_buf, arg); - buf_strappend(&userdef_buf, - " 1\n"); - } else { - buf_strnappend(&userdef_buf, arg, - def2 - arg); - buf_strappend(&userdef_buf, " "); - buf_strappend(&userdef_buf, - def2 + 1); - buf_strappend(&userdef_buf, "\n"); - } - } - break; - - case OPT_READ: - use_read = true; - break; - - case OPT_STACK: - //buf_strdefine(&userdef_buf, "YY_STACK_USED", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_STACK_USED", 0); - break; - - case OPT_STDINIT: - do_stdinit = true; - break; - - case OPT_NO_STDINIT: - do_stdinit = false; - break; - - case OPT_YYCLASS: - yyclass = arg; - break; - - case OPT_YYLINENO: - do_yylineno = true; - break; - - case OPT_NO_YYLINENO: - do_yylineno = false; - break; - - case OPT_YYWRAP: - do_yywrap = true; - break; - - case OPT_NO_YYWRAP: - do_yywrap = false; - break; - - case OPT_YYMORE: - yymore_really_used = true; - break; - - case OPT_NO_YYMORE: - yymore_really_used = false; - break; - - case OPT_REJECT: - reject_really_used = true; - break; - - case OPT_NO_REJECT: - reject_really_used = false; - break; - - case OPT_NO_ANSI_FUNC_DEFS: - ansi_func_defs = false; - break; - - case OPT_NO_ANSI_FUNC_PROTOS: - ansi_func_protos = false; - break; - - case OPT_NO_YY_PUSH_STATE: - //buf_strdefine(&userdef_buf, "YY_NO_PUSH_STATE", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_PUSH_STATE", 0); - break; - case OPT_NO_YY_POP_STATE: - //buf_strdefine(&userdef_buf, "YY_NO_POP_STATE", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_POP_STATE", 0); - break; - case OPT_NO_YY_TOP_STATE: - //buf_strdefine(&userdef_buf, "YY_NO_TOP_STATE", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_TOP_STATE", 0); - break; - case OPT_NO_UNPUT: - //buf_strdefine(&userdef_buf, "YY_NO_UNPUT", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_UNPUT", 0); - break; - case OPT_NO_YY_SCAN_BUFFER: - //buf_strdefine(&userdef_buf, "YY_NO_SCAN_BUFFER", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SCAN_BUFFER", 0); - break; - case OPT_NO_YY_SCAN_BYTES: - //buf_strdefine(&userdef_buf, "YY_NO_SCAN_BYTES", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SCAN_BYTES", 0); - break; - case OPT_NO_YY_SCAN_STRING: - //buf_strdefine(&userdef_buf, "YY_NO_SCAN_STRING", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SCAN_STRING", 0); - break; - case OPT_NO_YYGET_EXTRA: - //buf_strdefine(&userdef_buf, "YY_NO_GET_EXTRA", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_EXTRA", 0); - break; - case OPT_NO_YYSET_EXTRA: - //buf_strdefine(&userdef_buf, "YY_NO_SET_EXTRA", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_EXTRA", 0); - break; - case OPT_NO_YYGET_LENG: - //buf_strdefine(&userdef_buf, "YY_NO_GET_LENG", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_LENG", 0); - break; - case OPT_NO_YYGET_TEXT: - //buf_strdefine(&userdef_buf, "YY_NO_GET_TEXT", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_TEXT", 0); - break; - case OPT_NO_YYGET_LINENO: - //buf_strdefine(&userdef_buf, "YY_NO_GET_LINENO", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_LINENO", 0); - break; - case OPT_NO_YYSET_LINENO: - //buf_strdefine(&userdef_buf, "YY_NO_SET_LINENO", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_LINENO", 0); - break; - case OPT_NO_YYGET_IN: - //buf_strdefine(&userdef_buf, "YY_NO_GET_IN", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_IN", 0); - break; - case OPT_NO_YYSET_IN: - //buf_strdefine(&userdef_buf, "YY_NO_SET_IN", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_IN", 0); - break; - case OPT_NO_YYGET_OUT: - //buf_strdefine(&userdef_buf, "YY_NO_GET_OUT", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_OUT", 0); - break; - case OPT_NO_YYSET_OUT: - //buf_strdefine(&userdef_buf, "YY_NO_SET_OUT", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_OUT", 0); - break; - case OPT_NO_YYGET_LVAL: - //buf_strdefine(&userdef_buf, "YY_NO_GET_LVAL", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_LVAL", 0); - break; - case OPT_NO_YYSET_LVAL: - //buf_strdefine(&userdef_buf, "YY_NO_SET_LVAL", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_LVAL", 0); - break; - case OPT_NO_YYGET_LLOC: - //buf_strdefine(&userdef_buf, "YY_NO_GET_LLOC", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_GET_LLOC", 0); - break; - case OPT_NO_YYSET_LLOC: - //buf_strdefine(&userdef_buf, "YY_NO_SET_LLOC", "1"); - buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_LLOC", 0); - break; - - } /* switch */ - } /* while scanopt() */ - - scanopt_destroy(sopt); - - num_input_files = argc - optind; - input_files = argv + optind; - set_input_file(num_input_files > 0 ? input_files[0] : NULL); - - lastccl = lastsc = lastdfa = lastnfa = 0; - num_rules = num_eof_rules = default_rule = 0; - numas = numsnpairs = tmpuses = 0; - numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst = - 0; - numuniq = numdup = hshsave = eofseen = datapos = dataline = 0; - num_backing_up = onesp = numprots = 0; - variable_trailing_context_rules = bol_needed = false; - - linenum = sectnum = 1; - firstprot = NIL; - - /* - * Used in mkprot() so that the first proto goes in slot 1 of the - * proto queue. - */ - lastprot = 1; - - set_up_initial_allocations(); -} - - -/* readin - read in the rules section of the input file(s) */ - -void -readin() -{ - static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; - static char yy_nostdinit[] = - "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;"; - - line_directive_out((FILE *) 0, 1); - - if (yyparse()) { - pinpoint_message(_("fatal parse error")); - flexend(1); - } - if (syntaxerror) - flexend(1); - - /* - * If the user explicitly requested posix compatibility by specifing - * the posix-compat option, then we check for conflicting options. - * However, if the POSIXLY_CORRECT variable is set, then we quietly - * make flex as posix-compatible as possible. This is the - * recommended behavior according to the GNU Coding Standards. - * - * Note: The posix option was added to flex to provide the posix - * behavior of the repeat operator in regular expressions, e.g., - * `ab{3}' - */ - if (posix_compat) { - /* - * TODO: This is where we try to make flex behave according - * to posiz, AND check for conflicting options. How far - * should we go with this? Should we disable all the neat-o - * flex features? - */ - /* - * Update: Estes says no, since other flex features don't - * violate posix. - */ - } - if (getenv("POSIXLY_CORRECT")) { - posix_compat = true; - } - if (backing_up_report) { - backing_up_file = fopen(backing_name, "w"); - if (backing_up_file == NULL) - lerrsf(_ - ("could not create backing-up info file %s"), - backing_name); - } else - backing_up_file = NULL; - - if (yymore_really_used == true) - yymore_used = true; - else if (yymore_really_used == false) - yymore_used = false; - - if (reject_really_used == true) - reject = true; - else if (reject_really_used == false) - reject = false; - - if (performance_report > 0) { - if (lex_compat) { - fprintf(stderr, - _ - ("-l AT&T lex compatibility option entails a large performance penalty\n")); - fprintf(stderr, - _ - (" and may be the actual source of other reported performance penalties\n")); - } else if (do_yylineno) { - fprintf(stderr, - _ - ("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n")); - } - if (performance_report > 1) { - if (interactive) - fprintf(stderr, - _ - ("-I (interactive) entails a minor performance penalty\n")); - - if (yymore_used) - fprintf(stderr, - _ - ("yymore() entails a minor performance penalty\n")); - } - if (reject) - fprintf(stderr, - _ - ("REJECT entails a large performance penalty\n")); - - if (variable_trailing_context_rules) - fprintf(stderr, - _ - ("Variable trailing context rules entail a large performance penalty\n")); - } - if (reject) - real_reject = true; - - if (variable_trailing_context_rules) - reject = true; - - if ((fulltbl || fullspd) && reject) { - if (real_reject) - flexerror(_ - ("REJECT cannot be used with -f or -F")); - else if (do_yylineno) - flexerror(_ - ("%option yylineno cannot be used with REJECT")); - else - flexerror(_ - ("variable trailing context rules cannot be used with -f or -F")); - } - if (reject) { - out_m4_define("M4_YY_USES_REJECT", NULL); - //outn("\n#define YY_USES_REJECT"); - } - if (!do_yywrap) { - if (!C_plus_plus) { - if (reentrant) - outn("\n#define yywrap(yyscanner) 1"); - else - outn("\n#define yywrap() 1"); - } - outn("#define YY_SKIP_YYWRAP"); - } - if (ddebug) - outn("\n#define FLEX_DEBUG"); - - OUT_BEGIN_CODE(); - if (csize == 256) - outn("typedef unsigned char YY_CHAR;"); - else - outn("typedef char YY_CHAR;"); - OUT_END_CODE(); - - if (C_plus_plus) { - outn("#define yytext_ptr yytext"); - - if (interactive) - outn("#define YY_INTERACTIVE"); - } else { - OUT_BEGIN_CODE(); - /* In reentrant scanner, stdinit is handled in flex.skl. */ - if (do_stdinit) { - if (reentrant) { - outn("#define YY_STDINIT"); - } - outn(yy_stdinit); - } else { - if (!reentrant) - outn(yy_nostdinit); - } - OUT_END_CODE(); - } - - OUT_BEGIN_CODE(); - if (fullspd) - outn("typedef yyconst struct yy_trans_info *yy_state_type;"); - else if (!C_plus_plus) - outn("typedef int yy_state_type;"); - OUT_END_CODE(); - - if (lex_compat) - outn("#define YY_FLEX_LEX_COMPAT"); - - if (!C_plus_plus && !reentrant) { - outn("extern int yylineno;"); - OUT_BEGIN_CODE(); - outn("int yylineno = 1;"); - OUT_END_CODE(); - } - if (C_plus_plus) { - outn("\n#include \"third_party/lex/FlexLexer.h\""); - - if (!do_yywrap) { - outn("\nint yyFlexLexer::yywrap() { return 1; }"); - } - if (yyclass) { - outn("int yyFlexLexer::yylex()"); - outn("\t{"); - outn("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );"); - outn("\treturn 0;"); - outn("\t}"); - - out_str("\n#define YY_DECL int %s::yylex()\n", - yyclass); - } - } else { - - /* - * Watch out: yytext_ptr is a variable when yytext is an - * array, but it's a macro when yytext is a pointer. - */ - if (yytext_is_array) { - if (!reentrant) - outn("extern char yytext[];\n"); - } else { - if (reentrant) { - outn("#define yytext_ptr yytext_r"); - } else { - outn("extern char *yytext;"); - outn("#define yytext_ptr yytext"); - } - } - - if (yyclass) - flexerror(_ - ("%option yyclass only meaningful for C++ scanners")); - } - - if (useecs) - numecs = cre8ecs(nextecm, ecgroup, csize); - else - numecs = csize; - - /* Now map the equivalence class for NUL to its expected place. */ - ecgroup[0] = ecgroup[csize]; - NUL_ec = ABS(ecgroup[0]); - - if (useecs) - ccl2ecl(); -} - - -/* set_up_initial_allocations - allocate memory for internal tables */ - -void -set_up_initial_allocations() -{ - maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS); - current_mns = INITIAL_MNS; - firstst = allocate_integer_array(current_mns); - lastst = allocate_integer_array(current_mns); - finalst = allocate_integer_array(current_mns); - transchar = allocate_integer_array(current_mns); - trans1 = allocate_integer_array(current_mns); - trans2 = allocate_integer_array(current_mns); - accptnum = allocate_integer_array(current_mns); - assoc_rule = allocate_integer_array(current_mns); - state_type = allocate_integer_array(current_mns); - - current_max_rules = INITIAL_MAX_RULES; - rule_type = allocate_integer_array(current_max_rules); - rule_linenum = allocate_integer_array(current_max_rules); - rule_useful = allocate_integer_array(current_max_rules); - rule_has_nl = allocate_bool_array(current_max_rules); - - current_max_scs = INITIAL_MAX_SCS; - scset = allocate_integer_array(current_max_scs); - scbol = allocate_integer_array(current_max_scs); - scxclu = allocate_integer_array(current_max_scs); - sceof = allocate_integer_array(current_max_scs); - scname = allocate_char_ptr_array(current_max_scs); - - current_maxccls = INITIAL_MAX_CCLS; - cclmap = allocate_integer_array(current_maxccls); - ccllen = allocate_integer_array(current_maxccls); - cclng = allocate_integer_array(current_maxccls); - ccl_has_nl = allocate_bool_array(current_maxccls); - - current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE; - ccltbl = allocate_Character_array(current_max_ccl_tbl_size); - - current_max_dfa_size = INITIAL_MAX_DFA_SIZE; - - current_max_xpairs = INITIAL_MAX_XPAIRS; - nxt = allocate_integer_array(current_max_xpairs); - chk = allocate_integer_array(current_max_xpairs); - - current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS; - tnxt = allocate_integer_array(current_max_template_xpairs); - - current_max_dfas = INITIAL_MAX_DFAS; - base = allocate_integer_array(current_max_dfas); - def = allocate_integer_array(current_max_dfas); - dfasiz = allocate_integer_array(current_max_dfas); - accsiz = allocate_integer_array(current_max_dfas); - dhash = allocate_integer_array(current_max_dfas); - dss = allocate_int_ptr_array(current_max_dfas); - dfaacc = allocate_dfaacc_union(current_max_dfas); - - nultrans = (int *) 0; -} - - -/* extracts basename from path, optionally stripping the extension "\.*" - * (same concept as /bin/sh `basename`, but different handling of extension). */ -static char * -basename2(path, strip_ext) - char *path; - int strip_ext; /* boolean */ -{ - char *b, *e = 0; - - b = path; - for (b = path; *path; path++) - if (*path == '/') - b = path + 1; - else if (*path == '.') - e = path; - - if (strip_ext && e && e > b) - *e = '\0'; - return b; -} - -void -usage() -{ - FILE *f = stdout; - - if (!did_outfilename) { - snprintf(outfile_path, sizeof(outfile_path), outfile_template, - prefix, C_plus_plus ? "cc" : "c"); - outfilename = outfile_path; - } - fprintf(f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name); - fprintf(f, - _ - ("Generates programs that perform pattern-matching on text.\n" - "\n" "Table Compression:\n" - " -Ca, --align trade off larger tables for better memory alignment\n" - " -Ce, --ecs construct equivalence classes\n" - " -Cf do not compress tables; use -f representation\n" - " -CF do not compress tables; use -F representation\n" - " -Cm, --meta-ecs construct meta-equivalence classes\n" - " -Cr, --read use read() instead of stdio for scanner input\n" - " -f, --full generate fast, large scanner. Same as -Cfr\n" - " -F, --fast use alternate table representation. Same as -CFr\n" - " -Cem default compression (same as --ecs --meta-ecs)\n" - "\n" "Debugging:\n" - " -d, --debug enable debug mode in scanner\n" - " -b, --backup write backing-up information to %s\n" - " -p, --perf-report write performance report to stderr\n" - " -s, --nodefault suppress default rule to ECHO unmatched text\n" - " -T, --trace %s should run in trace mode\n" - " -w, --nowarn do not generate warnings\n" - " -v, --verbose write summary of scanner statistics to stdout\n" - "\n" "Files:\n" - " -o, --outfile=FILE specify output filename\n" - " -S, --skel=FILE specify skeleton file\n" - " -t, --stdout write scanner on stdout instead of %s\n" - " --yyclass=NAME name of C++ class\n" - " --header-file=FILE create a C header file in addition to the scanner\n" - " --tables-file[=FILE] write tables to FILE\n" "\n" - "Scanner behavior:\n" - " -7, --7bit generate 7-bit scanner\n" - " -8, --8bit generate 8-bit scanner\n" - " -B, --batch generate batch scanner (opposite of -I)\n" - " -i, --case-insensitive ignore case in patterns\n" - " -l, --lex-compat maximal compatibility with original lex\n" - " -X, --posix-compat maximal compatibility with POSIX lex\n" - " -I, --interactive generate interactive scanner (opposite of -B)\n" - " --yylineno track line count in yylineno\n" - "\n" "Generated code:\n" - " -+, --c++ generate C++ scanner class\n" - " -Dmacro[=defn] #define macro defn (default defn is '1')\n" - " -L, --noline suppress #line directives in scanner\n" - " -P, --prefix=STRING use STRING as prefix instead of \"yy\"\n" - " -R, --reentrant generate a reentrant C scanner\n" - " --bison-bridge scanner for bison pure parser.\n" - " --bison-locations include yylloc support.\n" - " --stdinit initialize yyin/yyout to stdin/stdout\n" - " --noansi-definitions old-style function definitions\n" - " --noansi-prototypes empty parameter list in prototypes\n" - " --nounistd do not include \n" - " --noFUNCTION do not generate a particular FUNCTION\n" - "\n" "Miscellaneous:\n" - " -n do-nothing POSIX option\n" - " -?\n" - " -h, --help produce this help message\n" - " -V, --version report %s version\n"), - backing_name, program_name, outfile_path, program_name); - -} diff --git a/third_party/lex/misc.c b/third_party/lex/misc.c deleted file mode 100644 index 2e5aa36a..00000000 --- a/third_party/lex/misc.c +++ /dev/null @@ -1,1017 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -/* $OpenBSD: misc.c,v 1.19 2015/11/19 23:34:56 mmcc Exp $ */ - -/* misc - miscellaneous flex routines */ - -/* 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. */ - -#include "flexdef.h" -#include "libc/mem/mem.h" -#include "libc/str/str.h" -#include "libc/fmt/fmt.h" -#include "tables.h" - -#define CMD_IF_TABLES_SER "%if-tables-serialization" -#define CMD_TABLES_YYDMAP "%tables-yydmap" -#define CMD_DEFINE_YYTABLES "%define-yytables" -#define CMD_IF_CPP_ONLY "%if-c++-only" -#define CMD_IF_C_ONLY "%if-c-only" -#define CMD_IF_C_OR_CPP "%if-c-or-c++" -#define CMD_NOT_FOR_HEADER "%not-for-header" -#define CMD_OK_FOR_HEADER "%ok-for-header" -#define CMD_PUSH "%push" -#define CMD_POP "%pop" -#define CMD_IF_REENTRANT "%if-reentrant" -#define CMD_IF_NOT_REENTRANT "%if-not-reentrant" -#define CMD_IF_BISON_BRIDGE "%if-bison-bridge" -#define CMD_IF_NOT_BISON_BRIDGE "%if-not-bison-bridge" -#define CMD_ENDIF "%endif" - -/* we allow the skeleton to push and pop. */ -struct sko_state { - bool dc; /**< do_copy */ -}; -static struct sko_state *sko_stack = 0; -static int sko_len = 0, sko_sz = 0; -static void -sko_push(bool dc) -{ - if (!sko_stack) { - sko_sz = 1; - sko_stack = malloc(sizeof(struct sko_state) * sko_sz); - if (!sko_stack) - flexfatal(_("allocation of sko_stack failed")); - sko_len = 0; - } - if (sko_len >= sko_sz) { - sko_sz *= 2; - sko_stack = realloc(sko_stack, sizeof(struct sko_state) * sko_sz); - } - /* initialize to zero and push */ - sko_stack[sko_len].dc = dc; - sko_len++; -} -static void -sko_peek(bool * dc) -{ - if (sko_len <= 0) - flex_die("peek attempt when sko stack is empty"); - if (dc) - *dc = sko_stack[sko_len - 1].dc; -} -static void -sko_pop(bool * dc) -{ - sko_peek(dc); - sko_len--; - if (sko_len < 0) - flex_die("popped too many times in skeleton."); -} - -/* Append "#define defname value\n" to the running buffer. */ -void -action_define(defname, value) - const char *defname; - int value; -{ - char buf[MAXLINE]; - char *cpy; - - if ((int) strlen(defname) > MAXLINE / 2) { - format_pinpoint_message(_ - ("name \"%s\" ridiculously long"), - defname); - return; - } - snprintf(buf, sizeof(buf), "#define %s %d\n", defname, value); - add_action(buf); - - /* track #defines so we can undef them when we're done. */ - cpy = copy_string(defname); - buf_append(&defs_buf, &cpy, 1); -} - - -/** Append "m4_define([[defname]],[[value]])m4_dnl\n" to the running buffer. - * @param defname The macro name. - * @param value The macro value, can be NULL, which is the same as the empty string. - */ -void -action_m4_define(const char *defname, const char *value) -{ - char buf[MAXLINE]; - - flexfatal("DO NOT USE THIS FUNCTION!"); - - if ((int) strlen(defname) > MAXLINE / 2) { - format_pinpoint_message(_ - ("name \"%s\" ridiculously long"), - defname); - return; - } - snprintf(buf, sizeof(buf), "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value ? value : ""); - add_action(buf); -} - -/* Append "new_text" to the running buffer. */ -void -add_action(new_text) - const char *new_text; -{ - int len = strlen(new_text); - - while (len + action_index >= action_size - 10 /* slop */ ) { - int new_size = action_size * 2; - - if (new_size <= 0) - /* - * Increase just a little, to try to avoid overflow - * on 16-bit machines. - */ - action_size += action_size / 8; - else - action_size = new_size; - - action_array = - reallocate_character_array(action_array, - action_size); - } - - strlcpy(&action_array[action_index], new_text, - action_size - action_index); - - action_index += len; -} - - -/* allocate_array - allocate memory for an integer array of the given size */ - -void * -allocate_array(size, element_size) - int size; - size_t element_size; -{ - void *mem; - size_t num_bytes = element_size * size; - - mem = malloc(num_bytes); - if (!mem) - flexfatal(_ - ("memory allocation failed in allocate_array()")); - - return mem; -} - - -/* all_lower - true if a string is all lower-case */ - -int -all_lower(str) - char *str; -{ - while (*str) { - if (!isascii((u_char) * str) || !islower((u_char) * str)) - return 0; - ++str; - } - - return 1; -} - - -/* all_upper - true if a string is all upper-case */ - -int -all_upper(str) - char *str; -{ - while (*str) { - if (!isascii((u_char) * str) || !isupper((u_char) * str)) - return 0; - ++str; - } - - return 1; -} - - -/* intcmp - compares two integers for use by qsort. */ - -int -intcmp(const void *a, const void *b) -{ - return *(const int *) a - *(const int *) b; -} - - -/* check_char - checks a character to make sure it's within the range - * we're expecting. If not, generates fatal error message - * and exits. - */ - -void -check_char(c) - int c; -{ - if (c >= CSIZE) - lerrsf(_("bad character '%s' detected in check_char()"), - readable_form(c)); - - if (c >= csize) - lerrsf(_ - ("scanner requires -8 flag to use the character %s"), - readable_form(c)); -} - - - -/* clower - replace upper-case letter to lower-case */ - -u_char -clower(c) - int c; -{ - return (u_char) ((isascii(c) && isupper(c)) ? tolower(c) : c); -} - - -/* copy_string - returns a dynamically allocated copy of a string */ - -char * -copy_string(str) - const char *str; -{ - const char *c1; - char *c2; - char *copy; - unsigned int size; - - /* find length */ - for (c1 = str; *c1; ++c1); - - size = (c1 - str + 1) * sizeof(char); - - copy = (char *) malloc(size); - - if (copy == NULL) - flexfatal(_("dynamic memory failure in copy_string()")); - - for (c2 = copy; (*c2++ = *str++) != 0;); - - return copy; -} - - -/* copy_unsigned_string - - * returns a dynamically allocated copy of a (potentially) unsigned string - */ - -u_char * -copy_unsigned_string(str) - u_char *str; -{ - u_char *c; - u_char *copy; - - /* find length */ - for (c = str; *c; ++c); - - copy = allocate_Character_array(c - str + 1); - - for (c = copy; (*c++ = *str++) != 0;); - - return copy; -} - - -/* cclcmp - compares two characters for use by qsort with '\0' sorting last. */ - -int -cclcmp(const void *a, const void *b) -{ - if (!*(const u_char *) a) - return 1; - else if (!*(const u_char *) b) - return -1; - else - return *(const u_char *) a - *(const u_char *) b; -} - - -/* dataend - finish up a block of data declarations */ - -void -dataend() -{ - /* short circuit any output */ - if (gentables) { - - if (datapos > 0) - dataflush(); - - /* add terminator for initialization; { for vi */ - outn(" } ;\n"); - } - dataline = 0; - datapos = 0; -} - - -/* dataflush - flush generated data statements */ - -void -dataflush() -{ - /* short circuit any output */ - if (!gentables) - return; - - outc('\n'); - - if (++dataline >= NUMDATALINES) { - /* - * Put out a blank line so that the table is grouped into - * large blocks that enable the user to find elements easily. - */ - outc('\n'); - dataline = 0; - } - /* Reset the number of characters written on the current line. */ - datapos = 0; -} - - -/* flexerror - report an error message and terminate */ - -void -flexerror(msg) - const char *msg; -{ - fprintf(stderr, "%s: %s\n", program_name, msg); - flexend(1); -} - - -/* flexfatal - report a fatal error message and terminate */ - -void -flexfatal(msg) - const char *msg; -{ - fprintf(stderr, _("%s: fatal internal error, %s\n"), - program_name, msg); - FLEX_EXIT(1); -} - - -/* htoi - convert a hexadecimal digit string to an integer value */ - -int -htoi(str) - u_char str[]; -{ - unsigned int result; - - (void) sscanf((char *) str, "%x", &result); - - return result; -} - - -/* lerrif - report an error message formatted with one integer argument */ - -void -lerrif(msg, arg) - const char *msg; - int arg; -{ - char errmsg[MAXLINE]; - - snprintf(errmsg, sizeof(errmsg), msg, arg); - flexerror(errmsg); -} - - -/* lerrsf - report an error message formatted with one string argument */ - -void -lerrsf(msg, arg) - const char *msg, arg[]; -{ - char errmsg[MAXLINE]; - - snprintf(errmsg, sizeof(errmsg) - 1, msg, arg); - errmsg[sizeof(errmsg) - 1] = 0; /* ensure NULL termination */ - flexerror(errmsg); -} - - -/* lerrsf_fatal - as lerrsf, but call flexfatal */ - -void -lerrsf_fatal(msg, arg) - const char *msg, arg[]; -{ - char errmsg[MAXLINE]; - - snprintf(errmsg, sizeof(errmsg) - 1, msg, arg); - errmsg[sizeof(errmsg) - 1] = 0; /* ensure NULL termination */ - flexfatal(errmsg); -} - - -/* line_directive_out - spit out a "#line" statement */ - -void -line_directive_out(output_file, do_infile) - FILE *output_file; - int do_infile; -{ - char directive[MAXLINE + 128], filename[MAXLINE]; - char *s1, *s2, *s3; - static const char *line_fmt = "#line %d \"%s\"\n"; - - if (!gen_line_dirs) - return; - - s1 = do_infile ? infilename : "M4_YY_OUTFILE_NAME"; - - if (do_infile && !s1) - s1 = ""; - - s2 = filename; - s3 = &filename[sizeof(filename) - 2]; - - while (s2 < s3 && *s1) { - if (*s1 == '\\') - /* Escape the '\' */ - *s2++ = '\\'; - - *s2++ = *s1++; - } - - *s2 = '\0'; - - if (do_infile) - snprintf(directive, sizeof(directive), line_fmt, linenum, filename); - else { - snprintf(directive, sizeof(directive), line_fmt, 0, filename); - } - - /* - * If output_file is nil then we should put the directive in the - * accumulated actions. - */ - if (output_file) { - fputs(directive, output_file); - } else - add_action(directive); -} - - -/* mark_defs1 - mark the current position in the action array as - * representing where the user's section 1 definitions end - * and the prolog begins - */ -void -mark_defs1() -{ - defs1_offset = 0; - action_array[action_index++] = '\0'; - action_offset = prolog_offset = action_index; - action_array[action_index] = '\0'; -} - - -/* mark_prolog - mark the current position in the action array as - * representing the end of the action prolog - */ -void -mark_prolog() -{ - action_array[action_index++] = '\0'; - action_offset = action_index; - action_array[action_index] = '\0'; -} - - -/* mk2data - generate a data statement for a two-dimensional array - * - * Generates a data statement initializing the current 2-D array to "value". - */ -void -mk2data(value) - int value; -{ - /* short circuit any output */ - if (!gentables) - return; - - if (datapos >= NUMDATAITEMS) { - outc(','); - dataflush(); - } - if (datapos == 0) - /* Indent. */ - out(" "); - - else - outc(','); - - ++datapos; - - out_dec("%5d", value); -} - - -/* mkdata - generate a data statement - * - * Generates a data statement initializing the current array element to - * "value". - */ -void -mkdata(value) - int value; -{ - /* short circuit any output */ - if (!gentables) - return; - - if (datapos >= NUMDATAITEMS) { - outc(','); - dataflush(); - } - if (datapos == 0) - /* Indent. */ - out(" "); - else - outc(','); - - ++datapos; - - out_dec("%5d", value); -} - - -/* myctoi - return the integer represented by a string of digits */ - -int -myctoi(array) - const char *array; -{ - int val = 0; - - (void) sscanf(array, "%d", &val); - - return val; -} - - -/* myesc - return character corresponding to escape sequence */ - -u_char -myesc(array) - u_char array[]; -{ - u_char c, esc_char; - - switch (array[1]) { - case 'b': - return '\b'; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - -#if defined (__STDC__) - case 'a': - return '\a'; - case 'v': - return '\v'; -#else - case 'a': - return '\007'; - case 'v': - return '\013'; -#endif - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { /* \ */ - int sptr = 1; - - while (isascii(array[sptr]) && - isdigit(array[sptr])) - /* - * Don't increment inside loop control - * because if isdigit() is a macro it might - * expand into multiple increments ... - */ - ++sptr; - - c = array[sptr]; - array[sptr] = '\0'; - - esc_char = otoi(array + 1); - - array[sptr] = c; - - return esc_char; - } - - case 'x': - { /* \x */ - int sptr = 2; - - while (isascii(array[sptr]) && - isxdigit(array[sptr])) - /* - * Don't increment inside loop control - * because if isdigit() is a macro it might - * expand into multiple increments ... - */ - ++sptr; - - c = array[sptr]; - array[sptr] = '\0'; - - esc_char = htoi(array + 2); - - array[sptr] = c; - - return esc_char; - } - - default: - return array[1]; - } -} - - -/* otoi - convert an octal digit string to an integer value */ - -int -otoi(str) - u_char str[]; -{ - unsigned int result; - - (void) sscanf((char *) str, "%o", &result); - return result; -} - - -/* out - various flavors of outputing a (possibly formatted) string for the - * generated scanner, keeping track of the line count. - */ - -void -out(str) - const char *str; -{ - fputs(str, stdout); -} - -void -out_dec(fmt, n) - const char *fmt; - int n; -{ - fprintf(stdout, fmt, n); -} - -void -out_dec2(fmt, n1, n2) - const char *fmt; - int n1, n2; -{ - fprintf(stdout, fmt, n1, n2); -} - -void -out_hex(fmt, x) - const char *fmt; - unsigned int x; -{ - fprintf(stdout, fmt, x); -} - -void -out_str(fmt, str) - const char *fmt, str[]; -{ - fprintf(stdout, fmt, str); -} - -void -out_str3(fmt, s1, s2, s3) - const char *fmt, s1[], s2[], s3[]; -{ - fprintf(stdout, fmt, s1, s2, s3); -} - -void -out_str_dec(fmt, str, n) - const char *fmt, str[]; - int n; -{ - fprintf(stdout, fmt, str, n); -} - -void -outc(c) - int c; -{ - fputc(c, stdout); -} - -void -outn(str) - const char *str; -{ - fputs(str, stdout); - fputc('\n', stdout); -} - -/** Print "m4_define( [[def]], [[val]])m4_dnl\n". - * @param def The m4 symbol to define. - * @param val The definition; may be NULL. - * @return buf - */ -void -out_m4_define(const char *def2, const char *val) -{ - const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n"; - fprintf(stdout, fmt, def2, val ? val : ""); -} - - -/* readable_form - return the human-readable form of a character - * - * The returned string is in static storage. - */ - -char * -readable_form(c) - int c; -{ - static char rform[10]; - - if ((c >= 0 && c < 32) || c >= 127) { - switch (c) { - case '\b': - return "\\b"; - case '\f': - return "\\f"; - case '\n': - return "\\n"; - case '\r': - return "\\r"; - case '\t': - return "\\t"; - -#if defined (__STDC__) - case '\a': - return "\\a"; - case '\v': - return "\\v"; -#endif - - default: - snprintf(rform, sizeof(rform), "\\%.3o", (unsigned int) c); - return rform; - } - } else if (c == ' ') - return "' '"; - - else { - rform[0] = c; - rform[1] = '\0'; - - return rform; - } -} - - -/* reallocate_array - increase the size of a dynamic array */ - -void * -reallocate_array(array, size, element_size) - void *array; - int size; - size_t element_size; -{ - void *new_array; - size_t num_bytes = element_size * size; - - new_array = realloc(array, num_bytes); - if (!new_array) - flexfatal(_("attempt to increase array size failed")); - - return new_array; -} - - -/* skelout - write out one section of the skeleton file - * - * Description - * Copies skelfile or skel array to stdout until a line beginning with - * "%%" or EOF is found. - */ -void -skelout() -{ - char buf_storage[MAXLINE]; - char *buf = buf_storage; - bool do_copy = true; - - /* "reset" the state by clearing the buffer and pushing a '1' */ - if (sko_len > 0) - sko_peek(&do_copy); - sko_len = 0; - sko_push(do_copy = true); - - - /* - * Loop pulling lines either from the skelfile, if we're using one, - * or from the skel[] array. - */ - while (skelfile ? - (fgets(buf, MAXLINE, skelfile) != NULL) : - ((buf = (char *) skel[skel_ind++]) != 0)) { - - if (skelfile) - chomp(buf); - - /* copy from skel array */ - if (buf[0] == '%') { /* control line */ - /* print the control line as a comment. */ - if (ddebug && buf[1] != '#') { - if (buf[strlen(buf) - 1] == '\\') - out_str("/* %s */\\\n", buf); - else - out_str("/* %s */\n", buf); - } - /* - * We've been accused of using cryptic markers in the - * skel. So we'll use - * emacs-style-hyphenated-commands. We might consider - * a hash if this if-else-if-else chain gets too - * large. - */ -#define cmd_match(s) (strncmp(buf,(s),strlen(s))==0) - - if (buf[1] == '%') { - /* %% is a break point for skelout() */ - return; - } else if (cmd_match(CMD_PUSH)) { - sko_push(do_copy); - if (ddebug) { - out_str("/*(state = (%s) */", do_copy ? "true" : "false"); - } - out_str("%s\n", buf[strlen(buf) - 1] == '\\' ? "\\" : ""); - } else if (cmd_match(CMD_POP)) { - sko_pop(&do_copy); - if (ddebug) { - out_str("/*(state = (%s) */", do_copy ? "true" : "false"); - } - out_str("%s\n", buf[strlen(buf) - 1] == '\\' ? "\\" : ""); - } else if (cmd_match(CMD_IF_REENTRANT)) { - sko_push(do_copy); - do_copy = reentrant && do_copy; - } else if (cmd_match(CMD_IF_NOT_REENTRANT)) { - sko_push(do_copy); - do_copy = !reentrant && do_copy; - } else if (cmd_match(CMD_IF_BISON_BRIDGE)) { - sko_push(do_copy); - do_copy = bison_bridge_lval && do_copy; - } else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)) { - sko_push(do_copy); - do_copy = !bison_bridge_lval && do_copy; - } else if (cmd_match(CMD_ENDIF)) { - sko_pop(&do_copy); - } else if (cmd_match(CMD_IF_TABLES_SER)) { - do_copy = do_copy && tablesext; - } else if (cmd_match(CMD_TABLES_YYDMAP)) { - if (tablesext && yydmap_buf.elts) - outn((char *) (yydmap_buf.elts)); - } else if (cmd_match(CMD_DEFINE_YYTABLES)) { - out_str("#define YYTABLES_NAME \"%s\"\n", - tablesname ? tablesname : "yytables"); - } else if (cmd_match(CMD_IF_CPP_ONLY)) { - /* only for C++ */ - sko_push(do_copy); - do_copy = C_plus_plus; - } else if (cmd_match(CMD_IF_C_ONLY)) { - /* %- only for C */ - sko_push(do_copy); - do_copy = !C_plus_plus; - } else if (cmd_match(CMD_IF_C_OR_CPP)) { - /* %* for C and C++ */ - sko_push(do_copy); - do_copy = true; - } else if (cmd_match(CMD_NOT_FOR_HEADER)) { - /* %c begin linkage-only (non-header) code. */ - OUT_BEGIN_CODE(); - } else if (cmd_match(CMD_OK_FOR_HEADER)) { - /* %e end linkage-only code. */ - OUT_END_CODE(); - } else if (buf[1] == '#') { - /* %# a comment in the skel. ignore. */ - } else { - flexfatal(_("bad line in skeleton file")); - } - } else if (do_copy) - outn(buf); - } /* end while */ -} - - -/* transition_struct_out - output a yy_trans_info structure - * - * outputs the yy_trans_info structure with the two elements, element_v and - * element_n. Formats the output with spaces and carriage returns. - */ - -void -transition_struct_out(element_v, element_n) - int element_v, element_n; -{ - - /* short circuit any output */ - if (!gentables) - return; - - out_dec2(" {%4d,%4d },", element_v, element_n); - - datapos += TRANS_STRUCT_PRINT_LENGTH; - - if (datapos >= 79 - TRANS_STRUCT_PRINT_LENGTH) { - outc('\n'); - - if (++dataline % 10 == 0) - outc('\n'); - - datapos = 0; - } -} - - -/* The following is only needed when building flex's parser using certain - * broken versions of bison. - */ -void * -yy_flex_xmalloc(size) - int size; -{ - void *result = malloc((size_t) size); - - if (!result) - flexfatal(_ - ("memory allocation failed in yy_flex_xmalloc()")); - - return result; -} diff --git a/third_party/lex/mkskel.sh b/third_party/lex/mkskel.sh deleted file mode 100644 index 9a8b02e1..00000000 --- a/third_party/lex/mkskel.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh -# $OpenBSD: mkskel.sh,v 1.3 2015/11/19 19:43:40 tedu Exp $ - -# 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. - -cat < 0) - fprintf(stderr, - _ - ("Variable trailing context rule at line %d\n"), - rule_linenum[num_rules]); - - variable_trailing_context_rules = true; - } else { - rule_type[num_rules] = RULE_NORMAL; - - if (headcnt > 0 || trailcnt > 0) { - /* - * Do trailing context magic to not match the - * trailing characters. - */ - char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp"; - char *scanner_bp = "yy_bp"; - - add_action - ("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n"); - - if (headcnt > 0) { - if (rule_has_nl[num_rules]) { - snprintf(action_text, sizeof(action_text), - "YY_LINENO_REWIND_TO(%s + %d);\n", scanner_bp, headcnt); - add_action(action_text); - } - snprintf(action_text, sizeof(action_text), "%s = %s + %d;\n", - scanner_cp, scanner_bp, headcnt); - add_action(action_text); - } else { - if (rule_has_nl[num_rules]) { - snprintf(action_text, sizeof(action_text), - "YY_LINENO_REWIND_TO(yy_cp - %d);\n", trailcnt); - add_action(action_text); - } - snprintf(action_text, sizeof(action_text), "%s -= %d;\n", - scanner_cp, trailcnt); - add_action(action_text); - } - - add_action - ("YY_DO_BEFORE_ACTION; /* set up yytext again */\n"); - } - } - - /* - * Okay, in the action code at this point yytext and yyleng have - * their proper final values for this rule, so here's the point to do - * any user action. But don't do it for continued actions, as - * that'll result in multiple YY_RULE_SETUP's. - */ - if (!continued_action) - add_action("YY_RULE_SETUP\n"); - - line_directive_out((FILE *) 0, 1); -} - - -/* link_machines - connect two machines together - * - * synopsis - * - * new = link_machines( first, last ); - * - * new - a machine constructed by connecting first to last - * first - the machine whose successor is to be last - * last - the machine whose predecessor is to be first - * - * note: this routine concatenates the machine first with the machine - * last to produce a machine new which will pattern-match first first - * and then last, and will fail if either of the sub-patterns fails. - * FIRST is set to new by the operation. last is unmolested. - */ - -int -link_machines(first, last) - int first, last; -{ - if (first == NIL) - return last; - - else if (last == NIL) - return first; - - else { - mkxtion(finalst[first], last); - finalst[first] = finalst[last]; - lastst[first] = MAX(lastst[first], lastst[last]); - firstst[first] = MIN(firstst[first], firstst[last]); - - return first; - } -} - - -/* mark_beginning_as_normal - mark each "beginning" state in a machine - * as being a "normal" (i.e., not trailing context- - * associated) states - * - * The "beginning" states are the epsilon closure of the first state - */ - -void -mark_beginning_as_normal(mach) - int mach; -{ - switch (state_type[mach]) { - case STATE_NORMAL: - /* Oh, we've already visited here. */ - return; - - case STATE_TRAILING_CONTEXT: - state_type[mach] = STATE_NORMAL; - - if (transchar[mach] == SYM_EPSILON) { - if (trans1[mach] != NO_TRANSITION) - mark_beginning_as_normal(trans1[mach]); - - if (trans2[mach] != NO_TRANSITION) - mark_beginning_as_normal(trans2[mach]); - } - break; - - default: - flexerror(_ - ("bad state type in mark_beginning_as_normal()")); - break; - } -} - - -/* mkbranch - make a machine that branches to two machines - * - * synopsis - * - * branch = mkbranch( first, second ); - * - * branch - a machine which matches either first's pattern or second's - * first, second - machines whose patterns are to be or'ed (the | operator) - * - * Note that first and second are NEITHER destroyed by the operation. Also, - * the resulting machine CANNOT be used with any other "mk" operation except - * more mkbranch's. Compare with mkor() - */ - -int -mkbranch(first, second) - int first, second; -{ - int eps; - - if (first == NO_TRANSITION) - return second; - - else if (second == NO_TRANSITION) - return first; - - eps = mkstate(SYM_EPSILON); - - mkxtion(eps, first); - mkxtion(eps, second); - - return eps; -} - - -/* mkclos - convert a machine into a closure - * - * synopsis - * new = mkclos( state ); - * - * new - a new state which matches the closure of "state" - */ - -int -mkclos(state) - int state; -{ - return mkopt(mkposcl(state)); -} - - -/* mkopt - make a machine optional - * - * synopsis - * - * new = mkopt( mach ); - * - * new - a machine which optionally matches whatever mach matched - * mach - the machine to make optional - * - * notes: - * 1. mach must be the last machine created - * 2. mach is destroyed by the call - */ - -int -mkopt(mach) - int mach; -{ - int eps; - - if (!SUPER_FREE_EPSILON(finalst[mach])) { - eps = mkstate(SYM_EPSILON); - mach = link_machines(mach, eps); - } - /* - * Can't skimp on the following if FREE_EPSILON(mach) is true because - * some state interior to "mach" might point back to the beginning - * for a closure. - */ - eps = mkstate(SYM_EPSILON); - mach = link_machines(eps, mach); - - mkxtion(mach, finalst[mach]); - - return mach; -} - - -/* mkor - make a machine that matches either one of two machines - * - * synopsis - * - * new = mkor( first, second ); - * - * new - a machine which matches either first's pattern or second's - * first, second - machines whose patterns are to be or'ed (the | operator) - * - * note that first and second are both destroyed by the operation - * the code is rather convoluted because an attempt is made to minimize - * the number of epsilon states needed - */ - -int -mkor(first, second) - int first, second; -{ - int eps, orend; - - if (first == NIL) - return second; - - else if (second == NIL) - return first; - - else { - /* - * See comment in mkopt() about why we can't use the first - * state of "first" or "second" if they satisfy - * "FREE_EPSILON". - */ - eps = mkstate(SYM_EPSILON); - - first = link_machines(eps, first); - - mkxtion(first, second); - - if (SUPER_FREE_EPSILON(finalst[first]) && - accptnum[finalst[first]] == NIL) { - orend = finalst[first]; - mkxtion(finalst[second], orend); - } else if (SUPER_FREE_EPSILON(finalst[second]) && - accptnum[finalst[second]] == NIL) { - orend = finalst[second]; - mkxtion(finalst[first], orend); - } else { - eps = mkstate(SYM_EPSILON); - - first = link_machines(first, eps); - orend = finalst[first]; - - mkxtion(finalst[second], orend); - } - } - - finalst[first] = orend; - return first; -} - - -/* mkposcl - convert a machine into a positive closure - * - * synopsis - * new = mkposcl( state ); - * - * new - a machine matching the positive closure of "state" - */ - -int -mkposcl(state) - int state; -{ - int eps; - - if (SUPER_FREE_EPSILON(finalst[state])) { - mkxtion(finalst[state], state); - return state; - } else { - eps = mkstate(SYM_EPSILON); - mkxtion(eps, state); - return link_machines(state, eps); - } -} - - -/* mkrep - make a replicated machine - * - * synopsis - * new = mkrep( mach, lb, ub ); - * - * new - a machine that matches whatever "mach" matched from "lb" - * number of times to "ub" number of times - * - * note - * if "ub" is INFINITE_REPEAT then "new" matches "lb" or more occurrences of "mach" - */ - -int -mkrep(mach, lb, ub) - int mach, lb, ub; -{ - int base_mach, tail, copy, i; - - base_mach = copysingl(mach, lb - 1); - - if (ub == INFINITE_REPEAT) { - copy = dupmachine(mach); - mach = link_machines(mach, - link_machines(base_mach, - mkclos(copy))); - } else { - tail = mkstate(SYM_EPSILON); - - for (i = lb; i < ub; ++i) { - copy = dupmachine(mach); - tail = mkopt(link_machines(copy, tail)); - } - - mach = - link_machines(mach, - link_machines(base_mach, tail)); - } - - return mach; -} - - -/* mkstate - create a state with a transition on a given symbol - * - * synopsis - * - * state = mkstate( sym ); - * - * state - a new state matching sym - * sym - the symbol the new state is to have an out-transition on - * - * note that this routine makes new states in ascending order through the - * state array (and increments LASTNFA accordingly). The routine DUPMACHINE - * relies on machines being made in ascending order and that they are - * CONTIGUOUS. Change it and you will have to rewrite DUPMACHINE (kludge - * that it admittedly is) - */ - -int -mkstate(sym) - int sym; -{ - if (++lastnfa >= current_mns) { - if ((current_mns += MNS_INCREMENT) >= maximum_mns) - lerrif(_ - ("input rules are too complicated (>= %d NFA states)"), - current_mns); - - ++num_reallocs; - - firstst = reallocate_integer_array(firstst, current_mns); - lastst = reallocate_integer_array(lastst, current_mns); - finalst = reallocate_integer_array(finalst, current_mns); - transchar = - reallocate_integer_array(transchar, current_mns); - trans1 = reallocate_integer_array(trans1, current_mns); - trans2 = reallocate_integer_array(trans2, current_mns); - accptnum = - reallocate_integer_array(accptnum, current_mns); - assoc_rule = - reallocate_integer_array(assoc_rule, current_mns); - state_type = - reallocate_integer_array(state_type, current_mns); - } - firstst[lastnfa] = lastnfa; - finalst[lastnfa] = lastnfa; - lastst[lastnfa] = lastnfa; - transchar[lastnfa] = sym; - trans1[lastnfa] = NO_TRANSITION; - trans2[lastnfa] = NO_TRANSITION; - accptnum[lastnfa] = NIL; - assoc_rule[lastnfa] = num_rules; - state_type[lastnfa] = current_state_type; - - /* - * Fix up equivalence classes base on this transition. Note that any - * character which has its own transition gets its own equivalence - * class. Thus only characters which are only in character classes - * have a chance at being in the same equivalence class. E.g. "a|b" - * puts 'a' and 'b' into two different equivalence classes. "[ab]" - * puts them in the same equivalence class (barring other differences - * elsewhere in the input). - */ - - if (sym < 0) { - /* - * We don't have to update the equivalence classes since that - * was already done when the ccl was created for the first - * time. - */ - } else if (sym == SYM_EPSILON) - ++numeps; - - else { - check_char(sym); - - if (useecs) - /* Map NUL's to csize. */ - mkechar(sym ? sym : csize, nextecm, ecgroup); - } - - return lastnfa; -} - - -/* mkxtion - make a transition from one state to another - * - * synopsis - * - * mkxtion( statefrom, stateto ); - * - * statefrom - the state from which the transition is to be made - * stateto - the state to which the transition is to be made - */ - -void -mkxtion(statefrom, stateto) - int statefrom, stateto; -{ - if (trans1[statefrom] == NO_TRANSITION) - trans1[statefrom] = stateto; - - else if ((transchar[statefrom] != SYM_EPSILON) || - (trans2[statefrom] != NO_TRANSITION)) - flexfatal(_("found too many transitions in mkxtion()")); - - else { /* second out-transition for an epsilon state */ - ++eps2; - trans2[statefrom] = stateto; - } -} - -/* new_rule - initialize for a new rule */ - -void -new_rule() -{ - if (++num_rules >= current_max_rules) { - ++num_reallocs; - current_max_rules += MAX_RULES_INCREMENT; - rule_type = reallocate_integer_array(rule_type, - current_max_rules); - rule_linenum = reallocate_integer_array(rule_linenum, - current_max_rules); - rule_useful = reallocate_integer_array(rule_useful, - current_max_rules); - rule_has_nl = reallocate_bool_array(rule_has_nl, - current_max_rules); - } - if (num_rules > MAX_RULE) - lerrif(_("too many rules (> %d)!"), MAX_RULE); - - rule_linenum[num_rules] = linenum; - rule_useful[num_rules] = false; - rule_has_nl[num_rules] = false; -} diff --git a/third_party/lex/options.c b/third_party/lex/options.c deleted file mode 100644 index 14bf3ef6..00000000 --- a/third_party/lex/options.c +++ /dev/null @@ -1,285 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -/* $OpenBSD: options.c,v 1.2 2015/11/19 22:16:43 tedu Exp $ */ - -/* flex - tool to generate fast lexical analyzers */ - -/* 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. */ - -#include "options.h" - -/* Be sure to synchronize these options with those defined in "options.h", - * the giant switch() statement in "main.c", and the %option processing in - * "scan.l". - */ - - -/* The command-line options, passed to scanopt_init() */ -optspec_t flexopts[] = { - - {"-7", OPT_7BIT, 0} - , - {"--7bit", OPT_7BIT, 0} - , /* Generate 7-bit scanner. */ - {"-8", OPT_8BIT, 0} - , - {"--8bit", OPT_8BIT, 0} - , /* Generate 8-bit scanner. */ - {"--align", OPT_ALIGN, 0} - , /* Trade off larger tables for better memory alignment. */ - {"--noalign", OPT_NO_ALIGN, 0} - , - {"--always-interactive", OPT_ALWAYS_INTERACTIVE, 0} - , - {"--array", OPT_ARRAY, 0} - , - {"-b", OPT_BACKUP, 0} - , - {"--backup", OPT_BACKUP, 0} - , /* Generate backing-up information to lex.backup. */ - {"-B", OPT_BATCH, 0} - , - {"--batch", OPT_BATCH, 0} - , /* Generate batch scanner (opposite of -I). */ - {"--bison-bridge", OPT_BISON_BRIDGE, 0} - , /* Scanner to be called by a bison pure parser. */ - {"--bison-locations", OPT_BISON_BRIDGE_LOCATIONS, 0} - , /* Scanner to be called by a bison pure parser. */ - {"-i", OPT_CASE_INSENSITIVE, 0} - , - {"--case-insensitive", OPT_CASE_INSENSITIVE, 0} - , /* Generate case-insensitive scanner. */ - - {"-C[aefFmr]", OPT_COMPRESSION, - "Specify degree of table compression (default is -Cem)"}, - {"-+", OPT_CPLUSPLUS, 0} - , - {"--c++", OPT_CPLUSPLUS, 0} - , /* Generate C++ scanner class. */ - {"-d", OPT_DEBUG, 0} - , - {"--debug", OPT_DEBUG, 0} - , /* Turn on debug mode in generated scanner. */ - {"--nodebug", OPT_NO_DEBUG, 0} - , - {"-s", OPT_NO_DEFAULT, 0} - , - {"--nodefault", OPT_NO_DEFAULT, 0} - , /* Suppress default rule to ECHO unmatched text. */ - {"--default", OPT_DEFAULT, 0} - , - {"-c", OPT_DONOTHING, 0} - , /* For POSIX lex compatibility. */ - {"-n", OPT_DONOTHING, 0} - , /* For POSIX lex compatibility. */ - {"--ecs", OPT_ECS, 0} - , /* Construct equivalence classes. */ - {"--noecs", OPT_NO_ECS, 0} - , - {"-F", OPT_FAST, 0} - , - {"--fast", OPT_FAST, 0} - , /* Same as -CFr. */ - {"-f", OPT_FULL, 0} - , - {"--full", OPT_FULL, 0} - , /* Same as -Cfr. */ - {"--header-file[=FILE]", OPT_HEADER_FILE, 0} - , - {"-?", OPT_HELP, 0} - , - {"-h", OPT_HELP, 0} - , - {"--help", OPT_HELP, 0} - , /* Produce this help message. */ - {"-I", OPT_INTERACTIVE, 0} - , - {"--interactive", OPT_INTERACTIVE, 0} - , /* Generate interactive scanner (opposite of -B). */ - {"-l", OPT_LEX_COMPAT, 0} - , - {"--lex-compat", OPT_LEX_COMPAT, 0} - , /* Maximal compatibility with original lex. */ - {"-X", OPT_POSIX_COMPAT, 0} - , - {"--posix-compat", OPT_POSIX_COMPAT, 0} - , /* Maximal compatibility with POSIX lex. */ - {"--preproc=NUM", OPT_PREPROC_LEVEL, 0} - , - {"-L", OPT_NO_LINE, 0} - , /* Suppress #line directives in scanner. */ - {"--noline", OPT_NO_LINE, 0} - , /* Suppress #line directives in scanner. */ - {"--main", OPT_MAIN, 0} - , /* use built-in main() function. */ - {"--nomain", OPT_NO_MAIN, 0} - , - {"--meta-ecs", OPT_META_ECS, 0} - , /* Construct meta-equivalence classes. */ - {"--nometa-ecs", OPT_NO_META_ECS, 0} - , - {"--never-interactive", OPT_NEVER_INTERACTIVE, 0} - , - {"-o FILE", OPT_OUTFILE, 0} - , - {"--outfile=FILE", OPT_OUTFILE, 0} - , /* Write to FILE (default is lex.yy.c) */ - {"-p", OPT_PERF_REPORT, 0} - , - {"--perf-report", OPT_PERF_REPORT, 0} - , /* Generate performance report to stderr. */ - {"--pointer", OPT_POINTER, 0} - , - {"-P PREFIX", OPT_PREFIX, 0} - , - {"--prefix=PREFIX", OPT_PREFIX, 0} - , /* Use PREFIX (default is yy) */ - {"-Dmacro", OPT_PREPROCDEFINE, 0} - , /* Define a preprocessor symbol. */ - {"--read", OPT_READ, 0} - , /* Use read(2) instead of stdio. */ - {"-R", OPT_REENTRANT, 0} - , - {"--reentrant", OPT_REENTRANT, 0} - , /* Generate a reentrant C scanner. */ - {"--noreentrant", OPT_NO_REENTRANT, 0} - , - {"--reject", OPT_REJECT, 0} - , - {"--noreject", OPT_NO_REJECT, 0} - , - {"-S FILE", OPT_SKEL, 0} - , - {"--skel=FILE", OPT_SKEL, 0} - , /* Use skeleton from FILE */ - {"--stack", OPT_STACK, 0} - , - {"--stdinit", OPT_STDINIT, 0} - , - {"--nostdinit", OPT_NO_STDINIT, 0} - , - {"-t", OPT_STDOUT, 0} - , - {"--stdout", OPT_STDOUT, 0} - , /* Write generated scanner to stdout. */ - {"-T", OPT_TRACE, 0} - , - {"--trace", OPT_TRACE, 0} - , /* Flex should run in trace mode. */ - {"--tables-file[=FILE]", OPT_TABLES_FILE, 0} - , /* Save tables to FILE */ - {"--tables-verify", OPT_TABLES_VERIFY, 0} - , /* Tables integrity check */ - {"--nounistd", OPT_NO_UNISTD_H, 0} - , /* Do not include unistd.h */ - {"-v", OPT_VERBOSE, 0} - , - {"--verbose", OPT_VERBOSE, 0} - , /* Write summary of scanner statistics to stdout. */ - {"-V", OPT_VERSION, 0} - , - {"--version", OPT_VERSION, 0} - , /* Report flex version. */ - {"--warn", OPT_WARN, 0} - , - {"-w", OPT_NO_WARN, 0} - , - {"--nowarn", OPT_NO_WARN, 0} - , /* Suppress warning messages. */ - {"--noansi-definitions", OPT_NO_ANSI_FUNC_DEFS, 0} - , - {"--noansi-prototypes", OPT_NO_ANSI_FUNC_PROTOS, 0} - , - {"--yyclass=NAME", OPT_YYCLASS, 0} - , - {"--yylineno", OPT_YYLINENO, 0} - , - {"--noyylineno", OPT_NO_YYLINENO, 0} - , - - {"--yymore", OPT_YYMORE, 0} - , - {"--noyymore", OPT_NO_YYMORE, 0} - , - {"--noyywrap", OPT_NO_YYWRAP, 0} - , - {"--yywrap", OPT_YYWRAP, 0} - , - - {"--nounput", OPT_NO_UNPUT, 0} - , - {"--noyy_push_state", OPT_NO_YY_PUSH_STATE, 0} - , - {"--noyy_pop_state", OPT_NO_YY_POP_STATE, 0} - , - {"--noyy_top_state", OPT_NO_YY_TOP_STATE, 0} - , - {"--noyy_scan_buffer", OPT_NO_YY_SCAN_BUFFER, 0} - , - {"--noyy_scan_bytes", OPT_NO_YY_SCAN_BYTES, 0} - , - {"--noyy_scan_string", OPT_NO_YY_SCAN_STRING, 0} - , - {"--noyyget_extra", OPT_NO_YYGET_EXTRA, 0} - , - {"--noyyset_extra", OPT_NO_YYSET_EXTRA, 0} - , - {"--noyyget_leng", OPT_NO_YYGET_LENG, 0} - , - {"--noyyget_text", OPT_NO_YYGET_TEXT, 0} - , - {"--noyyget_lineno", OPT_NO_YYGET_LINENO, 0} - , - {"--noyyset_lineno", OPT_NO_YYSET_LINENO, 0} - , - {"--noyyget_in", OPT_NO_YYGET_IN, 0} - , - {"--noyyset_in", OPT_NO_YYSET_IN, 0} - , - {"--noyyget_out", OPT_NO_YYGET_OUT, 0} - , - {"--noyyset_out", OPT_NO_YYSET_OUT, 0} - , - {"--noyyget_lval", OPT_NO_YYGET_LVAL, 0} - , - {"--noyyset_lval", OPT_NO_YYSET_LVAL, 0} - , - {"--noyyget_lloc", OPT_NO_YYGET_LLOC, 0} - , - {"--noyyset_lloc", OPT_NO_YYSET_LLOC, 0} - , - - {0, 0, 0} /* required final NULL entry. */ -}; diff --git a/third_party/lex/options.h b/third_party/lex/options.h deleted file mode 100644 index 95b9512f..00000000 --- a/third_party/lex/options.h +++ /dev/null @@ -1,135 +0,0 @@ -/* clang-format off */ -/* $OpenBSD: options.h,v 1.2 2015/11/19 22:16:43 tedu Exp $ */ - -/* flex - tool to generate fast lexical analyzers */ - -/* 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 OPTIONS_H -#define OPTIONS_H -#include "scanopt.h" - -extern optspec_t flexopts[]; - -enum flexopt_flag_t { - /* Use positive integers only, since they are return codes for scanopt. - * Order is not important. */ - OPT_7BIT = 1, - OPT_8BIT, - OPT_ALIGN, - OPT_ALWAYS_INTERACTIVE, - OPT_ARRAY, - OPT_BACKUP, - OPT_BATCH, - OPT_BISON_BRIDGE, - OPT_BISON_BRIDGE_LOCATIONS, - OPT_CASE_INSENSITIVE, - OPT_COMPRESSION, - OPT_CPLUSPLUS, - OPT_DEBUG, - OPT_DEFAULT, - OPT_DONOTHING, - OPT_ECS, - OPT_FAST, - OPT_FULL, - OPT_HEADER_FILE, - OPT_HELP, - OPT_INTERACTIVE, - OPT_LEX_COMPAT, - OPT_POSIX_COMPAT, - OPT_MAIN, - OPT_META_ECS, - OPT_NEVER_INTERACTIVE, - OPT_NO_ALIGN, - OPT_NO_ANSI_FUNC_DEFS, - OPT_NO_ANSI_FUNC_PROTOS, - OPT_NO_DEBUG, - OPT_NO_DEFAULT, - OPT_NO_ECS, - OPT_NO_LINE, - OPT_NO_MAIN, - OPT_NO_META_ECS, - OPT_NO_REENTRANT, - OPT_NO_REJECT, - OPT_NO_STDINIT, - OPT_NO_UNPUT, - OPT_NO_WARN, - OPT_NO_YYGET_EXTRA, - OPT_NO_YYGET_IN, - OPT_NO_YYGET_LENG, - OPT_NO_YYGET_LINENO, - OPT_NO_YYGET_LLOC, - OPT_NO_YYGET_LVAL, - OPT_NO_YYGET_OUT, - OPT_NO_YYGET_TEXT, - OPT_NO_YYLINENO, - OPT_NO_YYMORE, - OPT_NO_YYSET_EXTRA, - OPT_NO_YYSET_IN, - OPT_NO_YYSET_LINENO, - OPT_NO_YYSET_LLOC, - OPT_NO_YYSET_LVAL, - OPT_NO_YYSET_OUT, - OPT_NO_YYWRAP, - OPT_NO_YY_POP_STATE, - OPT_NO_YY_PUSH_STATE, - OPT_NO_YY_SCAN_BUFFER, - OPT_NO_YY_SCAN_BYTES, - OPT_NO_YY_SCAN_STRING, - OPT_NO_YY_TOP_STATE, - OPT_OUTFILE, - OPT_PERF_REPORT, - OPT_POINTER, - OPT_PREFIX, - OPT_PREPROCDEFINE, - OPT_PREPROC_LEVEL, - OPT_READ, - OPT_REENTRANT, - OPT_REJECT, - OPT_SKEL, - OPT_STACK, - OPT_STDINIT, - OPT_STDOUT, - OPT_TABLES_FILE, - OPT_TABLES_VERIFY, - OPT_TRACE, - OPT_NO_UNISTD_H, - OPT_VERBOSE, - OPT_VERSION, - OPT_WARN, - OPT_YYCLASS, - OPT_YYLINENO, - OPT_YYMORE, - OPT_YYWRAP -}; - -#endif diff --git a/third_party/lex/parse.c b/third_party/lex/parse.c deleted file mode 100644 index f492b073..00000000 --- a/third_party/lex/parse.c +++ /dev/null @@ -1,1810 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -#include "libc/alg/alg.h" -#include "libc/fmt/fmt.h" -#include "libc/mem/mem.h" -#include "libc/runtime/runtime.h" -#include "libc/str/str.h" -#include "third_party/lex/flexdef.h" -#include "third_party/lex/tables.h" - -/* clang-format off */ -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYLEX yylex() -#define YYEMPTY -1 -#define yyclearin (yychar=(YYEMPTY)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING() (yyerrflag!=0) -#define YYPREFIX "yy" -/* #line 37 "third_party/lex/parse.y" */ -/* 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. */ - - -int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen; -int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule; - -int *scon_stk; -int scon_stk_ptr; - -static int madeany = false; /* whether we've made the '.' character class */ -static int ccldot, cclany; -int previous_continued_action; /* whether the previous rule's action was '|' */ - -#define format_warn3(fmt, a1, a2) \ - do{ \ - char fw3_msg[MAXLINE];\ - snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\ - lexwarn( fw3_msg );\ - }while(0) - -/* Expand a POSIX character class expression. */ -#define CCL_EXPR(func) \ - do{ \ - int c; \ - for ( c = 0; c < csize; ++c ) \ - if ( isascii(c) && func(c) ) \ - ccladd( currccl, c ); \ - }while(0) - -/* negated class */ -#define CCL_NEG_EXPR(func) \ - do{ \ - int c; \ - for ( c = 0; c < csize; ++c ) \ - if ( !func(c) ) \ - ccladd( currccl, c ); \ - }while(0) - -/* On some over-ambitious machines, such as DEC Alpha's, the default - * token type is "long" instead of "int"; this leads to problems with - * declaring yylval in flexdef.h. But so far, all the yacc's I've seen - * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the - * following should ensure that the default token type is "int". - */ -#define YYSTYPE int - -/* #line 91 "third_party/lex/parse.c" */ -#define CHAR 257 -#define NUMBER 258 -#define SECTEND 259 -#define SCDECL 260 -#define XSCDECL 261 -#define NAME 262 -#define PREVCCL 263 -#define EOF_OP 264 -#define OPTION_OP 265 -#define OPT_OUTFILE 266 -#define OPT_PREFIX 267 -#define OPT_YYCLASS 268 -#define OPT_HEADER 269 -#define OPT_EXTRA_TYPE 270 -#define OPT_TABLES 271 -#define CCE_ALNUM 272 -#define CCE_ALPHA 273 -#define CCE_BLANK 274 -#define CCE_CNTRL 275 -#define CCE_DIGIT 276 -#define CCE_GRAPH 277 -#define CCE_LOWER 278 -#define CCE_PRINT 279 -#define CCE_PUNCT 280 -#define CCE_SPACE 281 -#define CCE_UPPER 282 -#define CCE_XDIGIT 283 -#define CCE_NEG_ALNUM 284 -#define CCE_NEG_ALPHA 285 -#define CCE_NEG_BLANK 286 -#define CCE_NEG_CNTRL 287 -#define CCE_NEG_DIGIT 288 -#define CCE_NEG_GRAPH 289 -#define CCE_NEG_LOWER 290 -#define CCE_NEG_PRINT 291 -#define CCE_NEG_PUNCT 292 -#define CCE_NEG_SPACE 293 -#define CCE_NEG_UPPER 294 -#define CCE_NEG_XDIGIT 295 -#define CCL_OP_DIFF 296 -#define CCL_OP_UNION 297 -#define BEGIN_REPEAT_POSIX 298 -#define END_REPEAT_POSIX 299 -#define BEGIN_REPEAT_FLEX 300 -#define END_REPEAT_FLEX 301 -#define YYERRCODE 256 -const short yylhs[] = - { -1, - 0, 1, 2, 2, 2, 2, 3, 6, 6, 7, - 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, - 10, 4, 4, 4, 5, 12, 12, 12, 12, 14, - 11, 11, 11, 15, 15, 15, 16, 13, 13, 13, - 13, 18, 18, 17, 19, 19, 19, 19, 19, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 21, 21, 21, 23, 23, 24, 24, 24, 24, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 22, 22, -}; -const short yylen[] = - { 2, - 5, 0, 3, 2, 0, 1, 1, 1, 1, 2, - 1, 1, 2, 2, 0, 3, 3, 3, 3, 3, - 3, 5, 5, 0, 0, 2, 1, 1, 1, 0, - 4, 3, 0, 3, 1, 1, 1, 2, 3, 2, - 1, 3, 1, 2, 2, 1, 6, 5, 4, 2, - 2, 2, 6, 5, 4, 1, 1, 1, 3, 3, - 1, 3, 3, 1, 3, 4, 4, 2, 2, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 0, -}; -const short yydefred[] = - { 2, - 0, 0, 6, 0, 7, 8, 9, 15, 24, 0, - 4, 0, 0, 12, 11, 0, 0, 0, 0, 0, - 0, 0, 14, 0, 1, 0, 10, 0, 0, 0, - 0, 0, 0, 0, 0, 24, 0, 16, 18, 19, - 20, 17, 21, 32, 36, 37, 0, 35, 0, 29, - 61, 58, 28, 0, 56, 96, 0, 0, 0, 27, - 0, 0, 0, 0, 0, 64, 31, 0, 23, 26, - 0, 0, 70, 0, 22, 0, 40, 0, 44, 0, - 0, 0, 50, 51, 52, 0, 0, 34, 95, 59, - 60, 0, 0, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 82, 81, 83, 84, 85, 86, 87, - 88, 93, 89, 90, 91, 94, 92, 65, 69, 39, - 0, 0, 0, 62, 63, 66, 0, 49, 0, 55, - 0, 67, 0, 48, 0, 54, 47, 53, -}; -const short yydgoto[] = - { 1, - 2, 4, 9, 13, 25, 10, 16, 11, 12, 23, - 26, 59, 60, 35, 47, 48, 61, 62, 63, 64, - 65, 71, 66, 74, 119, -}; -const short yysindex[] = - { 0, - 0, -222, 0, -155, 0, 0, 0, 0, 0, -215, - 0, -123, 6, 0, 0, -193, 10, 21, 26, 31, - 35, 37, 0, 59, 0, -44, 0, -147, -145, -140, - -133, -132, -129, 75, -214, 0, -19, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 23, 0, -48, 0, - 0, 0, 0, -17, 0, 0, -17, 27, 128, 0, - -17, -1, -30, -41, -189, 0, 0, -121, 0, 0, - -31, -34, 0, -87, 0, -25, 0, -17, 0, -109, - -41, -108, 0, 0, 0, 60, 60, 0, 0, 0, - 0, 46, 107, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -30, -36, -39, 0, 0, 0, -104, 0, -219, 0, - -238, 0, -144, 0, -143, 0, 0, 0,}; -const short yyrindex[] = - { 0, - 0, -141, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -134, 9, 0, 0, -125, 0, 0, 0, 0, - 0, 0, 0, -178, 0, 22, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -21, 0, - 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, - 0, 144, 47, 4, -10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 146, 0, 0, 0, 0, - 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 124, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0,}; -const short yygindex[] = - { 0, - 0, 0, 0, 121, 133, 0, 0, 0, 0, 0, - 0, 0, 106, 0, 0, 93, 0, 32, 84, -45, - 0, 0, 25, 90, 0, -}; -#define YYTABLESIZE 419 -const short yytable[] = - { 57, - 83, 84, 90, 56, 131, 118, 91, 129, 25, 57, - 120, 24, 33, 46, 56, 55, 56, 81, 33, 135, - 57, 85, 57, 57, 33, 57, 55, 45, 55, 57, - 57, 57, 57, 3, 77, 57, 57, 46, 133, 46, - 14, 45, 33, 46, 46, 79, 15, 46, 33, 46, - 46, 45, 57, 45, 33, 25, 43, 45, 45, 42, - 58, 25, 136, 45, 45, 24, 68, 25, 27, 33, - 28, 58, 33, 58, 54, 81, 69, 30, 36, 134, - 57, 29, 43, 30, 67, 42, 30, 43, 72, 78, - 42, 31, 76, 43, 46, 32, 42, 33, 78, 33, - 34, 33, 33, 5, 6, 7, 86, 87, 45, 8, - 124, 125, 25, 57, 38, 25, 39, 5, 5, 5, - 73, 40, 78, 5, 13, 13, 13, 46, 41, 42, - 13, 33, 43, 3, 3, 3, 44, 75, 126, 3, - 46, 45, 17, 18, 19, 20, 21, 22, 122, 123, - 58, 127, 132, 41, 137, 38, 49, 138, 37, 70, - 88, 121, 92, 0, 0, 0, 0, 0, 0, 93, - 43, 0, 0, 42, 0, 0, 0, 70, 0, 0, - 0, 0, 0, 0, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 0, 0, - 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 89, 51, 0, 0, 0, - 0, 0, 52, 0, 33, 33, 50, 51, 0, 51, - 0, 33, 33, 52, 53, 52, 57, 0, 0, 0, - 0, 0, 57, 0, 0, 0, 0, 0, 82, 0, - 46, 130, 128, 0, 33, 33, 46, 80, 0, 0, - 0, 33, 33, 0, 45, 0, 0, 25, 25, 0, - 45, 0, 0, 0, 25, 25, 0, 57, 0, 57, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 46, 93, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 45, 0, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 70, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, -}; -const short yycheck[] = - { 10, - 42, 43, 34, 34, 44, 93, 41, 44, 0, 40, - 36, 60, 34, 10, 34, 46, 34, 63, 40, 258, - 40, 63, 40, 34, 46, 36, 46, 10, 46, 40, - 41, 42, 43, 256, 36, 46, 47, 34, 258, 36, - 256, 256, 34, 40, 41, 47, 262, 262, 40, 46, - 47, 34, 63, 36, 46, 34, 10, 40, 41, 10, - 91, 40, 301, 46, 47, 60, 44, 46, 262, 91, - 61, 91, 94, 91, 94, 121, 125, 256, 123, 299, - 91, 61, 36, 262, 62, 36, 61, 41, 57, 124, - 41, 61, 61, 47, 91, 61, 47, 61, 124, 91, - 42, 123, 94, 259, 260, 261, 296, 297, 91, 265, - 86, 87, 91, 124, 262, 94, 262, 259, 260, 261, - 94, 262, 124, 265, 259, 260, 261, 124, 262, 262, - 265, 123, 262, 259, 260, 261, 62, 10, 93, 265, - 262, 124, 266, 267, 268, 269, 270, 271, 258, 258, - 91, 45, 257, 10, 299, 10, 36, 301, 26, 54, - 68, 78, 73, -1, -1, -1, -1, -1, -1, 257, - 124, -1, -1, 124, -1, -1, -1, 93, -1, -1, - -1, -1, -1, -1, 272, 273, 274, 275, 276, 277, - 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, -1, -1, - -1, -1, -1, -1, -1, -1, 93, -1, -1, -1, - -1, -1, -1, -1, -1, 257, 257, -1, -1, -1, - -1, -1, 263, -1, 256, 257, 256, 257, -1, 257, - -1, 263, 264, 263, 264, 263, 257, -1, -1, -1, - -1, -1, 263, -1, -1, -1, -1, -1, 300, -1, - 257, 301, 299, -1, 256, 257, 263, 298, -1, -1, - -1, 263, 264, -1, 257, -1, -1, 256, 257, -1, - 263, -1, -1, -1, 263, 264, -1, 298, -1, 300, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 298, 257, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 298, -1, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 257, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, - 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, - 257, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, - 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 301 -#if YYDEBUG -const char * const yyname[] = - { -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0, -0,0,0,0,0,0,0,0,0,0,"'<'","'='","'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,"'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR","NUMBER","SECTEND", -"SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","OPTION_OP","OPT_OUTFILE", -"OPT_PREFIX","OPT_YYCLASS","OPT_HEADER","OPT_EXTRA_TYPE","OPT_TABLES", -"CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL","CCE_DIGIT","CCE_GRAPH", -"CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE","CCE_UPPER","CCE_XDIGIT", -"CCE_NEG_ALNUM","CCE_NEG_ALPHA","CCE_NEG_BLANK","CCE_NEG_CNTRL","CCE_NEG_DIGIT", -"CCE_NEG_GRAPH","CCE_NEG_LOWER","CCE_NEG_PRINT","CCE_NEG_PUNCT","CCE_NEG_SPACE", -"CCE_NEG_UPPER","CCE_NEG_XDIGIT","CCL_OP_DIFF","CCL_OP_UNION", -"BEGIN_REPEAT_POSIX","END_REPEAT_POSIX","BEGIN_REPEAT_FLEX","END_REPEAT_FLEX", -}; -const char * const yyrule[] = - {"$accept : goal", -"goal : initlex sect1 sect1end sect2 initforrule", -"initlex :", -"sect1 : sect1 startconddecl namelist1", -"sect1 : sect1 options", -"sect1 :", -"sect1 : error", -"sect1end : SECTEND", -"startconddecl : SCDECL", -"startconddecl : XSCDECL", -"namelist1 : namelist1 NAME", -"namelist1 : NAME", -"namelist1 : error", -"options : OPTION_OP optionlist", -"optionlist : optionlist option", -"optionlist :", -"option : OPT_OUTFILE '=' NAME", -"option : OPT_EXTRA_TYPE '=' NAME", -"option : OPT_PREFIX '=' NAME", -"option : OPT_YYCLASS '=' NAME", -"option : OPT_HEADER '=' NAME", -"option : OPT_TABLES '=' NAME", -"sect2 : sect2 scon initforrule flexrule '\\n'", -"sect2 : sect2 scon '{' sect2 '}'", -"sect2 :", -"initforrule :", -"flexrule : '^' rule", -"flexrule : rule", -"flexrule : EOF_OP", -"flexrule : error", -"scon_stk_ptr :", -"scon : '<' scon_stk_ptr namelist2 '>'", -"scon : '<' '*' '>'", -"scon :", -"namelist2 : namelist2 ',' sconname", -"namelist2 : sconname", -"namelist2 : error", -"sconname : NAME", -"rule : re2 re", -"rule : re2 re '$'", -"rule : re '$'", -"rule : re", -"re : re '|' series", -"re : series", -"re2 : re '/'", -"series : series singleton", -"series : singleton", -"series : series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX", -"series : series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX", -"series : series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX", -"singleton : singleton '*'", -"singleton : singleton '+'", -"singleton : singleton '?'", -"singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX", -"singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX", -"singleton : singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX", -"singleton : '.'", -"singleton : fullccl", -"singleton : PREVCCL", -"singleton : '\"' string '\"'", -"singleton : '(' re ')'", -"singleton : CHAR", -"fullccl : fullccl CCL_OP_DIFF braceccl", -"fullccl : fullccl CCL_OP_UNION braceccl", -"fullccl : braceccl", -"braceccl : '[' ccl ']'", -"braceccl : '[' '^' ccl ']'", -"ccl : ccl CHAR '-' CHAR", -"ccl : ccl CHAR", -"ccl : ccl ccl_expr", -"ccl :", -"ccl_expr : CCE_ALNUM", -"ccl_expr : CCE_ALPHA", -"ccl_expr : CCE_BLANK", -"ccl_expr : CCE_CNTRL", -"ccl_expr : CCE_DIGIT", -"ccl_expr : CCE_GRAPH", -"ccl_expr : CCE_LOWER", -"ccl_expr : CCE_PRINT", -"ccl_expr : CCE_PUNCT", -"ccl_expr : CCE_SPACE", -"ccl_expr : CCE_XDIGIT", -"ccl_expr : CCE_UPPER", -"ccl_expr : CCE_NEG_ALNUM", -"ccl_expr : CCE_NEG_ALPHA", -"ccl_expr : CCE_NEG_BLANK", -"ccl_expr : CCE_NEG_CNTRL", -"ccl_expr : CCE_NEG_DIGIT", -"ccl_expr : CCE_NEG_GRAPH", -"ccl_expr : CCE_NEG_PRINT", -"ccl_expr : CCE_NEG_PUNCT", -"ccl_expr : CCE_NEG_SPACE", -"ccl_expr : CCE_NEG_XDIGIT", -"ccl_expr : CCE_NEG_LOWER", -"ccl_expr : CCE_NEG_UPPER", -"string : string CHAR", -"string :", -}; -#endif -#ifndef YYSTYPE -typedef int YYSTYPE; -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif -#define YYINITSTACKSIZE 200 -/* LINTUSED */ -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short *yyss; -short *yysslim; -YYSTYPE *yyvs; -unsigned int yystacksize; -/* int yyparse(void); */ -/* #line 947 "third_party/lex/parse.y" */ - - -/* build_eof_action - build the "<>" action for the active start - * conditions - */ - -void build_eof_action() - { - int i2; - char action_text[MAXLINE]; - - for ( i2 = 1; i2 <= scon_stk_ptr; ++i2 ) - { - if ( sceof[scon_stk[i2]] ) - format_pinpoint_message( - "multiple <> rules for start condition %s", - scname[scon_stk[i2]] ); - - else - { - sceof[scon_stk[i2]] = true; - - if (previous_continued_action /* && previous action was regular */) - add_action("YY_RULE_SETUP\n"); - - snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n", - scname[scon_stk[i2]] ); - add_action( action_text ); - } - } - - line_directive_out( (FILE *) 0, 1 ); - - /* This isn't a normal rule after all - don't count it as - * such, so we don't have any holes in the rule numbering - * (which make generating "rule can never match" warnings - * more difficult. - */ - --num_rules; - ++num_eof_rules; - } - - -/* format_synerr - write out formatted syntax error */ - -void format_synerr( msg, arg ) -const char *msg, arg[]; - { - char errmsg[MAXLINE]; - - (void) snprintf( errmsg, sizeof(errmsg), msg, arg ); - synerr( errmsg ); - } - - -/* synerr - report a syntax error */ - -void synerr( str ) -const char *str; - { - syntaxerror = true; - pinpoint_message( str ); - } - - -/* format_warn - write out formatted warning */ - -void format_warn( msg, arg ) -const char *msg, arg[]; - { - char warn_msg[MAXLINE]; - - snprintf( warn_msg, sizeof(warn_msg), msg, arg ); - lexwarn( warn_msg ); - } - - -/* warn - report a warning, unless -w was given */ - -void lexwarn( str ) -const char *str; - { - line_warning( str, linenum ); - } - -/* format_pinpoint_message - write out a message formatted with one string, - * pinpointing its location - */ - -void format_pinpoint_message( msg, arg ) -const char *msg, arg[]; - { - char errmsg[MAXLINE]; - - snprintf( errmsg, sizeof(errmsg), msg, arg ); - pinpoint_message( errmsg ); - } - - -/* pinpoint_message - write out a message, pinpointing its location */ - -void pinpoint_message( str ) -const char *str; - { - line_pinpoint( str, linenum ); - } - - -/* line_warning - report a warning at a given line, unless -w was given */ - -void line_warning( str, line ) -const char *str; -int line; - { - char warning[MAXLINE]; - - if ( ! nowarn ) - { - snprintf( warning, sizeof(warning), "warning, %s", str ); - line_pinpoint( warning, line ); - } - } - - -/* line_pinpoint - write out a message, pinpointing it at the given line */ - -void line_pinpoint( str, line ) -const char *str; -int line; - { - fprintf( stderr, "%s:%d: %s\n", infilename, line, str ); - } - - -/* yyerror - eat up an error message from the parser; - * currently, messages are ignore - */ - -void yyerror( msg ) -const char *msg; - { - } -/* #line 605 "third_party/lex/parse.c" */ -/* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack(void) -{ - unsigned int newsize; - long sslen; - short *newss; - YYSTYPE *newvs; - - if ((newsize = yystacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return -1; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - sslen = yyssp - yyss; -#ifdef SIZE_MAX -#define YY_SIZE_MAX SIZE_MAX -#else -#define YY_SIZE_MAX 0xffffffffU -#endif - if (newsize && YY_SIZE_MAX / newsize < sizeof *newss) - goto bail; - newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : - (short *)malloc(newsize * sizeof *newss); /* overflow check above */ - if (newss == NULL) - goto bail; - yyss = newss; - yyssp = newss + sslen; - if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs) - goto bail; - newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : - (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */ - if (newvs == NULL) - goto bail; - yyvs = newvs; - yyvsp = newvs + sslen; - yystacksize = newsize; - yysslim = yyss + newsize - 1; - return 0; -bail: - if (yyss) - free(yyss); - if (yyvs) - free(yyvs); - yyss = yyssp = NULL; - yyvs = yyvsp = NULL; - yystacksize = 0; - return -1; -} - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse(void) -{ - int yym, yyn, yystate; -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG"))) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif /* YYDEBUG */ - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - if (yyss == NULL && yygrowstack()) goto yyoverflow; - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#if defined(__GNUC__) - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#if defined(__GNUC__) - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym) - yyval = yyvsp[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - switch (yyn) - { -case 1: -/* #line 118 "third_party/lex/parse.y" */ -{ /* add default rule */ - int def_rule; - - pat = cclinit(); - cclnegate( pat ); - - def_rule = mkstate( -pat ); - - /* Remember the number of the default rule so we - * don't generate "can't match" warnings for it. - */ - default_rule = num_rules; - - finish_rule( def_rule, false, 0, 0, 0); - - for ( i = 1; i <= lastsc; ++i ) - scset[i] = mkbranch( scset[i], def_rule ); - - if ( spprdflt ) - add_action( - "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); - else - add_action( "ECHO" ); - - add_action( ";\n\tYY_BREAK\n" ); - } -break; -case 2: -/* #line 147 "third_party/lex/parse.y" */ -{ /* initialize for processing rules */ - - /* Create default DFA start condition. */ - scinstal( "INITIAL", false ); - } -break; -case 6: -/* #line 158 "third_party/lex/parse.y" */ -{ synerr( _("unknown error processing section 1") ); } -break; -case 7: -/* #line 162 "third_party/lex/parse.y" */ -{ - check_options(); - scon_stk = allocate_integer_array( lastsc + 1 ); - scon_stk_ptr = 0; - } -break; -case 8: -/* #line 170 "third_party/lex/parse.y" */ -{ xcluflg = false; } -break; -case 9: -/* #line 173 "third_party/lex/parse.y" */ -{ xcluflg = true; } -break; -case 10: -/* #line 177 "third_party/lex/parse.y" */ -{ scinstal( nmstr, xcluflg ); } -break; -case 11: -/* #line 180 "third_party/lex/parse.y" */ -{ scinstal( nmstr, xcluflg ); } -break; -case 12: -/* #line 183 "third_party/lex/parse.y" */ -{ synerr( _("bad start condition list") ); } -break; -case 16: -/* #line 194 "third_party/lex/parse.y" */ -{ - outfilename = copy_string( nmstr ); - did_outfilename = 1; - } -break; -case 17: -/* #line 199 "third_party/lex/parse.y" */ -{ extra_type = copy_string( nmstr ); } -break; -case 18: -/* #line 201 "third_party/lex/parse.y" */ -{ prefix = copy_string( nmstr ); } -break; -case 19: -/* #line 203 "third_party/lex/parse.y" */ -{ yyclass = copy_string( nmstr ); } -break; -case 20: -/* #line 205 "third_party/lex/parse.y" */ -{ headerfilename = copy_string( nmstr ); } -break; -case 21: -/* #line 207 "third_party/lex/parse.y" */ -{ tablesext = true; tablesfilename = copy_string( nmstr ); } -break; -case 22: -/* #line 211 "third_party/lex/parse.y" */ -{ scon_stk_ptr = yyvsp[-3]; } -break; -case 23: -/* #line 213 "third_party/lex/parse.y" */ -{ scon_stk_ptr = yyvsp[-3]; } -break; -case 25: -/* #line 218 "third_party/lex/parse.y" */ -{ - /* Initialize for a parse of one rule. */ - trlcontxt = variable_trail_rule = varlength = false; - trailcnt = headcnt = rulelen = 0; - current_state_type = STATE_NORMAL; - previous_continued_action = continued_action; - in_rule = true; - - new_rule(); - } -break; -case 26: -/* #line 231 "third_party/lex/parse.y" */ -{ - pat = yyvsp[0]; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt , previous_continued_action); - - if ( scon_stk_ptr > 0 ) - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - scbol[scon_stk[i]] = - mkbranch( scbol[scon_stk[i]], - pat ); - } - - else - { - /* Add to all non-exclusive start conditions, - * including the default (0) start condition. - */ - - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scbol[i] = mkbranch( scbol[i], - pat ); - } - - if ( ! bol_needed ) - { - bol_needed = true; - - if ( performance_report > 1 ) - pinpoint_message( - "'^' operator results in sub-optimal performance" ); - } - } -break; -case 27: -/* #line 267 "third_party/lex/parse.y" */ -{ - pat = yyvsp[0]; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt , previous_continued_action); - - if ( scon_stk_ptr > 0 ) - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - scset[scon_stk[i]] = - mkbranch( scset[scon_stk[i]], - pat ); - } - - else - { - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scset[i] = - mkbranch( scset[i], - pat ); - } - } -break; -case 28: -/* #line 291 "third_party/lex/parse.y" */ -{ - if ( scon_stk_ptr > 0 ) - build_eof_action(); - - else - { - /* This EOF applies to all start conditions - * which don't already have EOF actions. - */ - for ( i = 1; i <= lastsc; ++i ) - if ( ! sceof[i] ) - scon_stk[++scon_stk_ptr] = i; - - if ( scon_stk_ptr == 0 ) - lexwarn( - "all start conditions already have <> rules" ); - - else - build_eof_action(); - } - } -break; -case 29: -/* #line 314 "third_party/lex/parse.y" */ -{ synerr( _("unrecognized rule") ); } -break; -case 30: -/* #line 318 "third_party/lex/parse.y" */ -{ yyval = scon_stk_ptr; } -break; -case 31: -/* #line 322 "third_party/lex/parse.y" */ -{ yyval = yyvsp[-2]; } -break; -case 32: -/* #line 325 "third_party/lex/parse.y" */ -{ - yyval = scon_stk_ptr; - - for ( i = 1; i <= lastsc; ++i ) - { - int j; - - for ( j = 1; j <= scon_stk_ptr; ++j ) - if ( scon_stk[j] == i ) - break; - - if ( j > scon_stk_ptr ) - scon_stk[++scon_stk_ptr] = i; - } - } -break; -case 33: -/* #line 342 "third_party/lex/parse.y" */ -{ yyval = scon_stk_ptr; } -break; -case 36: -/* #line 350 "third_party/lex/parse.y" */ -{ synerr( _("bad start condition list") ); } -break; -case 37: -/* #line 354 "third_party/lex/parse.y" */ -{ - if ( (scnum = sclookup( nmstr )) == 0 ) - format_pinpoint_message( - "undeclared start condition %s", - nmstr ); - else - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - if ( scon_stk[i] == scnum ) - { - format_warn( - "<%s> specified twice", - scname[scnum] ); - break; - } - - if ( i > scon_stk_ptr ) - scon_stk[++scon_stk_ptr] = scnum; - } - } -break; -case 38: -/* #line 377 "third_party/lex/parse.y" */ -{ - if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON ) - /* Provide final transition \now/ so it - * will be marked as a trailing context - * state. - */ - yyvsp[0] = link_machines( yyvsp[0], - mkstate( SYM_EPSILON ) ); - - mark_beginning_as_normal( yyvsp[0] ); - current_state_type = STATE_NORMAL; - - if ( previous_continued_action ) - { - /* We need to treat this as variable trailing - * context so that the backup does not happen - * in the action but before the action switch - * statement. If the backup happens in the - * action, then the rules "falling into" this - * one's action will *also* do the backup, - * erroneously. - */ - if ( ! varlength || headcnt != 0 ) - lexwarn( - "trailing context made variable due to preceding '|' action" ); - - /* Mark as variable. */ - varlength = true; - headcnt = 0; - - } - - if ( lex_compat || (varlength && headcnt == 0) ) - { /* variable trailing context rule */ - /* Mark the first part of the rule as the - * accepting "head" part of a trailing - * context rule. - * - * By the way, we didn't do this at the - * beginning of this production because back - * then current_state_type was set up for a - * trail rule, and add_accept() can create - * a new state ... - */ - add_accept( yyvsp[-1], - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - else - trailcnt = rulelen; - - yyval = link_machines( yyvsp[-1], yyvsp[0] ); - } -break; -case 39: -/* #line 433 "third_party/lex/parse.y" */ -{ synerr( _("trailing context used twice") ); } -break; -case 40: -/* #line 436 "third_party/lex/parse.y" */ -{ - headcnt = 0; - trailcnt = 1; - rulelen = 1; - varlength = false; - - current_state_type = STATE_TRAILING_CONTEXT; - - if ( trlcontxt ) - { - synerr( _("trailing context used twice") ); - yyval = mkstate( SYM_EPSILON ); - } - - else if ( previous_continued_action ) - { - /* See the comment in the rule for "re2 re" - * above. - */ - lexwarn( - "trailing context made variable due to preceding '|' action" ); - - varlength = true; - } - - if ( lex_compat || varlength ) - { - /* Again, see the comment in the rule for - * "re2 re" above. - */ - add_accept( yyvsp[-1], - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - trlcontxt = true; - - eps = mkstate( SYM_EPSILON ); - yyval = link_machines( yyvsp[-1], - link_machines( eps, mkstate( '\n' ) ) ); - } -break; -case 41: -/* #line 479 "third_party/lex/parse.y" */ -{ - yyval = yyvsp[0]; - - if ( trlcontxt ) - { - if ( lex_compat || (varlength && headcnt == 0) ) - /* Both head and trail are - * variable-length. - */ - variable_trail_rule = true; - else - trailcnt = rulelen; - } - } -break; -case 42: -/* #line 497 "third_party/lex/parse.y" */ -{ - varlength = true; - yyval = mkor( yyvsp[-2], yyvsp[0] ); - } -break; -case 43: -/* #line 503 "third_party/lex/parse.y" */ -{ yyval = yyvsp[0]; } -break; -case 44: -/* #line 508 "third_party/lex/parse.y" */ -{ - /* This rule is written separately so the - * reduction will occur before the trailing - * series is parsed. - */ - - if ( trlcontxt ) - synerr( _("trailing context used twice") ); - else - trlcontxt = true; - - if ( varlength ) - /* We hope the trailing context is - * fixed-length. - */ - varlength = false; - else - headcnt = rulelen; - - rulelen = 0; - - current_state_type = STATE_TRAILING_CONTEXT; - yyval = yyvsp[-1]; - } -break; -case 45: -/* #line 535 "third_party/lex/parse.y" */ -{ - /* This is where concatenation of adjacent patterns - * gets done. - */ - yyval = link_machines( yyvsp[-1], yyvsp[0] ); - } -break; -case 46: -/* #line 543 "third_party/lex/parse.y" */ -{ yyval = yyvsp[0]; } -break; -case 47: -/* #line 546 "third_party/lex/parse.y" */ -{ - varlength = true; - - if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 ) - { - synerr( _("bad iteration values") ); - yyval = yyvsp[-5]; - } - else - { - if ( yyvsp[-3] == 0 ) - { - if ( yyvsp[-1] <= 0 ) - { - synerr( - _("bad iteration values") ); - yyval = yyvsp[-5]; - } - else - yyval = mkopt( - mkrep( yyvsp[-5], 1, yyvsp[-1] ) ); - } - else - yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ); - } - } -break; -case 48: -/* #line 574 "third_party/lex/parse.y" */ -{ - varlength = true; - - if ( yyvsp[-2] <= 0 ) - { - synerr( _("iteration value must be positive") ); - yyval = yyvsp[-4]; - } - - else - yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITE_REPEAT ); - } -break; -case 49: -/* #line 588 "third_party/lex/parse.y" */ -{ - /* The series could be something like "(foo)", - * in which case we have no idea what its length - * is, so we punt here. - */ - varlength = true; - - if ( yyvsp[-1] <= 0 ) - { - synerr( _("iteration value must be positive") - ); - yyval = yyvsp[-3]; - } - - else - yyval = link_machines( yyvsp[-3], - copysingl( yyvsp[-3], yyvsp[-1] - 1 ) ); - } -break; -case 50: -/* #line 610 "third_party/lex/parse.y" */ -{ - varlength = true; - - yyval = mkclos( yyvsp[-1] ); - } -break; -case 51: -/* #line 617 "third_party/lex/parse.y" */ -{ - varlength = true; - yyval = mkposcl( yyvsp[-1] ); - } -break; -case 52: -/* #line 623 "third_party/lex/parse.y" */ -{ - varlength = true; - yyval = mkopt( yyvsp[-1] ); - } -break; -case 53: -/* #line 629 "third_party/lex/parse.y" */ -{ - varlength = true; - - if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 ) - { - synerr( _("bad iteration values") ); - yyval = yyvsp[-5]; - } - else - { - if ( yyvsp[-3] == 0 ) - { - if ( yyvsp[-1] <= 0 ) - { - synerr( - _("bad iteration values") ); - yyval = yyvsp[-5]; - } - else - yyval = mkopt( - mkrep( yyvsp[-5], 1, yyvsp[-1] ) ); - } - else - yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ); - } - } -break; -case 54: -/* #line 657 "third_party/lex/parse.y" */ -{ - varlength = true; - - if ( yyvsp[-2] <= 0 ) - { - synerr( _("iteration value must be positive") ); - yyval = yyvsp[-4]; - } - - else - yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITE_REPEAT ); - } -break; -case 55: -/* #line 671 "third_party/lex/parse.y" */ -{ - /* The singleton could be something like "(foo)", - * in which case we have no idea what its length - * is, so we punt here. - */ - varlength = true; - - if ( yyvsp[-1] <= 0 ) - { - synerr( _("iteration value must be positive") ); - yyval = yyvsp[-3]; - } - - else - yyval = link_machines( yyvsp[-3], - copysingl( yyvsp[-3], yyvsp[-1] - 1 ) ); - } -break; -case 56: -/* #line 690 "third_party/lex/parse.y" */ -{ - if ( ! madeany ) - { - /* Create the '.' character class. */ - ccldot = cclinit(); - ccladd( ccldot, '\n' ); - cclnegate( ccldot ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[ccldot], - ccllen[ccldot], nextecm, - ecgroup, csize, csize ); - - /* Create the (?s:'.') character class. */ - cclany = cclinit(); - cclnegate( cclany ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[cclany], - ccllen[cclany], nextecm, - ecgroup, csize, csize ); - - madeany = true; - } - - ++rulelen; - - if (sf_dot_all()) - yyval = mkstate( -cclany ); - else - yyval = mkstate( -ccldot ); - } -break; -case 57: -/* #line 724 "third_party/lex/parse.y" */ -{ - /* Sort characters for fast searching. - */ - qsort( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], sizeof (*ccltbl), cclcmp ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], - nextecm, ecgroup, csize, csize ); - - ++rulelen; - - if (ccl_has_nl[yyvsp[0]]) - rule_has_nl[num_rules] = true; - - yyval = mkstate( -yyvsp[0] ); - } -break; -case 58: -/* #line 742 "third_party/lex/parse.y" */ -{ - ++rulelen; - - if (ccl_has_nl[yyvsp[0]]) - rule_has_nl[num_rules] = true; - - yyval = mkstate( -yyvsp[0] ); - } -break; -case 59: -/* #line 752 "third_party/lex/parse.y" */ -{ yyval = yyvsp[-1]; } -break; -case 60: -/* #line 755 "third_party/lex/parse.y" */ -{ yyval = yyvsp[-1]; } -break; -case 61: -/* #line 758 "third_party/lex/parse.y" */ -{ - ++rulelen; - - if (yyvsp[0] == nlch) - rule_has_nl[num_rules] = true; - - if (sf_case_ins() && has_case(yyvsp[0])) - /* create an alternation, as in (a|A) */ - yyval = mkor (mkstate(yyvsp[0]), mkstate(reverse_case(yyvsp[0]))); - else - yyval = mkstate( yyvsp[0] ); - } -break; -case 62: -/* #line 772 "third_party/lex/parse.y" */ -{ yyval = ccl_set_diff (yyvsp[-2], yyvsp[0]); } -break; -case 63: -/* #line 773 "third_party/lex/parse.y" */ -{ yyval = ccl_set_union (yyvsp[-2], yyvsp[0]); } -break; -case 65: -/* #line 779 "third_party/lex/parse.y" */ -{ yyval = yyvsp[-1]; } -break; -case 66: -/* #line 782 "third_party/lex/parse.y" */ -{ - cclnegate( yyvsp[-1] ); - yyval = yyvsp[-1]; - } -break; -case 67: -/* #line 789 "third_party/lex/parse.y" */ -{ - - if (sf_case_ins()) - { - - /* If one end of the range has case and the other - * does not, or the cases are different, then we're not - * sure what range the user is trying to express. - * Examples: [@-z] or [S-t] - */ - if (has_case (yyvsp[-2]) != has_case (yyvsp[0]) - || (has_case (yyvsp[-2]) && (b_islower (yyvsp[-2]) != b_islower (yyvsp[0]))) - || (has_case (yyvsp[-2]) && (b_isupper (yyvsp[-2]) != b_isupper (yyvsp[0])))) - format_warn3 ( - _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"), - yyvsp[-2], yyvsp[0]); - - /* If the range spans uppercase characters but not - * lowercase (or vice-versa), then should we automatically - * include lowercase characters in the range? - * Example: [@-_] spans [a-z] but not [A-Z] - */ - else if (!has_case (yyvsp[-2]) && !has_case (yyvsp[0]) && !range_covers_case (yyvsp[-2], yyvsp[0])) - format_warn3 ( - _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"), - yyvsp[-2], yyvsp[0]); - } - - if ( yyvsp[-2] > yyvsp[0] ) - synerr( _("negative range in character class") ); - - else - { - for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i ) - ccladd( yyvsp[-3], i ); - - /* Keep track if this ccl is staying in - * alphabetical order. - */ - cclsorted = cclsorted && (yyvsp[-2] > lastchar); - lastchar = yyvsp[0]; - - /* Do it again for upper/lowercase */ - if (sf_case_ins() && has_case(yyvsp[-2]) && has_case(yyvsp[0])){ - yyvsp[-2] = reverse_case (yyvsp[-2]); - yyvsp[0] = reverse_case (yyvsp[0]); - - for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i ) - ccladd( yyvsp[-3], i ); - - cclsorted = cclsorted && (yyvsp[-2] > lastchar); - lastchar = yyvsp[0]; - } - - } - - yyval = yyvsp[-3]; - } -break; -case 68: -/* #line 849 "third_party/lex/parse.y" */ -{ - ccladd( yyvsp[-1], yyvsp[0] ); - cclsorted = cclsorted && (yyvsp[0] > lastchar); - lastchar = yyvsp[0]; - - /* Do it again for upper/lowercase */ - if (sf_case_ins() && has_case(yyvsp[0])){ - yyvsp[0] = reverse_case (yyvsp[0]); - ccladd (yyvsp[-1], yyvsp[0]); - - cclsorted = cclsorted && (yyvsp[0] > lastchar); - lastchar = yyvsp[0]; - } - - yyval = yyvsp[-1]; - } -break; -case 69: -/* #line 867 "third_party/lex/parse.y" */ -{ - /* Too hard to properly maintain cclsorted. */ - cclsorted = false; - yyval = yyvsp[-1]; - } -break; -case 70: -/* #line 874 "third_party/lex/parse.y" */ -{ - cclsorted = true; - lastchar = 0; - currccl = yyval = cclinit(); - } -break; -case 71: -/* #line 882 "third_party/lex/parse.y" */ -{ CCL_EXPR(isalnum); } -break; -case 72: -/* #line 883 "third_party/lex/parse.y" */ -{ CCL_EXPR(isalpha); } -break; -case 73: -/* #line 884 "third_party/lex/parse.y" */ -{ CCL_EXPR(isblank); } -break; -case 74: -/* #line 885 "third_party/lex/parse.y" */ -{ CCL_EXPR(iscntrl); } -break; -case 75: -/* #line 886 "third_party/lex/parse.y" */ -{ CCL_EXPR(isdigit); } -break; -case 76: -/* #line 887 "third_party/lex/parse.y" */ -{ CCL_EXPR(isgraph); } -break; -case 77: -/* #line 888 "third_party/lex/parse.y" */ -{ - CCL_EXPR(islower); - if (sf_case_ins()) - CCL_EXPR(isupper); - } -break; -case 78: -/* #line 893 "third_party/lex/parse.y" */ -{ CCL_EXPR(isprint); } -break; -case 79: -/* #line 894 "third_party/lex/parse.y" */ -{ CCL_EXPR(ispunct); } -break; -case 80: -/* #line 895 "third_party/lex/parse.y" */ -{ CCL_EXPR(isspace); } -break; -case 81: -/* #line 896 "third_party/lex/parse.y" */ -{ CCL_EXPR(isxdigit); } -break; -case 82: -/* #line 897 "third_party/lex/parse.y" */ -{ - CCL_EXPR(isupper); - if (sf_case_ins()) - CCL_EXPR(islower); - } -break; -case 83: -/* #line 903 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isalnum); } -break; -case 84: -/* #line 904 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isalpha); } -break; -case 85: -/* #line 905 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isblank); } -break; -case 86: -/* #line 906 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(iscntrl); } -break; -case 87: -/* #line 907 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isdigit); } -break; -case 88: -/* #line 908 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isgraph); } -break; -case 89: -/* #line 909 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isprint); } -break; -case 90: -/* #line 910 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(ispunct); } -break; -case 91: -/* #line 911 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isspace); } -break; -case 92: -/* #line 912 "third_party/lex/parse.y" */ -{ CCL_NEG_EXPR(isxdigit); } -break; -case 93: -/* #line 913 "third_party/lex/parse.y" */ -{ - if ( sf_case_ins() ) - lexwarn(_("[:^lower:] is ambiguous in case insensitive scanner")); - else - CCL_NEG_EXPR(islower); - } -break; -case 94: -/* #line 919 "third_party/lex/parse.y" */ -{ - if ( sf_case_ins() ) - lexwarn(_("[:^upper:] ambiguous in case insensitive scanner")); - else - CCL_NEG_EXPR(isupper); - } -break; -case 95: -/* #line 928 "third_party/lex/parse.y" */ -{ - if ( yyvsp[0] == nlch ) - rule_has_nl[num_rules] = true; - - ++rulelen; - - if (sf_case_ins() && has_case(yyvsp[0])) - yyval = mkor (mkstate(yyvsp[0]), mkstate(reverse_case(yyvsp[0]))); - else - yyval = mkstate (yyvsp[0]); - - yyval = link_machines( yyvsp[-1], yyval); - } -break; -case 96: -/* #line 943 "third_party/lex/parse.y" */ -{ yyval = mkstate( SYM_EPSILON ); } -break; -/* #line 1724 "third_party/lex/parse.c" */ - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - if (yyss) - free(yyss); - if (yyvs) - free(yyvs); - yyss = yyssp = NULL; - yyvs = yyvsp = NULL; - yystacksize = 0; - return (1); -yyaccept: - if (yyss) - free(yyss); - if (yyvs) - free(yyvs); - yyss = yyssp = NULL; - yyvs = yyvsp = NULL; - yystacksize = 0; - return (0); -} diff --git a/third_party/lex/parse.h b/third_party/lex/parse.h deleted file mode 100644 index 7be05c73..00000000 --- a/third_party/lex/parse.h +++ /dev/null @@ -1,45 +0,0 @@ -#define CHAR 257 -#define NUMBER 258 -#define SECTEND 259 -#define SCDECL 260 -#define XSCDECL 261 -#define NAME 262 -#define PREVCCL 263 -#define EOF_OP 264 -#define OPTION_OP 265 -#define OPT_OUTFILE 266 -#define OPT_PREFIX 267 -#define OPT_YYCLASS 268 -#define OPT_HEADER 269 -#define OPT_EXTRA_TYPE 270 -#define OPT_TABLES 271 -#define CCE_ALNUM 272 -#define CCE_ALPHA 273 -#define CCE_BLANK 274 -#define CCE_CNTRL 275 -#define CCE_DIGIT 276 -#define CCE_GRAPH 277 -#define CCE_LOWER 278 -#define CCE_PRINT 279 -#define CCE_PUNCT 280 -#define CCE_SPACE 281 -#define CCE_UPPER 282 -#define CCE_XDIGIT 283 -#define CCE_NEG_ALNUM 284 -#define CCE_NEG_ALPHA 285 -#define CCE_NEG_BLANK 286 -#define CCE_NEG_CNTRL 287 -#define CCE_NEG_DIGIT 288 -#define CCE_NEG_GRAPH 289 -#define CCE_NEG_LOWER 290 -#define CCE_NEG_PRINT 291 -#define CCE_NEG_PUNCT 292 -#define CCE_NEG_SPACE 293 -#define CCE_NEG_UPPER 294 -#define CCE_NEG_XDIGIT 295 -#define CCL_OP_DIFF 296 -#define CCL_OP_UNION 297 -#define BEGIN_REPEAT_POSIX 298 -#define END_REPEAT_POSIX 299 -#define BEGIN_REPEAT_FLEX 300 -#define END_REPEAT_FLEX 301 diff --git a/third_party/lex/parse.y b/third_party/lex/parse.y deleted file mode 100644 index 7ff2fd3c..00000000 --- a/third_party/lex/parse.y +++ /dev/null @@ -1,1089 +0,0 @@ -/* $OpenBSD: parse.y,v 1.10 2017/04/12 14:53:27 millert Exp $ */ - -/* parse.y - parser for flex input */ - -%token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP -%token OPTION_OP OPT_OUTFILE OPT_PREFIX OPT_YYCLASS OPT_HEADER OPT_EXTRA_TYPE -%token OPT_TABLES - -%token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH -%token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT - -%token CCE_NEG_ALNUM CCE_NEG_ALPHA CCE_NEG_BLANK CCE_NEG_CNTRL CCE_NEG_DIGIT CCE_NEG_GRAPH -%token CCE_NEG_LOWER CCE_NEG_PRINT CCE_NEG_PUNCT CCE_NEG_SPACE CCE_NEG_UPPER CCE_NEG_XDIGIT - -%left CCL_OP_DIFF CCL_OP_UNION - -/* - *POSIX and AT&T lex place the - * precedence of the repeat operator, {}, below that of concatenation. - * Thus, ab{3} is ababab. Most other POSIX utilities use an Extended - * Regular Expression (ERE) precedence that has the repeat operator - * higher than concatenation. This causes ab{3} to yield abbb. - * - * In order to support the POSIX and AT&T precedence and the flex - * precedence we define two token sets for the begin and end tokens of - * the repeat operator, '{' and '}'. The lexical scanner chooses - * which tokens to return based on whether posix_compat or lex_compat - * are specified. Specifying either posix_compat or lex_compat will - * cause flex to parse scanner files as per the AT&T and - * POSIX-mandated behavior. - */ - -%token BEGIN_REPEAT_POSIX END_REPEAT_POSIX BEGIN_REPEAT_FLEX END_REPEAT_FLEX - - -%{ -/* 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. */ - -#include "third_party/lex/flexdef.h" -#include "libc/fmt/fmt.h" -#include "third_party/lex/tables.h" - -int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen; -int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule; - -int *scon_stk; -int scon_stk_ptr; - -static int madeany = false; /* whether we've made the '.' character class */ -static int ccldot, cclany; -int previous_continued_action; /* whether the previous rule's action was '|' */ - -#define format_warn3(fmt, a1, a2) \ - do{ \ - char fw3_msg[MAXLINE];\ - snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\ - lexwarn( fw3_msg );\ - }while(0) - -/* Expand a POSIX character class expression. */ -#define CCL_EXPR(func) \ - do{ \ - int c; \ - for ( c = 0; c < csize; ++c ) \ - if ( isascii(c) && func(c) ) \ - ccladd( currccl, c ); \ - }while(0) - -/* negated class */ -#define CCL_NEG_EXPR(func) \ - do{ \ - int c; \ - for ( c = 0; c < csize; ++c ) \ - if ( !func(c) ) \ - ccladd( currccl, c ); \ - }while(0) - -/* On some over-ambitious machines, such as DEC Alpha's, the default - * token type is "long" instead of "int"; this leads to problems with - * declaring yylval in flexdef.h. But so far, all the yacc's I've seen - * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the - * following should ensure that the default token type is "int". - */ -#define YYSTYPE int - -%} - -%% -goal : initlex sect1 sect1end sect2 initforrule - { /* add default rule */ - int def_rule; - - pat = cclinit(); - cclnegate( pat ); - - def_rule = mkstate( -pat ); - - /* Remember the number of the default rule so we - * don't generate "can't match" warnings for it. - */ - default_rule = num_rules; - - finish_rule( def_rule, false, 0, 0, 0); - - for ( i = 1; i <= lastsc; ++i ) - scset[i] = mkbranch( scset[i], def_rule ); - - if ( spprdflt ) - add_action( - "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); - else - add_action( "ECHO" ); - - add_action( ";\n\tYY_BREAK\n" ); - } - ; - -initlex : - { /* initialize for processing rules */ - - /* Create default DFA start condition. */ - scinstal( "INITIAL", false ); - } - ; - -sect1 : sect1 startconddecl namelist1 - | sect1 options - | - | error - { synerr( _("unknown error processing section 1") ); } - ; - -sect1end : SECTEND - { - check_options(); - scon_stk = allocate_integer_array( lastsc + 1 ); - scon_stk_ptr = 0; - } - ; - -startconddecl : SCDECL - { xcluflg = false; } - - | XSCDECL - { xcluflg = true; } - ; - -namelist1 : namelist1 NAME - { scinstal( nmstr, xcluflg ); } - - | NAME - { scinstal( nmstr, xcluflg ); } - - | error - { synerr( _("bad start condition list") ); } - ; - -options : OPTION_OP optionlist - ; - -optionlist : optionlist option - | - ; - -option : OPT_OUTFILE '=' NAME - { - outfilename = copy_string( nmstr ); - did_outfilename = 1; - } - | OPT_EXTRA_TYPE '=' NAME - { extra_type = copy_string( nmstr ); } - | OPT_PREFIX '=' NAME - { prefix = copy_string( nmstr ); } - | OPT_YYCLASS '=' NAME - { yyclass = copy_string( nmstr ); } - | OPT_HEADER '=' NAME - { headerfilename = copy_string( nmstr ); } - | OPT_TABLES '=' NAME - { tablesext = true; tablesfilename = copy_string( nmstr ); } - ; - -sect2 : sect2 scon initforrule flexrule '\n' - { scon_stk_ptr = $2; } - | sect2 scon '{' sect2 '}' - { scon_stk_ptr = $2; } - | - ; - -initforrule : - { - /* Initialize for a parse of one rule. */ - trlcontxt = variable_trail_rule = varlength = false; - trailcnt = headcnt = rulelen = 0; - current_state_type = STATE_NORMAL; - previous_continued_action = continued_action; - in_rule = true; - - new_rule(); - } - ; - -flexrule : '^' rule - { - pat = $2; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt , previous_continued_action); - - if ( scon_stk_ptr > 0 ) - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - scbol[scon_stk[i]] = - mkbranch( scbol[scon_stk[i]], - pat ); - } - - else - { - /* Add to all non-exclusive start conditions, - * including the default (0) start condition. - */ - - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scbol[i] = mkbranch( scbol[i], - pat ); - } - - if ( ! bol_needed ) - { - bol_needed = true; - - if ( performance_report > 1 ) - pinpoint_message( - "'^' operator results in sub-optimal performance" ); - } - } - - | rule - { - pat = $1; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt , previous_continued_action); - - if ( scon_stk_ptr > 0 ) - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - scset[scon_stk[i]] = - mkbranch( scset[scon_stk[i]], - pat ); - } - - else - { - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scset[i] = - mkbranch( scset[i], - pat ); - } - } - - | EOF_OP - { - if ( scon_stk_ptr > 0 ) - build_eof_action(); - - else - { - /* This EOF applies to all start conditions - * which don't already have EOF actions. - */ - for ( i = 1; i <= lastsc; ++i ) - if ( ! sceof[i] ) - scon_stk[++scon_stk_ptr] = i; - - if ( scon_stk_ptr == 0 ) - lexwarn( - "all start conditions already have <> rules" ); - - else - build_eof_action(); - } - } - - | error - { synerr( _("unrecognized rule") ); } - ; - -scon_stk_ptr : - { $$ = scon_stk_ptr; } - ; - -scon : '<' scon_stk_ptr namelist2 '>' - { $$ = $2; } - - | '<' '*' '>' - { - $$ = scon_stk_ptr; - - for ( i = 1; i <= lastsc; ++i ) - { - int j; - - for ( j = 1; j <= scon_stk_ptr; ++j ) - if ( scon_stk[j] == i ) - break; - - if ( j > scon_stk_ptr ) - scon_stk[++scon_stk_ptr] = i; - } - } - - | - { $$ = scon_stk_ptr; } - ; - -namelist2 : namelist2 ',' sconname - - | sconname - - | error - { synerr( _("bad start condition list") ); } - ; - -sconname : NAME - { - if ( (scnum = sclookup( nmstr )) == 0 ) - format_pinpoint_message( - "undeclared start condition %s", - nmstr ); - else - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - if ( scon_stk[i] == scnum ) - { - format_warn( - "<%s> specified twice", - scname[scnum] ); - break; - } - - if ( i > scon_stk_ptr ) - scon_stk[++scon_stk_ptr] = scnum; - } - } - ; - -rule : re2 re - { - if ( transchar[lastst[$2]] != SYM_EPSILON ) - /* Provide final transition \now/ so it - * will be marked as a trailing context - * state. - */ - $2 = link_machines( $2, - mkstate( SYM_EPSILON ) ); - - mark_beginning_as_normal( $2 ); - current_state_type = STATE_NORMAL; - - if ( previous_continued_action ) - { - /* We need to treat this as variable trailing - * context so that the backup does not happen - * in the action but before the action switch - * statement. If the backup happens in the - * action, then the rules "falling into" this - * one's action will *also* do the backup, - * erroneously. - */ - if ( ! varlength || headcnt != 0 ) - lexwarn( - "trailing context made variable due to preceding '|' action" ); - - /* Mark as variable. */ - varlength = true; - headcnt = 0; - - } - - if ( lex_compat || (varlength && headcnt == 0) ) - { /* variable trailing context rule */ - /* Mark the first part of the rule as the - * accepting "head" part of a trailing - * context rule. - * - * By the way, we didn't do this at the - * beginning of this production because back - * then current_state_type was set up for a - * trail rule, and add_accept() can create - * a new state ... - */ - add_accept( $1, - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - else - trailcnt = rulelen; - - $$ = link_machines( $1, $2 ); - } - - | re2 re '$' - { synerr( _("trailing context used twice") ); } - - | re '$' - { - headcnt = 0; - trailcnt = 1; - rulelen = 1; - varlength = false; - - current_state_type = STATE_TRAILING_CONTEXT; - - if ( trlcontxt ) - { - synerr( _("trailing context used twice") ); - $$ = mkstate( SYM_EPSILON ); - } - - else if ( previous_continued_action ) - { - /* See the comment in the rule for "re2 re" - * above. - */ - lexwarn( - "trailing context made variable due to preceding '|' action" ); - - varlength = true; - } - - if ( lex_compat || varlength ) - { - /* Again, see the comment in the rule for - * "re2 re" above. - */ - add_accept( $1, - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - trlcontxt = true; - - eps = mkstate( SYM_EPSILON ); - $$ = link_machines( $1, - link_machines( eps, mkstate( '\n' ) ) ); - } - - | re - { - $$ = $1; - - if ( trlcontxt ) - { - if ( lex_compat || (varlength && headcnt == 0) ) - /* Both head and trail are - * variable-length. - */ - variable_trail_rule = true; - else - trailcnt = rulelen; - } - } - ; - - -re : re '|' series - { - varlength = true; - $$ = mkor( $1, $3 ); - } - - | series - { $$ = $1; } - ; - - -re2 : re '/' - { - /* This rule is written separately so the - * reduction will occur before the trailing - * series is parsed. - */ - - if ( trlcontxt ) - synerr( _("trailing context used twice") ); - else - trlcontxt = true; - - if ( varlength ) - /* We hope the trailing context is - * fixed-length. - */ - varlength = false; - else - headcnt = rulelen; - - rulelen = 0; - - current_state_type = STATE_TRAILING_CONTEXT; - $$ = $1; - } - ; - -series : series singleton - { - /* This is where concatenation of adjacent patterns - * gets done. - */ - $$ = link_machines( $1, $2 ); - } - - | singleton - { $$ = $1; } - - | series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX - { - varlength = true; - - if ( $3 > $5 || $3 < 0 ) - { - synerr( _("bad iteration values") ); - $$ = $1; - } - else - { - if ( $3 == 0 ) - { - if ( $5 <= 0 ) - { - synerr( - _("bad iteration values") ); - $$ = $1; - } - else - $$ = mkopt( - mkrep( $1, 1, $5 ) ); - } - else - $$ = mkrep( $1, $3, $5 ); - } - } - - | series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX - { - varlength = true; - - if ( $3 <= 0 ) - { - synerr( _("iteration value must be positive") ); - $$ = $1; - } - - else - $$ = mkrep( $1, $3, INFINITE_REPEAT ); - } - - | series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX - { - /* The series could be something like "(foo)", - * in which case we have no idea what its length - * is, so we punt here. - */ - varlength = true; - - if ( $3 <= 0 ) - { - synerr( _("iteration value must be positive") - ); - $$ = $1; - } - - else - $$ = link_machines( $1, - copysingl( $1, $3 - 1 ) ); - } - - ; - -singleton : singleton '*' - { - varlength = true; - - $$ = mkclos( $1 ); - } - - | singleton '+' - { - varlength = true; - $$ = mkposcl( $1 ); - } - - | singleton '?' - { - varlength = true; - $$ = mkopt( $1 ); - } - - | singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX - { - varlength = true; - - if ( $3 > $5 || $3 < 0 ) - { - synerr( _("bad iteration values") ); - $$ = $1; - } - else - { - if ( $3 == 0 ) - { - if ( $5 <= 0 ) - { - synerr( - _("bad iteration values") ); - $$ = $1; - } - else - $$ = mkopt( - mkrep( $1, 1, $5 ) ); - } - else - $$ = mkrep( $1, $3, $5 ); - } - } - - | singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX - { - varlength = true; - - if ( $3 <= 0 ) - { - synerr( _("iteration value must be positive") ); - $$ = $1; - } - - else - $$ = mkrep( $1, $3, INFINITE_REPEAT ); - } - - | singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX - { - /* The singleton could be something like "(foo)", - * in which case we have no idea what its length - * is, so we punt here. - */ - varlength = true; - - if ( $3 <= 0 ) - { - synerr( _("iteration value must be positive") ); - $$ = $1; - } - - else - $$ = link_machines( $1, - copysingl( $1, $3 - 1 ) ); - } - - | '.' - { - if ( ! madeany ) - { - /* Create the '.' character class. */ - ccldot = cclinit(); - ccladd( ccldot, '\n' ); - cclnegate( ccldot ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[ccldot], - ccllen[ccldot], nextecm, - ecgroup, csize, csize ); - - /* Create the (?s:'.') character class. */ - cclany = cclinit(); - cclnegate( cclany ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[cclany], - ccllen[cclany], nextecm, - ecgroup, csize, csize ); - - madeany = true; - } - - ++rulelen; - - if (sf_dot_all()) - $$ = mkstate( -cclany ); - else - $$ = mkstate( -ccldot ); - } - - | fullccl - { - /* Sort characters for fast searching. - */ - qsort( ccltbl + cclmap[$1], ccllen[$1], sizeof (*ccltbl), cclcmp ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[$1], ccllen[$1], - nextecm, ecgroup, csize, csize ); - - ++rulelen; - - if (ccl_has_nl[$1]) - rule_has_nl[num_rules] = true; - - $$ = mkstate( -$1 ); - } - - | PREVCCL - { - ++rulelen; - - if (ccl_has_nl[$1]) - rule_has_nl[num_rules] = true; - - $$ = mkstate( -$1 ); - } - - | '"' string '"' - { $$ = $2; } - - | '(' re ')' - { $$ = $2; } - - | CHAR - { - ++rulelen; - - if ($1 == nlch) - rule_has_nl[num_rules] = true; - - if (sf_case_ins() && has_case($1)) - /* create an alternation, as in (a|A) */ - $$ = mkor (mkstate($1), mkstate(reverse_case($1))); - else - $$ = mkstate( $1 ); - } - ; -fullccl: - fullccl CCL_OP_DIFF braceccl { $$ = ccl_set_diff ($1, $3); } - | fullccl CCL_OP_UNION braceccl { $$ = ccl_set_union ($1, $3); } - | braceccl - ; - -braceccl: - - '[' ccl ']' { $$ = $2; } - - | '[' '^' ccl ']' - { - cclnegate( $3 ); - $$ = $3; - } - ; - -ccl : ccl CHAR '-' CHAR - { - - if (sf_case_ins()) - { - - /* If one end of the range has case and the other - * does not, or the cases are different, then we're not - * sure what range the user is trying to express. - * Examples: [@-z] or [S-t] - */ - if (has_case ($2) != has_case ($4) - || (has_case ($2) && (b_islower ($2) != b_islower ($4))) - || (has_case ($2) && (b_isupper ($2) != b_isupper ($4)))) - format_warn3 ( - _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"), - $2, $4); - - /* If the range spans uppercase characters but not - * lowercase (or vice-versa), then should we automatically - * include lowercase characters in the range? - * Example: [@-_] spans [a-z] but not [A-Z] - */ - else if (!has_case ($2) && !has_case ($4) && !range_covers_case ($2, $4)) - format_warn3 ( - _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"), - $2, $4); - } - - if ( $2 > $4 ) - synerr( _("negative range in character class") ); - - else - { - for ( i = $2; i <= $4; ++i ) - ccladd( $1, i ); - - /* Keep track if this ccl is staying in - * alphabetical order. - */ - cclsorted = cclsorted && ($2 > lastchar); - lastchar = $4; - - /* Do it again for upper/lowercase */ - if (sf_case_ins() && has_case($2) && has_case($4)){ - $2 = reverse_case ($2); - $4 = reverse_case ($4); - - for ( i = $2; i <= $4; ++i ) - ccladd( $1, i ); - - cclsorted = cclsorted && ($2 > lastchar); - lastchar = $4; - } - - } - - $$ = $1; - } - - | ccl CHAR - { - ccladd( $1, $2 ); - cclsorted = cclsorted && ($2 > lastchar); - lastchar = $2; - - /* Do it again for upper/lowercase */ - if (sf_case_ins() && has_case($2)){ - $2 = reverse_case ($2); - ccladd ($1, $2); - - cclsorted = cclsorted && ($2 > lastchar); - lastchar = $2; - } - - $$ = $1; - } - - | ccl ccl_expr - { - /* Too hard to properly maintain cclsorted. */ - cclsorted = false; - $$ = $1; - } - - | - { - cclsorted = true; - lastchar = 0; - currccl = $$ = cclinit(); - } - ; - -ccl_expr: - CCE_ALNUM { CCL_EXPR(isalnum); } - | CCE_ALPHA { CCL_EXPR(isalpha); } - | CCE_BLANK { CCL_EXPR(isblank); } - | CCE_CNTRL { CCL_EXPR(iscntrl); } - | CCE_DIGIT { CCL_EXPR(isdigit); } - | CCE_GRAPH { CCL_EXPR(isgraph); } - | CCE_LOWER { - CCL_EXPR(islower); - if (sf_case_ins()) - CCL_EXPR(isupper); - } - | CCE_PRINT { CCL_EXPR(isprint); } - | CCE_PUNCT { CCL_EXPR(ispunct); } - | CCE_SPACE { CCL_EXPR(isspace); } - | CCE_XDIGIT { CCL_EXPR(isxdigit); } - | CCE_UPPER { - CCL_EXPR(isupper); - if (sf_case_ins()) - CCL_EXPR(islower); - } - - | CCE_NEG_ALNUM { CCL_NEG_EXPR(isalnum); } - | CCE_NEG_ALPHA { CCL_NEG_EXPR(isalpha); } - | CCE_NEG_BLANK { CCL_NEG_EXPR(isblank); } - | CCE_NEG_CNTRL { CCL_NEG_EXPR(iscntrl); } - | CCE_NEG_DIGIT { CCL_NEG_EXPR(isdigit); } - | CCE_NEG_GRAPH { CCL_NEG_EXPR(isgraph); } - | CCE_NEG_PRINT { CCL_NEG_EXPR(isprint); } - | CCE_NEG_PUNCT { CCL_NEG_EXPR(ispunct); } - | CCE_NEG_SPACE { CCL_NEG_EXPR(isspace); } - | CCE_NEG_XDIGIT { CCL_NEG_EXPR(isxdigit); } - | CCE_NEG_LOWER { - if ( sf_case_ins() ) - lexwarn(_("[:^lower:] is ambiguous in case insensitive scanner")); - else - CCL_NEG_EXPR(islower); - } - | CCE_NEG_UPPER { - if ( sf_case_ins() ) - lexwarn(_("[:^upper:] ambiguous in case insensitive scanner")); - else - CCL_NEG_EXPR(isupper); - } - ; - -string : string CHAR - { - if ( $2 == nlch ) - rule_has_nl[num_rules] = true; - - ++rulelen; - - if (sf_case_ins() && has_case($2)) - $$ = mkor (mkstate($2), mkstate(reverse_case($2))); - else - $$ = mkstate ($2); - - $$ = link_machines( $1, $$); - } - - | - { $$ = mkstate( SYM_EPSILON ); } - ; - -%% - - -/* build_eof_action - build the "<>" action for the active start - * conditions - */ - -void build_eof_action() - { - int i2; - char action_text[MAXLINE]; - - for ( i2 = 1; i2 <= scon_stk_ptr; ++i2 ) - { - if ( sceof[scon_stk[i2]] ) - format_pinpoint_message( - "multiple <> rules for start condition %s", - scname[scon_stk[i2]] ); - - else - { - sceof[scon_stk[i2]] = true; - - if (previous_continued_action /* && previous action was regular */) - add_action("YY_RULE_SETUP\n"); - - snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n", - scname[scon_stk[i2]] ); - add_action( action_text ); - } - } - - line_directive_out( (FILE *) 0, 1 ); - - /* This isn't a normal rule after all - don't count it as - * such, so we don't have any holes in the rule numbering - * (which make generating "rule can never match" warnings - * more difficult. - */ - --num_rules; - ++num_eof_rules; - } - - -/* format_synerr - write out formatted syntax error */ - -void format_synerr( msg, arg ) -const char *msg, arg[]; - { - char errmsg[MAXLINE]; - - (void) snprintf( errmsg, sizeof(errmsg), msg, arg ); - synerr( errmsg ); - } - - -/* synerr - report a syntax error */ - -void synerr( str ) -const char *str; - { - syntaxerror = true; - pinpoint_message( str ); - } - - -/* format_warn - write out formatted warning */ - -void format_warn( msg, arg ) -const char *msg, arg[]; - { - char warn_msg[MAXLINE]; - - snprintf( warn_msg, sizeof(warn_msg), msg, arg ); - lexwarn( warn_msg ); - } - - -/* warn - report a warning, unless -w was given */ - -void lexwarn( str ) -const char *str; - { - line_warning( str, linenum ); - } - -/* format_pinpoint_message - write out a message formatted with one string, - * pinpointing its location - */ - -void format_pinpoint_message( msg, arg ) -const char *msg, arg[]; - { - char errmsg[MAXLINE]; - - snprintf( errmsg, sizeof(errmsg), msg, arg ); - pinpoint_message( errmsg ); - } - - -/* pinpoint_message - write out a message, pinpointing its location */ - -void pinpoint_message( str ) -const char *str; - { - line_pinpoint( str, linenum ); - } - - -/* line_warning - report a warning at a given line, unless -w was given */ - -void line_warning( str, line ) -const char *str; -int line; - { - char warning[MAXLINE]; - - if ( ! nowarn ) - { - snprintf( warning, sizeof(warning), "warning, %s", str ); - line_pinpoint( warning, line ); - } - } - - -/* line_pinpoint - write out a message, pinpointing it at the given line */ - -void line_pinpoint( str, line ) -const char *str; -int line; - { - fprintf( stderr, "%s:%d: %s\n", infilename, line, str ); - } - - -/* yyerror - eat up an error message from the parser; - * currently, messages are ignore - */ - -void yyerror( msg ) -const char *msg; - { - } diff --git a/third_party/lex/regex.c b/third_party/lex/regex.c deleted file mode 100644 index 018f482c..00000000 --- a/third_party/lex/regex.c +++ /dev/null @@ -1,181 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ - -/* clang-format off */ -/* $OpenBSD: regex.c,v 1.3 2015/11/19 23:20:34 tedu Exp $ */ - -/** regex - regular expression functions related to POSIX regex lib. */ - -/* 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. */ - -#include "libc/str/str.h" -#include "libc/mem/mem.h" -#include "libc/fmt/fmt.h" -#include "libc/fmt/conv.h" -#include "flexdef.h" - - -static const char* REGEXP_LINEDIR = "^#line ([[:digit:]]+) \"(.*)\""; -static const char* REGEXP_BLANK_LINE = "^[[:space:]]*$"; - -regex_t regex_linedir; /**< matches line directives */ -regex_t regex_blank_line; /**< matches blank lines */ - - -/** Initialize the regular expressions. - * @return true upon success. - */ -bool flex_init_regex(void) -{ - flex_regcomp(®ex_linedir, REGEXP_LINEDIR, REG_EXTENDED); - flex_regcomp(®ex_blank_line, REGEXP_BLANK_LINE, REG_EXTENDED); - - return true; -} - -/** Compiles a regular expression or dies trying. - * @param preg Same as for regcomp(). - * @param regex Same as for regcomp(). - * @param cflags Same as for regcomp(). - */ -void flex_regcomp(regex_t *preg, const char *regex, int cflags) -{ - int err; - - memset (preg, 0, sizeof (regex_t)); - - if ((err = regcomp (preg, regex, cflags)) != 0) { - const int errbuf_sz = 200; - char *errbuf, *rxerr; - - errbuf = (char*)malloc(errbuf_sz *sizeof(char)); - if (!errbuf) - flexfatal(_("Unable to allocate buffer to report regcomp")); - rxerr = (char*)malloc(errbuf_sz *sizeof(char)); - if (!rxerr) - flexfatal(_("Unable to allocate buffer for regerror")); - regerror (err, preg, rxerr, errbuf_sz); - snprintf (errbuf, errbuf_sz, "regcomp for \"%s\" failed: %s", regex, rxerr); - - flexfatal (errbuf); - free(errbuf); - free(rxerr); - } -} - -/** Extract a copy of the match, or NULL if no match. - * @param m A match as returned by regexec(). - * @param src The source string that was passed to regexec(). - * @return The allocated string. - */ -char *regmatch_dup (regmatch_t * m, const char *src) -{ - char *str; - int len; - - if (m == NULL || m->rm_so < 0) - return NULL; - len = m->rm_eo - m->rm_so; - str = (char *) malloc ((len + 1) * sizeof (char)); - if (!str) - flexfatal(_("Unable to allocate a copy of the match")); - strncpy (str, src + m->rm_so, len); - str[len] = 0; - return str; -} - -/** Copy the match. - * @param m A match as returned by regexec(). - * @param dest The destination buffer. - * @param src The source string that was passed to regexec(). - * @return dest - */ -char *regmatch_cpy (regmatch_t * m, char *dest, const char *src) -{ - if (m == NULL || m->rm_so < 0) { - if (dest) - dest[0] = '\0'; - return dest; - } - - snprintf (dest, regmatch_len(m), "%s", src + m->rm_so); - return dest; -} - -/** Get the length in characters of the match. - * @param m A match as returned by regexec(). - * @param src The source string that was passed to regexec(). - * @return The length of the match. - */ -int regmatch_len (regmatch_t * m) -{ - if (m == NULL || m->rm_so < 0) { - return 0; - } - - return m->rm_eo - m->rm_so; -} - - - -/** Convert a regmatch_t object to an integer using the strtol() function. - * @param m A match as returned by regexec(). - * @param src The source string that was passed to regexec(). - * @param endptr Same as the second argument to strtol(). - * @param base Same as the third argument to strtol(). - * @return The converted integer or error (Return value is the same as for strtol()). - */ -int regmatch_strtol (regmatch_t * m, const char *src, char **endptr, - int base2) -{ - int n = 0; - -#define bufsz 20 - char buf[bufsz]; - char *s; - - if (m == NULL || m->rm_so < 0) - return 0; - - if (regmatch_len (m) < bufsz) - s = regmatch_cpy (m, buf, src); - else - s = regmatch_dup (m, src); - - n = strtol (s, endptr, base2); - - if (s != buf) - free (s); - - return n; -} - -/** Check for empty or non-existent match. - * @param m A match as returned by regexec(). - * @return false if match length is non-zero. - * Note that reg_empty returns true even if match did not occur at all. - */ -bool regmatch_empty (regmatch_t * m) -{ - return (m == NULL || m->rm_so < 0 || m->rm_so == m->rm_eo); -} diff --git a/third_party/lex/scan.c b/third_party/lex/scan.c deleted file mode 100644 index 3064cf93..00000000 --- a/third_party/lex/scan.c +++ /dev/null @@ -1,4588 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ -│vi: set et ft=c ts=8 sw=8 fenc=utf-8 :vi│ -└─────────────────────────────────────────────────────────────────────────────*/ -/* clang-format off */ - -#define YY_INT_ALIGNED short int - -/* $OpenBSD: flex.skl,v 1.16 2017/05/02 19:16:19 millert Exp $ */ - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 39 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -#include "libc/limits.h" -#include "libc/sysv/consts/exit.h" -#include "libc/errno.h" -#include "libc/stdio/stdio.h" - -/* $OpenBSD: flexint.h,v 1.1 2015/11/19 19:43:40 tedu Exp $ */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767 - 1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647 - 1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined(__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int)(unsigned char)c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start)-1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the - * main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -#define YY_LESS_LINENO(n) -#define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET(yy_c_buf_p) = yy_cp = \ - yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } while (0) - -#define unput(c) yyunput(c, (yytext_ptr)) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 -}; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE *yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER \ - ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *)0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart(FILE *input_file); -void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer); -YY_BUFFER_STATE yy_create_buffer(FILE *file, int size); -void yy_delete_buffer(YY_BUFFER_STATE b); -void yy_flush_buffer(YY_BUFFER_STATE b); -void yypush_buffer_state(YY_BUFFER_STATE new_buffer); -void yypop_buffer_state(void); - -static void yyensure_buffer_stack(void); -static void yy_load_buffer_state(void); -static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER) - -YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size); -YY_BUFFER_STATE yy_scan_string(yyconst char *yy_str); -YY_BUFFER_STATE yy_scan_bytes(yyconst char *bytes, yy_size_t len); - -void *yyalloc(yy_size_t); -void *yyrealloc(void *, yy_size_t); -void yyfree(void *); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if (!YY_CURRENT_BUFFER) { \ - yyensure_buffer_stack(); \ - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if (!YY_CURRENT_BUFFER) { \ - yyensure_buffer_stack(); \ - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *)0, *yyout = (FILE *)0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state(void); -static yy_state_type yy_try_NUL_trans(yy_state_type current_state); -static int yy_get_next_buffer(void); -static void yy_fatal_error(yyconst char msg[]); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - (yytext_ptr) -= (yy_more_len); \ - yyleng = (size_t)(yy_cp - (yytext_ptr)); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 251 -#define YY_END_OF_BUFFER 252 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; -}; -static yyconst flex_int16_t yy_acclist[1223] = { - 0, 248, 248, 252, 250, 251, 9, 250, 251, 20, 250, 251, 250, 251, 18, - 250, 251, 1, 9, 250, 251, 19, 20, 250, 251, 250, 251, 250, 251, 250, - 251, 250, 251, 17, 18, 250, 251, 164, 250, 251, 149, 164, 250, 251, 150, - 250, 251, 164, 250, 251, 142, 164, 250, 251, 164, 250, 251, 161, 163, 164, - 250, 251, 162, 163, 164, 250, 251, 163, 164, 250, 251, 163, 164, 250, 251, - 164, 250, 251, 164, 250, 251, 164, 250, 251, 163, 164, 250, 251, 148, 149, - 164, 250, 251, 138, 150, 250, 251, 164, 250, 251, 164, - - 250, 251, 140, 164, 250, 251, 141, 164, 250, 251, 136, 250, 251, 137, 250, - 251, 136, 250, 251, 135, 136, 250, 251, 134, 136, 250, 251, 135, 136, 250, - 251, 248, 249, 250, 251, 248, 249, 250, 251, 249, 250, 251, 249, 250, 251, - 41, 250, 251, 42, 250, 251, 41, 250, 251, 41, 250, 251, 41, 250, 251, - 41, 250, 251, 41, 250, 251, 41, 250, 251, 50, 250, 251, 49, 250, 251, - 51, 250, 251, 250, 251, 170, 250, 251, 170, 250, 251, 165, 250, 251, 170, - 250, 251, 166, 170, 250, 251, 167, 170, 250, 251, - - 169, 170, 250, 251, 171, 250, 251, 219, 250, 251, 220, 250, 251, 219, 250, - 251, 217, 219, 250, 251, 216, 219, 250, 251, 218, 219, 250, 251, 172, 250, - 251, 174, 250, 251, 172, 250, 251, 173, 250, 251, 172, 250, 251, 186, 250, - 251, 186, 250, 251, 186, 250, 251, 186, 250, 251, 188, 190, 250, 251, 190, - 250, 251, 188, 190, 250, 251, 188, 190, 250, 251, 188, 190, 250, 251, 188, - 190, 250, 251, 189, 190, 250, 251, 233, 239, 250, 251, 238, 250, 251, 233, - 239, 250, 251, 237, 239, 250, 251, 239, 250, 251, - - 239, 250, 251, 235, 239, 250, 251, 235, 239, 250, 251, 235, 239, 250, 251, - 234, 239, 250, 251, 234, 239, 250, 251, 229, 239, 250, 251, 230, 239, 250, - 251, 250, 251, 131, 250, 251, 250, 251, 25, 250, 251, 26, 250, 251, 25, - 250, 251, 22, 250, 251, 25, 250, 251, 25, 250, 251, 240, 244, 250, 251, - 242, 250, 251, 240, 244, 250, 251, 243, 244, 250, 251, 244, 250, 251, 227, - 250, 251, 227, 250, 251, 228, 250, 251, 227, 250, 251, 227, 250, 251, 227, - 250, 251, 227, 250, 251, 227, 250, 251, 227, 250, - - 251, 227, 250, 251, 130, 250, 251, 53, 130, 250, 251, 52, 250, 251, 130, - 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, 54, 130, 250, 251, - 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, - 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, - 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, - 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, 130, 250, 251, - 130, 250, 251, 37, 250, 251, 34, 250, 251, 37, - - 250, 251, 35, 37, 250, 251, 48, 250, 251, 45, 250, 251, 250, 251, 48, - 250, 251, 48, 250, 251, 44, 250, 251, 43, 250, 251, 176, 250, 251, 175, - 250, 251, 177, 250, 251, 178, 250, 251, 179, 250, 251, 180, 250, 251, 181, - 250, 251, 182, 250, 251, 183, 250, 251, 32, 250, 251, 33, 250, 251, 32, - 250, 251, 31, 250, 251, 29, 250, 251, 30, 250, 251, 29, 250, 251, 28, - 250, 251, 9, 20, 18, 1, 9, 19, 20, 16, 10, 16, 4, 16, 5, - 2, 17, 18, 149, 150, 144, 160, 158, 154, 154, - - 245, 245, 245, 143, 148, 149, 138, 150, 140, 141, 153, 139, 137, 135, 134, - 134, 132, 135, 133, 135, 248, 248, 246, 247, 42, 39, 40, 50, 49, 51, - 165, 165, 168, 169, 220, 216, 174, 184, 185, 190, 187, 233, 238, 236, 222, - 235, 235, 235, 231, 232, 131, 26, 21, 23, 24, 240, 242, 241, 228, 221, - 225, 226, 53, 52, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 55, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 36, 35, 45, - - 46, 47, 32, 33, 30, 27, 16, 10, 16, 14, 4, 16, 5, 6, 145, - 146, 159, 154, 154, 154, 154, 154, 245, 245, 156, 155, 157, 139, 145, 147, - 153, 132, 135, 133, 135, 38, 235, 235, 221, 130, 130, 130, 130, 130, 130, - 130, 67, 130, 130, 130, 130, 72, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 14, 15, 4, - 8, 16, 5, 154, 154, 154, 154, 154, 154, 154, - - 245, 157, 235, 235, 56, 57, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 73, 130, 74, 130, 130, 130, 130, 130, 79, 130, 130, 130, 130, - 130, 130, 130, 130, 84, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 93, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 15, 8, 16, 8, - 16, 8, 16, 154, 154, 154, 154, 154, 154, 154, 215, 235, 235, 58, 130, - 130, 130, 60, 130, 130, 64, 130, 130, 130, 130, 130, 70, 130, 130, 130, - 130, 75, 130, 130, 130, 130, 130, 130, 130, 130, - - 130, 130, 130, 130, 87, 130, 130, 130, 130, 130, 91, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 3, 8, 16, 7, 8, 16, 154, 154, - 154, 223, 224, 223, 235, 224, 235, 130, 130, 130, 63, 130, 130, 130, 130, - 130, 130, 130, 130, 126, 130, 130, 130, 130, 130, 130, 130, 130, 130, 124, - 130, 130, 86, 130, 130, 89, 130, 130, 90, 130, 130, 130, 130, 105, 130, - 130, 95, 130, 130, 96, 130, 12, 13, 152, 151, 152, 130, 130, 130, 130, - 130, 130, 130, 68, 130, 130, 71, 130, 130, 130, - - 130, 130, 130, 130, 123, 130, 130, 83, 130, 130, 130, 88, 130, 130, 92, - 130, 103, 130, 125, 130, 130, 130, 151, 130, 130, 130, 130, 130, 130, 130, - 69, 130, 130, 130, 130, 130, 80, 130, 130, 130, 130, 130, 130, 130, 114, - 94, 130, 130, 115, 11, 191, 215, 192, 215, 193, 215, 194, 215, 195, 215, - 196, 215, 197, 215, 198, 215, 199, 215, 200, 215, 201, 215, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 85, 130, 130, 130, - 116, 104, 130, 117, 202, 215, 203, 215, 204, 215, - - 205, 215, 206, 215, 207, 215, 208, 215, 209, 215, 210, 215, 211, 215, 212, - 215, 213, 215, 130, 130, 130, 130, 130, 130, 130, 122, 130, 130, 130, 77, - 130, 130, 130, 130, 130, 130, 110, 120, 118, 111, 121, 119, 214, 215, 130, - 130, 130, 130, 130, 130, 130, 126, 130, 76, 130, 130, 82, 130, 130, 127, - 130, 130, 106, 108, 107, 109, 130, 130, 130, 65, 130, 130, 130, 130, 130, - 78, 130, 130, 112, 113, 98, 99, 130, 130, 130, 130, 130, 130, 130, 128, - 130, 97, 101, 130, 130, 130, 130, 130, 68, 130, - - 130, 100, 102, 130, 130, 62, 130, 66, 130, 130, 130, 130, 61, 130, 69, - 130, 130, 130, 81, 130, 59, 130}; - -static yyconst flex_int16_t yy_accept[1108] = { - 0, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 4, 6, 9, 12, 14, 17, 21, 25, 27, 29, - 31, 33, 37, 40, 44, 47, 50, 54, 57, 62, 67, 71, - 75, 78, 81, 84, 88, 93, 97, 100, 103, 107, 111, 114, - 117, 120, 124, 128, 132, 136, 140, 143, 146, 149, 152, 155, - 158, 161, 164, 167, 170, - - 173, 176, 179, 181, 184, 187, 190, 193, 197, 201, 205, 208, - 211, 214, 217, 221, 225, 229, 232, 235, 238, 241, 244, 247, - 250, 253, 256, 260, 263, 267, 271, 275, 279, 283, 287, 290, - 294, 298, 301, 304, 308, 312, 316, 320, 324, 328, 332, 334, - 337, 339, 342, 345, 348, 351, 354, 357, 361, 364, 368, 372, - 375, 378, 381, 384, 387, 390, 393, 396, 399, 402, 405, 408, - 412, 415, 418, 421, 424, 427, 431, 434, 437, 440, 443, 446, - 449, 452, 455, 458, 461, 464, 467, 470, 473, 476, 479, 482, - 485, 488, 491, 494, - - 497, 500, 503, 507, 510, 513, 515, 518, 521, 524, 527, 530, - 533, 536, 539, 542, 545, 548, 551, 554, 557, 560, 563, 566, - 569, 572, 575, 578, 579, 580, 580, 581, 583, 585, 585, 585, - 585, 586, 588, 588, 588, 588, 588, 589, 590, 591, 591, 592, - 594, 595, 596, 596, 596, 596, 597, 597, 598, 599, 599, 600, - 601, 601, 602, 603, 604, 604, 604, 605, 605, 607, 609, 609, - 609, 609, 610, 611, 612, 613, 613, 614, 615, 616, 617, 619, - 621, 622, 623, 624, 625, 626, 626, 626, 627, 628, 628, 629, - 630, 631, 631, 632, - - 632, 633, 634, 635, 636, 637, 638, 638, 639, 640, 641, 642, - 643, 644, 644, 645, 645, 646, 647, 648, 649, 650, 651, 651, - 652, 652, 653, 654, 655, 656, 657, 658, 659, 659, 659, 660, - 661, 662, 663, 664, 665, 665, 666, 666, 666, 667, 668, 669, - 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, - 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, - 694, 695, 696, 697, 698, 698, 699, 700, 701, 702, 703, 704, - 705, 706, 707, 707, 708, 710, 710, 711, 711, 711, 711, 711, - 711, 712, 713, 714, - - 714, 715, 715, 716, 716, 717, 717, 718, 718, 719, 720, 720, - 721, 722, 723, 724, 725, 726, 727, 727, 728, 730, 731, 731, - 732, 732, 734, 736, 736, 736, 736, 737, 737, 737, 737, 737, - 737, 737, 737, 737, 737, 737, 737, 737, 737, 738, 739, 740, - 740, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, - 752, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, - 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, - 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, - 788, 788, 788, 788, - - 790, 790, 790, 790, 790, 790, 790, 791, 793, 794, 794, 795, - 796, 797, 798, 799, 800, 801, 802, 803, 803, 803, 803, 803, - 803, 803, 803, 803, 803, 803, 803, 803, 803, 803, 803, 803, - 803, 803, 803, 803, 803, 803, 803, 803, 803, 803, 804, 805, - 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, - 818, 820, 822, 823, 824, 825, 826, 828, 829, 830, 831, 832, - 833, 834, 835, 837, 838, 839, 840, 841, 842, 843, 844, 845, - 846, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 857, - 857, 857, 857, 858, - - 858, 858, 858, 858, 858, 860, 862, 864, 864, 865, 866, 867, - 868, 869, 870, 871, 871, 871, 871, 871, 872, 872, 872, 872, - 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, - 872, 872, 872, 872, 872, 872, 872, 872, 873, 874, 876, 877, - 878, 880, 881, 883, 884, 885, 886, 887, 889, 890, 891, 892, - 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, - 907, 908, 909, 910, 911, 913, 914, 915, 916, 917, 918, 919, - 920, 921, 922, 923, 923, 923, 923, 923, 924, 924, 924, 924, - 926, 927, 929, 929, - - 930, 931, 932, 932, 932, 933, 934, 934, 934, 934, 934, 934, - 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, - 934, 934, 934, 934, 934, 934, 934, 936, 938, 939, 940, 941, - 943, 944, 945, 946, 947, 948, 949, 950, 952, 953, 954, 955, - 956, 957, 958, 959, 960, 962, 963, 965, 966, 968, 969, 971, - 972, 973, 974, 976, 976, 977, 979, 980, 980, 982, 982, 982, - 982, 982, 982, 983, 983, 984, 984, 985, 985, 987, 987, 987, - 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, - 987, 987, 987, 987, - - 987, 987, 987, 987, 987, 987, 988, 989, 990, 991, 992, 993, - 994, 996, 997, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1007, 1008, - 1010, 1011, 1012, 1014, 1015, 1017, 1019, 1021, 1021, 1021, 1021, 1021, - 1021, 1021, 1022, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, - 1023, 1023, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, - 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, - 1024, 1024, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1033, 1034, - 1035, 1036, 1037, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1045, 1045, - 1046, 1046, 1046, 1046, - - 1046, 1046, 1046, 1048, 1049, 1049, 1049, 1050, 1050, 1050, 1050, 1050, - 1050, 1050, 1050, 1050, 1050, 1051, 1051, 1053, 1055, 1057, 1059, 1061, - 1063, 1065, 1067, 1069, 1071, 1073, 1073, 1073, 1073, 1073, 1073, 1073, - 1073, 1073, 1073, 1073, 1073, 1073, 1073, 1074, 1075, 1076, 1077, 1078, - 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1090, 1091, - 1091, 1091, 1091, 1091, 1091, 1091, 1092, 1092, 1094, 1094, 1094, 1094, - 1094, 1094, 1095, 1095, 1095, 1095, 1095, 1095, 1097, 1099, 1101, 1103, - 1105, 1107, 1109, 1111, 1113, 1115, 1117, 1119, 1119, 1120, 1121, 1122, - 1123, 1124, 1125, 1126, - - 1128, 1129, 1130, 1132, 1133, 1134, 1135, 1136, 1137, 1137, 1137, 1138, - 1138, 1139, 1140, 1141, 1141, 1141, 1141, 1142, 1143, 1143, 1143, 1143, - 1143, 1143, 1143, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1154, - 1156, 1157, 1159, 1160, 1162, 1163, 1164, 1165, 1165, 1166, 1167, 1167, - 1167, 1167, 1167, 1167, 1167, 1167, 1168, 1169, 1170, 1172, 1173, 1174, - 1175, 1176, 1178, 1179, 1180, 1181, 1182, 1182, 1182, 1182, 1182, 1183, - 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1192, 1193, 1193, 1194, 1194, - 1195, 1196, 1197, 1198, 1199, 1201, 1202, 1203, 1204, 1205, 1206, 1208, - 1210, 1211, 1212, 1213, - - 1215, 1217, 1218, 1219, 1221, 1223, 1223}; - -static yyconst flex_int32_t yy_ec[256] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 6, 7, 8, 9, - 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19, 19, 19, 19, 19, 20, 21, - 22, 23, 1, 24, 25, 26, 27, 1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 44, 53, 54, 55, 56, - 57, 1, 58, 59, 60, 61, - - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 44, 74, 75, 76, 77, 78, 79, - 80, 81, 44, 82, 83, 84, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - -static yyconst flex_int32_t yy_meta[85] = { - 0, 1, 1, 2, 1, 3, 4, 1, 1, 1, 5, 1, 6, 1, 7, 1, 8, - 1, 5, 9, 9, 9, 9, 10, 1, 1, 1, 1, 11, 11, 11, 11, 11, 11, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 13, 14, 15, 1, 16, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 5, 1, 17}; - -static yyconst flex_int16_t yy_base[1201] = { - 0, 0, 84, 167, 250, 171, 184, 174, 179, 192, 233, 196, - 200, 334, 0, 3343, 3340, 203, 416, 206, 211, 187, 216, 276, - 417, 500, 0, 210, 223, 421, 427, 436, 440, 583, 588, 669, - 0, 277, 299, 584, 751, 579, 580, 576, 732, 279, 305, 310, - 444, 3378, 3975, 228, 3975, 3371, 0, 322, 3975, 3358, 423, 827, - 3328, 0, 3975, 755, 3975, 3337, 3975, 448, 3312, 3975, 3975, 3323, - 3291, 222, 408, 444, 764, 3975, 3311, 230, 3289, 3975, 3975, 3975, - 3306, 0, 3306, 164, 3304, 3975, 3236, 3217, 3975, 3975, 3266, 239, - 119, 3215, 3212, 3180, 0, - - 3248, 3975, 3243, 3975, 476, 3227, 3222, 3975, 3168, 0, 3975, 3975, - 3975, 3203, 3975, 464, 3975, 3975, 3975, 3186, 3975, 742, 3975, 3161, - 751, 180, 3975, 3975, 3171, 0, 3149, 757, 3975, 0, 3975, 3149, - 3975, 200, 3138, 0, 429, 241, 3097, 3092, 3975, 3975, 306, 3975, - 323, 3975, 3975, 3126, 3108, 3072, 3069, 0, 3975, 3115, 3975, 0, - 3975, 446, 3975, 3114, 3031, 3098, 435, 371, 3045, 3026, 3975, 3076, - 3975, 3074, 3070, 439, 440, 3975, 578, 751, 586, 562, 735, 752, - 0, 572, 577, 588, 786, 749, 396, 809, 727, 582, 747, 753, - 764, 769, 580, 3975, - - 3975, 3067, 588, 3975, 3975, 3053, 3002, 2996, 3975, 3975, 3975, 3975, - 3975, 3975, 3975, 3975, 3975, 3975, 3975, 0, 3975, 3046, 3975, 3975, - 3975, 3018, 2986, 837, 3975, 2998, 0, 847, 3975, 2997, 817, 777, - 0, 0, 891, 903, 912, 924, 0, 774, 0, 451, 3975, 0, - 858, 3975, 2996, 2914, 472, 3975, 2974, 2953, 3975, 791, 236, 822, - 899, 3975, 275, 0, 2873, 2872, 3975, 2871, 949, 3975, 2949, 2850, - 2918, 2906, 3975, 0, 3975, 796, 3975, 0, 0, 2925, 0, 0, - 2597, 3975, 3975, 3975, 3975, 795, 794, 3975, 3975, 484, 0, 2597, - 3975, 877, 2596, 2594, - - 2594, 3975, 0, 3975, 918, 3975, 1005, 3975, 3975, 3975, 3975, 0, - 3975, 611, 3975, 0, 3975, 0, 853, 851, 3975, 3975, 490, 3975, - 608, 3975, 3975, 3975, 3975, 0, 3975, 3975, 596, 2510, 3975, 0, - 3975, 3975, 2588, 3975, 2581, 3975, 894, 906, 0, 911, 717, 727, - 923, 728, 2571, 882, 930, 889, 902, 916, 917, 940, 928, 923, - 940, 933, 0, 932, 3975, 935, 939, 951, 956, 1059, 964, 965, - 1052, 955, 957, 1099, 2578, 3975, 1078, 3975, 3975, 3975, 0, 3975, - 3975, 3975, 987, 0, 0, 1087, 3975, 2576, 1132, 985, 1046, 1058, - 0, 1058, 0, 1009, - - 3975, 1016, 3975, 1057, 3975, 1099, 3975, 1068, 731, 1088, 1095, 1178, - 1244, 1280, 988, 0, 3975, 3975, 2492, 1162, 3975, 3975, 1081, 0, - 1086, 0, 0, 1098, 1105, 1100, 3975, 1167, 1245, 1246, 1247, 1250, - 2539, 1248, 1249, 1258, 1244, 1251, 1259, 1321, 1233, 1224, 0, 1072, - 1228, 1243, 1261, 1287, 1298, 1289, 1298, 1287, 0, 1299, 1228, 1308, - 0, 1280, 1298, 1307, 1316, 1314, 1316, 2532, 1322, 1337, 1338, 1340, - 1342, 1342, 1348, 1353, 1356, 1347, 1357, 1362, 1366, 1358, 1353, 1356, - 1377, 1366, 1370, 1371, 1367, 1383, 1384, 1379, 1391, 1392, 1381, 1388, - 1397, 1275, 1455, 3975, - - 1439, 1463, 1444, 1415, 1412, 1415, 0, 1409, 0, 1429, 1492, 1558, - 1594, 1524, 2449, 1564, 1639, 3975, 3975, 1537, 1556, 1560, 1407, 2427, - 1558, 1563, 1559, 1564, 1572, 1584, 1574, 1562, 1615, 1619, 1609, 1625, - 1626, 1643, 1614, 1651, 1662, 1658, 1664, 1665, 1616, 1616, 1637, 3975, - 3975, 1638, 1631, 2352, 1634, 1641, 1655, 1650, 1677, 1679, 1671, 1689, - 0, 0, 1690, 1677, 1681, 1697, 0, 2348, 1684, 1694, 2274, 1686, - 1685, 1695, 0, 1692, 1711, 1704, 1703, 1701, 1713, 1703, 1704, 1712, - 0, 1717, 1731, 1731, 1719, 1723, 1722, 1741, 1726, 1742, 1734, 1747, - 1741, 2241, 3975, 1464, - - 1485, 1729, 1743, 1740, 0, 1721, 1591, 2173, 1585, 2139, 1771, 1807, - 1417, 962, 1426, 1755, 2049, 1745, 1769, 3975, 1774, 1782, 1789, 1775, - 1796, 1791, 1810, 1800, 1820, 1822, 1821, 1823, 1832, 1831, 1838, 1840, - 1853, 1856, 1854, 1855, 1863, 1865, 1861, 1846, 1862, 0, 1853, 1864, - 0, 1857, 0, 2008, 1866, 1862, 1869, 0, 1874, 1893, 1870, 0, - 1888, 1875, 1886, 1882, 1880, 1878, 1897, 1876, 1882, 1889, 1889, 0, - 1904, 1895, 1899, 1919, 0, 1907, 1909, 1908, 1923, 1791, 1924, 1925, - 1919, 1747, 1917, 1918, 1918, 1938, 1924, 1726, 1599, 1927, 1937, 1970, - 3975, 1702, 1652, 1923, - - 1755, 1941, 1625, 1618, 3975, 3975, 1961, 1977, 1966, 1969, 1956, 1979, - 1983, 1986, 1989, 1984, 1992, 1987, 1994, 1990, 1988, 1995, 2007, 2004, - 2016, 2022, 1996, 2028, 2018, 2026, 0, 0, 1620, 1990, 2009, 0, - 2035, 2020, 2035, 2029, 2024, 2025, 2029, 1589, 2049, 2041, 2052, 2048, - 2053, 2054, 2044, 2057, 0, 2064, 0, 2048, 0, 1576, 0, 2064, - 2070, 2056, 0, 2096, 2062, 0, 2067, 2108, 0, 1531, 2072, 2078, - 1438, 1853, 3975, 2105, 3975, 2068, 3975, 1463, 3975, 1407, 1402, 1348, - 1345, 1314, 1307, 1269, 1260, 1256, 1210, 1158, 2106, 2111, 2097, 2118, - 2122, 2129, 2125, 2140, - - 2131, 2136, 2141, 2143, 2156, 2131, 2138, 2147, 2101, 2151, 2138, 2153, - 0, 2141, 0, 2144, 2165, 2153, 2159, 2158, 2165, 0, 2165, 0, - 2167, 2169, 0, 2178, 0, 0, 0, 2183, 2167, 2179, 2210, 2178, - 2189, 2188, 2189, 2202, 2186, 2194, 2218, 2196, 2202, 1119, 1114, 2206, - 2118, 3975, 1106, 1100, 1081, 1068, 1065, 1061, 1057, 972, 968, 965, - 914, 925, 893, 881, 874, 869, 865, 861, 854, 843, 807, 802, - 776, 2235, 2212, 2226, 2221, 2227, 2239, 2238, 2228, 0, 2228, 2239, - 2242, 2252, 0, 2238, 2244, 2249, 2244, 2258, 2263, 2269, 2255, 3975, - 2263, 2265, 2265, 2281, - - 2265, 2262, 0, 2285, 2288, 2274, 3975, 2277, 2280, 2295, 2279, 2280, - 2283, 2303, 2283, 2330, 3975, 2335, 3975, 3975, 3975, 3975, 3975, 3975, - 3975, 3975, 3975, 3975, 3975, 735, 612, 608, 598, 441, 374, 261, - 245, 202, 152, 149, 137, 165, 2296, 2303, 2304, 2320, 2326, 2316, - 2324, 2329, 2324, 2316, 2319, 2335, 2324, 2327, 0, 2332, 2328, 2327, - 2332, 2345, 2348, 2352, 2344, 3975, 2338, 0, 2338, 2343, 2357, 2362, - 2357, 3975, 2371, 2356, 2359, 2358, 2380, 3975, 3975, 3975, 3975, 3975, - 3975, 3975, 3975, 3975, 3975, 3975, 3975, 128, 2384, 2382, 2373, 2387, - 2376, 2378, 2378, 0, - - 2395, 2396, 0, 2385, 2384, 2405, 2403, 2401, 2405, 2413, 3975, 2401, - 3975, 3975, 3975, 2409, 2416, 2404, 3975, 3975, 2400, 2422, 2422, 2414, - 2417, 2417, 3975, 2421, 2421, 2418, 2424, 2441, 2442, 2443, 0, 0, - 2453, 0, 2436, 0, 2451, 3975, 3975, 2445, 3975, 3975, 2446, 2457, - 2445, 2461, 2464, 2462, 2468, 2473, 2466, 2460, 0, 2462, 2459, 2461, - 2483, 0, 2463, 3975, 3975, 3975, 2484, 2488, 2476, 2482, 3975, 2495, - 2485, 2497, 2495, 2501, 2506, 2493, 0, 3975, 2496, 3975, 2508, 2498, - 2506, 2503, 2506, 2505, 0, 2520, 3975, 3975, 2522, 2514, 0, 0, - 2529, 2514, 2515, 0, - - 0, 2533, 2539, 0, 0, 3975, 2601, 2618, 2635, 2652, 2669, 2686, - 2703, 2720, 2737, 2754, 2771, 2788, 2805, 2822, 2839, 2856, 2873, 2890, - 2907, 2917, 2933, 2942, 2958, 2975, 2986, 3002, 3019, 3036, 3053, 3063, - 3079, 3096, 3113, 3127, 3137, 3153, 3170, 3187, 3204, 3215, 2009, 3227, - 3244, 3254, 3270, 3287, 3294, 3300, 3316, 3326, 3342, 3359, 3376, 2564, - 3386, 3403, 3420, 3437, 3454, 3471, 3488, 3505, 3522, 3532, 3548, 3562, - 3572, 3588, 3605, 3622, 3639, 3650, 3662, 3679, 3696, 3713, 3730, 3740, - 3749, 3765, 3782, 3799, 2571, 3809, 3826, 3843, 3860, 3877, 3885, 3890, - 3906, 3923, 3940, 3957 - -}; - -static yyconst flex_int16_t yy_def[1201] = { - 0, 1106, 1106, 1107, 1107, 1108, 1109, 1110, 1110, 1111, 1111, 1112, - 1112, 1106, 13, 1113, 1113, 1114, 1114, 1115, 1115, 1116, 1116, 1117, - 1117, 1106, 25, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1106, - 35, 1122, 1122, 1123, 1123, 1113, 1113, 1113, 1113, 1124, 1124, 1125, - 1125, 1106, 1106, 1106, 1106, 1106, 1126, 1106, 1106, 1106, 1106, 1127, - 1106, 1128, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1129, 1130, 1131, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1132, 1133, 1132, 1134, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1135, - - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1136, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1130, 1106, 1106, - 1130, 1137, 1106, 1106, 1106, 1138, 1106, 1130, 1106, 1139, 1106, 1139, - 1106, 1140, 1106, 1141, 1141, 1141, 1106, 1106, 1106, 1106, 1142, 1106, - 1142, 1106, 1106, 1106, 1106, 1106, 1106, 1143, 1106, 1143, 1106, 1144, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1145, 1106, 1106, 1106, 1146, 1146, 1146, 1146, 1146, 1146, - 1146, 1146, 1146, 1146, 1146, 1147, 1146, 1146, 1146, 1146, 1146, 1146, - 1146, 1146, 1146, 1106, - - 1106, 1148, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1149, 1106, 1149, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1150, 1106, 1106, 1106, 1106, 1106, - 1151, 1152, 1106, 1106, 1106, 1106, 1153, 1151, 1154, 1155, 1106, 1156, - 1106, 1106, 1106, 1106, 1157, 1106, 1106, 1106, 1106, 1106, 1158, 1158, - 1159, 1106, 1106, 1160, 1106, 1106, 1106, 1161, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1162, 1106, 1106, 1106, 1163, 1164, 1164, 1165, 1166, - 1167, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1168, 1169, 1106, - 1106, 1106, 1106, 1106, - - 1106, 1106, 1170, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1171, - 1106, 1172, 1106, 1172, 1106, 1173, 1173, 1173, 1106, 1106, 1174, 1106, - 1174, 1106, 1106, 1106, 1106, 1175, 1106, 1106, 1106, 1106, 1106, 1176, - 1106, 1106, 1106, 1106, 1177, 1106, 1106, 1106, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1106, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1179, 1106, 1106, 1106, 1106, 1106, 1180, 1106, - 1106, 1106, 1106, 1181, 1182, 1183, 1106, 1106, 1106, 1106, 1106, 1106, - 1184, 1181, 1185, 1186, - - 1106, 1186, 1106, 1187, 1106, 1187, 1106, 1106, 1188, 1188, 1188, 1106, - 1188, 1188, 1106, 1189, 1106, 1106, 1190, 1106, 1106, 1106, 1106, 1191, - 1106, 1192, 1193, 1106, 1106, 1194, 1106, 1194, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1196, 1196, 1197, 1106, - 1106, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, - 1106, 1183, 1183, 1106, - - 1183, 1183, 1106, 1106, 1106, 1106, 1184, 1198, 1185, 1106, 1106, 1188, - 414, 412, 412, 1188, 414, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1196, 1196, 1106, - 1106, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, 1106, - 1106, 1106, 1106, 1183, - - 1183, 1106, 1106, 1106, 1198, 1198, 1198, 1106, 511, 511, 1188, 414, - 1188, 1188, 1188, 1106, 1106, 1106, 1106, 1106, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1196, 1196, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1106, 1106, 1106, 1106, 1106, 1199, 1106, 1106, 1198, - 1106, 1198, 1106, 1188, - - 1188, 1188, 1106, 1106, 1106, 1106, 1195, 1195, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1196, 1196, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1106, 1178, 1178, 1178, 1106, 1178, 1106, 1106, 1106, - 1106, 1199, 1106, 1199, 1106, 1106, 1106, 1106, 1106, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, - 1195, 1195, 1195, 1195, - - 1195, 1195, 1195, 1195, 1195, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, 1106, 1106, 1106, 1106, - 1106, 1178, 1178, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1200, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, - 1195, 1195, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, - - 1106, 1106, 1178, 1178, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1200, 1106, 1200, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1195, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1178, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, - - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, 1178, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1178, 1178, 1178, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1106, 1106, 1106, 1106, 1178, - 1178, 1178, 1178, 1178, 1178, 1178, 1106, 1106, 1178, 1178, 1178, 1178, - 1178, 1178, 1178, 1178, - - 1178, 1178, 1178, 1178, 1178, 0, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106 - -}; - -static yyconst flex_int16_t yy_nxt[4060] = { - 0, 50, 51, 52, 50, 53, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 50, 50, 50, 50, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 50, 50, - 50, 50, 55, 56, 50, 57, 50, 58, 50, 59, 50, 50, - 50, 50, 50, 50, 50, - - 50, 60, 50, 50, 50, 50, 50, 50, 50, 50, 50, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 50, 50, 50, 50, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 50, 50, 50, 63, 64, 291, 65, - 66, 83, 67, 84, 89, 68, 69, 70, 70, 89, 1027, 70, - 71, 86, 83, 992, 84, 50, 72, 991, 87, 70, 93, 309, - 94, 101, 102, 291, - - 103, 101, 102, 990, 103, 113, 989, 114, 119, 315, 120, 121, - 148, 119, 149, 120, 121, 115, 50, 73, 74, 116, 116, 116, - 116, 148, 90, 149, 91, 228, 229, 90, 230, 91, 309, 93, - 95, 94, 276, 124, 125, 99, 126, 96, 97, 283, 98, 284, - 75, 70, 70, 76, 77, 316, 78, 66, 988, 67, 79, 122, - 68, 69, 70, 70, 122, 95, 70, 71, 124, 125, 290, 126, - 96, 80, 260, 261, 70, 95, 128, 201, 129, 221, 202, 222, - 96, 97, 117, 98, 410, 411, 223, 130, 320, 415, 415, 203, - 203, 203, 203, 987, - - 290, 201, 73, 74, 202, 81, 95, 221, 324, 222, 325, 277, - 225, 96, 226, 986, 223, 203, 203, 203, 203, 320, 227, 232, - 233, 324, 234, 325, 131, 132, 133, 75, 70, 70, 104, 105, - 106, 104, 107, 104, 104, 104, 104, 104, 104, 104, 108, 104, - 108, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 109, - 104, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 104, 104, 104, 104, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, - - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 104, 104, 104, 113, 128, 114, 129, 291, 151, - 235, 152, 263, 263, 985, 151, 115, 152, 130, 153, 116, 116, - 116, 116, 157, 153, 158, 159, 157, 366, 158, 159, 225, 333, - 226, 254, 254, 291, 255, 401, 334, 402, 227, 265, 264, 266, - 319, 236, 267, 267, 267, 267, 290, 343, 344, 131, 132, 133, - 366, 154, 405, 155, 406, 298, 299, 154, 300, 155, 305, 305, - 305, 305, 431, 264, 432, 160, 319, 236, 324, 160, 325, 984, - 290, 343, 344, 117, - - 134, 134, 135, 134, 136, 137, 134, 134, 134, 138, 134, 134, - 134, 134, 134, 134, 134, 139, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, 141, 140, 140, 140, - 140, 140, 140, 142, 143, 134, 144, 134, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 141, 140, 140, 140, 140, 140, 140, 142, 145, 134, 146, - 162, 163, 205, 164, 206, 162, 163, 165, 164, 353, 211, 211, - 165, 333, 216, 351, - - 166, 212, 212, 358, 334, 166, 379, 379, 379, 379, 324, 217, - 325, 352, 213, 213, 346, 359, 347, 360, 315, 218, 348, 353, - 214, 214, 219, 167, 371, 215, 215, 376, 167, 358, 168, 169, - 207, 170, 208, 168, 169, 217, 170, 352, 213, 213, 346, 359, - 347, 360, 218, 348, 983, 214, 214, 219, 167, 371, 215, 215, - 376, 167, 982, 168, 316, 209, 981, 210, 168, 171, 172, 173, - 171, 174, 175, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 176, 177, 171, 171, 171, 178, 171, 171, - 179, 180, 181, 182, - - 183, 184, 185, 186, 187, 185, 185, 188, 189, 190, 191, 192, - 185, 193, 194, 195, 196, 197, 198, 185, 199, 171, 171, 171, - 171, 171, 179, 180, 181, 182, 183, 184, 185, 186, 187, 185, - 185, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, - 185, 199, 171, 171, 171, 205, 216, 206, 249, 250, 370, 251, - 263, 263, 452, 252, 354, 269, 270, 217, 271, 263, 263, 453, - 272, 456, 372, 263, 263, 218, 349, 356, 364, 273, 219, 410, - 411, 355, 350, 274, 370, 980, 365, 452, 264, 373, 354, 374, - 375, 217, 941, 357, - - 453, 264, 456, 207, 372, 208, 218, 264, 349, 356, 364, 219, - 387, 361, 355, 398, 350, 362, 235, 275, 365, 264, 408, 373, - 940, 374, 375, 425, 357, 939, 264, 428, 209, 429, 210, 238, - 264, 253, 228, 229, 367, 230, 387, 361, 412, 398, 253, 362, - 232, 233, 368, 234, 408, 369, 239, 236, 240, 425, 240, 249, - 250, 428, 251, 429, 240, 938, 252, 240, 241, 242, 367, 240, - 243, 244, 410, 411, 937, 245, 298, 299, 368, 300, 369, 936, - 239, 236, 240, 935, 240, 445, 446, 934, 390, 391, 240, 392, - 933, 240, 241, 242, - - 240, 243, 244, 932, 390, 391, 245, 392, 246, 393, 393, 393, - 393, 390, 391, 931, 392, 413, 413, 445, 446, 393, 393, 393, - 393, 390, 391, 458, 392, 448, 393, 393, 393, 393, 461, 394, - 305, 305, 305, 305, 253, 449, 393, 393, 393, 393, 450, 930, - 462, 414, 269, 270, 454, 271, 395, 464, 458, 272, 459, 448, - 451, 463, 460, 461, 394, 396, 273, 465, 929, 455, 466, 449, - 274, 468, 467, 469, 450, 462, 414, 470, 471, 472, 454, 473, - 395, 464, 474, 476, 459, 451, 463, 480, 460, 482, 481, 396, - 475, 465, 455, 485, - - 466, 486, 468, 467, 275, 469, 262, 262, 470, 471, 472, 401, - 473, 402, 410, 411, 474, 476, 401, 928, 402, 480, 927, 482, - 481, 475, 926, 497, 485, 504, 486, 253, 433, 434, 435, 436, - 437, 437, 438, 437, 437, 437, 437, 439, 437, 437, 437, 440, - 437, 437, 441, 437, 442, 437, 437, 443, 437, 497, 504, 405, - 444, 406, 433, 434, 435, 436, 437, 437, 438, 437, 437, 437, - 437, 439, 437, 437, 437, 440, 437, 441, 437, 442, 437, 437, - 443, 437, 477, 483, 499, 500, 478, 501, 505, 506, 484, 479, - 379, 379, 379, 379, - - 508, 405, 431, 406, 432, 502, 502, 502, 502, 510, 511, 925, - 520, 512, 512, 924, 477, 483, 548, 923, 478, 505, 922, 506, - 484, 479, 487, 521, 488, 522, 508, 489, 490, 503, 391, 921, - 392, 491, 492, 510, 410, 411, 520, 493, 494, 513, 523, 548, - 495, 409, 393, 393, 393, 393, 920, 496, 487, 521, 488, 522, - 919, 489, 490, 519, 519, 519, 519, 491, 492, 431, 914, 432, - 493, 494, 513, 913, 523, 495, 409, 409, 861, 409, 409, 409, - 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 409, 409, 409, - - 409, 409, 409, 409, 409, 514, 514, 514, 514, 514, 514, 514, - 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, - 514, 514, 514, 514, 514, 514, 410, 411, 860, 515, 409, 514, - 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, - 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 409, - 409, 409, 516, 516, 546, 547, 524, 524, 524, 524, 524, 524, - 524, 524, 549, 558, 550, 599, 859, 600, 524, 524, 858, 525, - 526, 528, 533, 527, 551, 535, 530, 857, 529, 534, 546, 547, - 410, 411, 517, 517, - - 517, 517, 531, 549, 558, 532, 550, 517, 517, 517, 517, 517, - 517, 525, 526, 528, 533, 527, 551, 535, 530, 529, 552, 534, - 560, 553, 554, 555, 556, 856, 557, 531, 410, 411, 532, 559, - 855, 517, 517, 517, 517, 517, 517, 1106, 561, 562, 563, 565, - 536, 537, 538, 539, 552, 560, 540, 553, 554, 555, 556, 541, - 557, 564, 567, 542, 568, 559, 543, 854, 544, 569, 853, 545, - 570, 561, 571, 562, 563, 565, 536, 537, 538, 539, 572, 573, - 540, 574, 575, 576, 577, 541, 564, 578, 567, 542, 568, 543, - 581, 544, 582, 569, - - 545, 579, 570, 583, 571, 584, 585, 580, 586, 587, 606, 588, - 572, 573, 589, 574, 575, 576, 577, 590, 591, 578, 592, 593, - 852, 594, 581, 582, 598, 851, 595, 579, 583, 596, 597, 584, - 585, 580, 586, 587, 588, 500, 602, 600, 589, 503, 391, 603, - 392, 590, 591, 619, 592, 593, 594, 604, 499, 500, 598, 501, - 595, 608, 596, 597, 601, 500, 599, 501, 600, 410, 411, 259, - 602, 502, 502, 502, 502, 603, 410, 411, 619, 502, 502, 502, - 502, 604, 601, 500, 850, 501, 607, 608, 409, 409, 848, 409, - 409, 409, 409, 409, - - 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 409, 409, 409, 409, 409, 409, 609, 609, 609, 609, 609, - 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, - 609, 609, 609, 609, 609, 609, 609, 609, 410, 411, 613, 610, - 409, 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, - 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, - 609, 409, 409, 409, 611, 611, 616, 409, 524, 524, 614, 614, - 524, 524, 524, 845, 617, 618, 623, 828, 696, 697, 524, 698, - 524, 625, 621, 626, - - 622, 775, 629, 776, 817, 624, 524, 700, 616, 628, 410, 411, - 612, 612, 612, 612, 410, 411, 617, 618, 623, 612, 612, 612, - 612, 612, 612, 625, 621, 626, 622, 524, 629, 627, 624, 806, - 524, 524, 524, 628, 409, 524, 630, 781, 632, 644, 643, 524, - 524, 636, 780, 612, 612, 612, 612, 612, 612, 615, 615, 615, - 615, 631, 627, 633, 634, 524, 615, 615, 615, 615, 615, 615, - 630, 524, 632, 644, 643, 779, 646, 636, 524, 645, 647, 635, - 524, 649, 524, 524, 650, 651, 652, 631, 653, 633, 634, 637, - 615, 615, 615, 615, - - 615, 615, 639, 638, 697, 640, 641, 642, 646, 654, 645, 647, - 656, 635, 649, 655, 658, 650, 657, 651, 652, 659, 606, 660, - 637, 661, 662, 692, 664, 665, 669, 639, 667, 638, 640, 668, - 641, 642, 670, 654, 671, 672, 656, 673, 675, 655, 658, 657, - 674, 676, 677, 659, 660, 678, 661, 679, 662, 664, 680, 665, - 669, 667, 681, 683, 668, 682, 684, 670, 685, 687, 671, 672, - 686, 673, 675, 688, 690, 674, 676, 677, 693, 689, 691, 678, - 694, 679, 695, 703, 680, 701, 701, 705, 681, 683, 682, 684, - 524, 524, 685, 687, - - 706, 686, 607, 768, 524, 688, 690, 410, 411, 693, 689, 524, - 691, 524, 694, 695, 708, 703, 524, 710, 705, 707, 524, 410, - 411, 702, 702, 702, 702, 709, 706, 711, 524, 712, 702, 702, - 702, 702, 702, 702, 714, 713, 524, 524, 524, 524, 708, 764, - 710, 715, 707, 716, 717, 524, 524, 775, 718, 776, 721, 709, - 524, 711, 524, 712, 702, 702, 702, 702, 702, 702, 714, 713, - 719, 723, 720, 524, 524, 524, 524, 715, 724, 716, 717, 524, - 722, 524, 718, 524, 721, 726, 728, 752, 731, 732, 734, 727, - 730, 748, 733, 736, - - 741, 738, 719, 723, 720, 725, 735, 729, 743, 740, 724, 739, - 742, 722, 744, 745, 746, 747, 749, 726, 728, 731, 750, 732, - 734, 727, 730, 733, 751, 736, 741, 738, 753, 754, 725, 755, - 735, 729, 740, 756, 739, 757, 742, 744, 758, 745, 746, 747, - 749, 759, 761, 750, 760, 762, 763, 765, 766, 767, 751, 769, - 770, 753, 754, 771, 755, 772, 773, 777, 778, 756, 757, 696, - 697, 758, 698, 410, 411, 409, 524, 759, 761, 760, 762, 524, - 763, 765, 766, 767, 524, 769, 770, 524, 771, 410, 411, 772, - 773, 777, 778, 524, - - 782, 524, 786, 784, 783, 524, 524, 785, 524, 524, 524, 524, - 524, 787, 524, 791, 524, 524, 524, 363, 363, 807, 793, 737, - 795, 802, 524, 788, 796, 524, 782, 786, 789, 784, 783, 790, - 792, 785, 524, 797, 524, 794, 798, 787, 524, 791, 799, 800, - 524, 804, 524, 807, 793, 808, 795, 802, 788, 803, 796, 805, - 811, 789, 801, 809, 790, 792, 812, 813, 797, 814, 794, 815, - 798, 810, 704, 816, 799, 800, 818, 804, 819, 820, 808, 821, - 822, 823, 825, 803, 824, 805, 811, 826, 801, 809, 827, 829, - 812, 813, 814, 830, - - 815, 831, 838, 810, 816, 839, 846, 775, 818, 776, 819, 820, - 849, 821, 822, 823, 825, 824, 847, 524, 917, 826, 918, 827, - 864, 829, 832, 833, 524, 830, 831, 834, 838, 524, 835, 839, - 846, 836, 840, 841, 524, 849, 837, 842, 524, 878, 843, 524, - 847, 844, 863, 524, 862, 524, 864, 865, 832, 833, 524, 868, - 866, 834, 524, 524, 835, 524, 875, 836, 840, 841, 876, 837, - 872, 842, 878, 867, 843, 870, 524, 844, 863, 862, 871, 880, - 869, 865, 882, 873, 877, 868, 866, 874, 879, 881, 409, 883, - 875, 884, 699, 885, - - 876, 886, 872, 887, 867, 888, 870, 889, 890, 891, 892, 871, - 880, 869, 894, 882, 873, 895, 877, 896, 902, 874, 879, 881, - 883, 901, 893, 884, 885, 903, 904, 886, 887, 905, 907, 888, - 906, 889, 890, 891, 892, 897, 692, 911, 894, 898, 895, 912, - 899, 896, 902, 915, 943, 908, 901, 893, 909, 524, 900, 903, - 904, 944, 946, 905, 907, 906, 910, 945, 947, 948, 950, 897, - 911, 949, 951, 898, 912, 952, 899, 953, 915, 942, 943, 908, - 954, 955, 909, 900, 956, 666, 957, 944, 946, 958, 959, 910, - 945, 960, 947, 948, - - 950, 961, 949, 962, 951, 963, 964, 952, 965, 953, 942, 966, - 967, 954, 968, 955, 969, 971, 956, 957, 970, 972, 973, 958, - 959, 974, 975, 960, 976, 979, 961, 977, 917, 962, 918, 963, - 964, 917, 965, 918, 966, 967, 993, 994, 968, 995, 969, 971, - 978, 970, 996, 972, 973, 997, 974, 975, 998, 976, 979, 999, - 1000, 977, 1001, 663, 1002, 1003, 1004, 648, 1005, 1006, 1007, 993, - 1008, 994, 1009, 995, 1010, 978, 1011, 1012, 996, 1013, 1014, 997, - 1015, 1016, 998, 1017, 1018, 999, 1000, 1019, 1001, 1002, 1003, 1020, - 1004, 1005, 1021, 1006, - - 1007, 1008, 1022, 1009, 1025, 1010, 1023, 1026, 1011, 1012, 1024, 1013, - 1014, 1015, 1016, 1028, 1017, 1029, 1018, 1030, 1031, 1019, 1032, 1033, - 1034, 1020, 1035, 1036, 1021, 1037, 1038, 1022, 1039, 1025, 1040, 1023, - 1041, 1026, 1042, 1024, 1043, 1044, 1045, 1046, 1047, 1028, 1048, 1029, - 1030, 1049, 1031, 1032, 1033, 1034, 1050, 1057, 1035, 1036, 1037, 1038, - 1051, 1052, 1039, 1053, 1040, 1054, 1041, 1055, 1042, 1056, 1043, 1044, - 1045, 1046, 1047, 1048, 1058, 1059, 1060, 1049, 1061, 620, 1062, 1063, - 1050, 1057, 1064, 1065, 1066, 1051, 1052, 1067, 1053, 1068, 1054, 1069, - 1055, 1070, 1056, 1071, - - 1072, 1073, 1074, 1075, 409, 1076, 1058, 1059, 1060, 1077, 1061, 1062, - 1078, 1063, 1079, 1080, 1064, 1065, 1066, 1081, 1067, 1082, 1083, 1068, - 1084, 1069, 1085, 1070, 1086, 1071, 1072, 1073, 1074, 1075, 1076, 1087, - 1088, 1089, 1077, 1090, 1091, 1092, 1078, 1079, 1093, 1080, 1094, 566, - 1095, 1081, 1082, 1096, 1083, 1097, 1084, 1098, 1085, 1099, 1086, 1100, - 1101, 524, 1102, 1103, 1104, 1087, 1088, 1089, 1090, 1091, 1105, 1092, - 416, 1093, 416, 420, 1094, 1095, 391, 518, 1096, 518, 1097, 378, - 457, 1098, 342, 1099, 1100, 339, 1101, 1102, 1103, 336, 1104, 301, - 299, 301, 296, 286, - - 1105, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 92, 92, 92, - 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, - - 100, 100, 100, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, - - 147, 147, 147, 147, 147, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 204, 204, 204, 220, 220, 220, 220, 220, 220, - 220, 220, 220, 220, - - 220, 220, 220, 220, 220, 220, 220, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 231, 231, 282, 231, 231, 423, 422, 421, 231, 237, 237, 237, - 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, - 237, 248, 248, 270, 248, 248, 420, 418, 417, 248, 259, 407, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 262, 254, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 268, 268, 268, 403, - 268, 268, 250, 233, - - 229, 268, 280, 386, 280, 280, 280, 280, 280, 280, 280, 280, - 280, 280, 280, 280, 280, 280, 280, 281, 385, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - 384, 285, 382, 285, 285, 295, 381, 380, 295, 295, 295, 295, - 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 303, 303, - 378, 303, 303, 342, 340, 339, 303, 308, 338, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 311, 337, 311, 311, - - 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 317, 311, - 311, 312, 336, 312, 335, 331, 312, 312, 312, 312, 312, 329, - 328, 327, 312, 314, 326, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 318, 318, 322, 318, - 318, 321, 317, 313, 318, 323, 323, 323, 323, 323, 323, 323, - 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 330, 307, - 330, 310, 330, 330, 330, 330, 330, 330, 330, 330, 330, 307, - 330, 330, 330, 332, 306, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, - - 332, 332, 332, 332, 341, 304, 341, 341, 341, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 341, 341, 341, 345, 345, 302, - 299, 345, 345, 377, 301, 377, 377, 377, 377, 377, 377, 377, - 377, 377, 377, 377, 377, 377, 377, 377, 383, 297, 383, 383, - 383, 296, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 231, 231, 294, 231, 231, 293, 292, 289, 231, 388, 288, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 389, 287, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, - - 389, 389, 389, 389, 397, 397, 286, 282, 279, 397, 399, 399, - 278, 270, 258, 399, 400, 400, 400, 400, 400, 400, 400, 400, - 400, 400, 400, 400, 400, 400, 400, 400, 400, 248, 248, 257, - 248, 248, 256, 250, 247, 248, 404, 404, 404, 404, 404, 404, - 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 409, - 233, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 229, 409, 409, 259, 1106, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 419, 419, 111, - 419, 419, 111, 1106, - - 1106, 419, 419, 424, 1106, 424, 424, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 424, 424, 424, 424, 280, 1106, 280, 280, - 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, - 280, 281, 1106, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 426, 1106, 426, 426, 426, 426, - 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, 427, - 1106, 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 285, 285, 285, 285, 285, 285, 285, 285, - 285, 285, 285, 285, - - 1106, 285, 1106, 285, 285, 430, 430, 430, 430, 430, 430, 430, - 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, 295, 1106, - 1106, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, - 295, 295, 295, 303, 303, 1106, 303, 303, 1106, 1106, 1106, 303, - 312, 1106, 312, 1106, 1106, 312, 312, 312, 312, 312, 1106, 1106, - 1106, 312, 314, 1106, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 318, 318, 1106, 318, 318, - 1106, 1106, 1106, 318, 323, 323, 323, 323, 323, 323, 323, 323, - 323, 323, 323, 323, - - 323, 323, 323, 323, 323, 330, 1106, 330, 1106, 330, 330, 330, - 330, 330, 330, 330, 330, 330, 1106, 330, 330, 330, 447, 1106, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 341, 1106, 341, 341, 341, 341, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 341, 341, 345, 345, 1106, 1106, - 345, 345, 377, 1106, 377, 377, 377, 377, 377, 377, 377, 377, - 377, 377, 377, 377, 377, 377, 377, 383, 1106, 383, 383, 383, - 1106, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 388, 1106, 388, 388, - - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 389, 1106, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, 389, 389, 498, 498, 498, 498, 498, 498, - 498, 498, 498, 498, 498, 498, 498, 498, 498, 498, 498, 507, - 507, 1106, 507, 507, 1106, 1106, 1106, 507, 509, 509, 1106, 509, - 509, 1106, 1106, 1106, 509, 400, 400, 400, 400, 400, 400, 400, - 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 404, 404, - 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, - 404, 404, 404, 409, - - 1106, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 1106, 409, 409, 419, 419, 1106, 419, 419, 1106, 1106, 1106, - 419, 419, 424, 1106, 424, 424, 424, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 424, 424, 424, 426, 1106, 426, 426, 426, - 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - 427, 1106, 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 427, 430, 430, 430, 430, 430, 430, 430, - 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, 437, 437, - 437, 318, 318, 1106, - - 318, 318, 1106, 1106, 1106, 318, 447, 1106, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 605, - 1106, 605, 605, 605, 605, 605, 605, 605, 605, 605, 605, 605, - 605, 605, 605, 605, 774, 774, 774, 774, 774, 774, 774, 774, - 774, 774, 774, 774, 774, 774, 774, 774, 774, 916, 916, 916, - 916, 916, 916, 916, 916, 916, 916, 916, 916, 916, 916, 916, - 916, 916, 49, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, - - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106}; - -static yyconst flex_int16_t yy_chk[4060] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, - - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 96, 3, - 3, 5, 3, 5, 7, 3, 3, 3, 3, 8, 992, 3, - 3, 6, 6, 942, 6, 21, 3, 941, 6, 3, 9, 126, - 9, 11, 11, 96, - - 11, 12, 12, 940, 12, 17, 939, 17, 19, 138, 19, 19, - 27, 20, 27, 20, 20, 17, 22, 3, 3, 17, 17, 17, - 17, 28, 7, 28, 7, 51, 51, 8, 51, 8, 126, 10, - 9, 10, 79, 21, 21, 10, 21, 9, 9, 87, 9, 87, - 3, 3, 3, 4, 4, 138, 4, 4, 938, 4, 4, 19, - 4, 4, 4, 4, 20, 9, 4, 4, 22, 22, 95, 22, - 9, 4, 73, 73, 4, 10, 23, 37, 23, 45, 37, 45, - 10, 10, 17, 10, 259, 259, 45, 23, 142, 263, 263, 37, - 37, 37, 37, 937, - - 95, 38, 4, 4, 38, 4, 10, 46, 147, 46, 147, 79, - 47, 10, 47, 936, 46, 38, 38, 38, 38, 142, 47, 55, - 55, 149, 55, 149, 23, 23, 23, 4, 4, 4, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, - - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 18, 24, 18, 24, 168, 29, - 58, 29, 74, 74, 935, 30, 18, 30, 24, 29, 18, 18, - 18, 18, 31, 30, 31, 31, 32, 191, 32, 32, 48, 162, - 48, 67, 67, 168, 67, 246, 162, 246, 48, 75, 74, 75, - 141, 58, 75, 75, 75, 75, 167, 176, 177, 24, 24, 24, - 191, 29, 253, 29, 253, 105, 105, 30, 105, 30, 116, 116, - 116, 116, 294, 74, 294, 31, 141, 58, 323, 32, 323, 934, - 167, 176, 177, 18, - - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 33, 33, 39, 33, 39, 34, 34, 33, 34, 182, 41, 42, - 34, 333, 43, 181, - - 33, 41, 42, 186, 333, 34, 203, 203, 203, 203, 325, 43, - 325, 181, 41, 42, 179, 187, 179, 188, 314, 43, 179, 182, - 41, 42, 43, 33, 194, 41, 42, 199, 34, 186, 33, 33, - 39, 33, 39, 34, 34, 43, 34, 181, 41, 42, 179, 187, - 179, 188, 43, 179, 933, 41, 42, 43, 33, 194, 41, 42, - 199, 34, 932, 33, 314, 39, 931, 39, 34, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, - - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 40, 44, 40, 63, 63, 193, 63, - 122, 122, 347, 63, 183, 76, 76, 44, 76, 125, 125, 348, - 76, 350, 195, 132, 132, 44, 180, 184, 190, 76, 44, 409, - 409, 183, 180, 76, 193, 930, 190, 347, 122, 196, 183, 197, - 198, 44, 873, 184, - - 348, 125, 350, 40, 195, 40, 44, 132, 180, 184, 190, 44, - 236, 189, 183, 244, 180, 189, 235, 76, 190, 122, 258, 196, - 872, 197, 198, 278, 184, 871, 125, 290, 40, 291, 40, 59, - 132, 63, 228, 228, 192, 228, 236, 189, 260, 244, 76, 189, - 232, 232, 192, 232, 258, 192, 59, 235, 59, 278, 59, 249, - 249, 290, 249, 291, 59, 870, 249, 59, 59, 59, 192, 59, - 59, 59, 260, 260, 869, 59, 298, 298, 192, 298, 192, 868, - 59, 235, 59, 867, 59, 319, 320, 866, 239, 239, 59, 239, - 865, 59, 59, 59, - - 59, 59, 59, 864, 240, 240, 59, 240, 59, 239, 239, 239, - 239, 241, 241, 863, 241, 261, 261, 319, 320, 240, 240, 240, - 240, 242, 242, 352, 242, 343, 241, 241, 241, 241, 354, 239, - 305, 305, 305, 305, 249, 344, 242, 242, 242, 242, 346, 862, - 355, 261, 269, 269, 349, 269, 241, 357, 352, 269, 353, 343, - 346, 356, 353, 354, 239, 242, 269, 358, 861, 349, 359, 344, - 269, 360, 359, 361, 346, 355, 261, 362, 364, 366, 349, 367, - 241, 357, 368, 369, 353, 346, 356, 371, 353, 372, 371, 242, - 368, 358, 349, 374, - - 359, 375, 360, 359, 269, 361, 415, 415, 362, 364, 366, 400, - 367, 400, 614, 614, 368, 369, 402, 860, 402, 371, 859, 372, - 371, 368, 858, 387, 374, 394, 375, 269, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 387, 394, 404, - 307, 404, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 370, 373, 390, 390, 370, 390, 395, 396, 373, 370, - 379, 379, 379, 379, - - 398, 406, 430, 406, 430, 390, 390, 390, 390, 408, 410, 857, - 423, 411, 411, 856, 370, 373, 448, 855, 370, 395, 854, 396, - 373, 370, 376, 425, 376, 428, 398, 376, 376, 393, 393, 853, - 393, 376, 376, 408, 410, 410, 423, 376, 376, 411, 429, 448, - 376, 411, 393, 393, 393, 393, 852, 376, 376, 425, 376, 428, - 851, 376, 376, 420, 420, 420, 420, 376, 376, 432, 847, 432, - 376, 376, 411, 846, 429, 376, 412, 412, 792, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, - - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 791, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 413, 413, 445, 446, 441, 433, 434, 435, 438, 439, - 436, 442, 449, 459, 450, 498, 790, 498, 440, 443, 789, 433, - 434, 436, 441, 435, 451, 443, 439, 788, 438, 442, 445, 446, - 413, 413, 414, 414, - - 414, 414, 440, 449, 459, 440, 450, 414, 414, 414, 414, 414, - 414, 433, 434, 436, 441, 435, 451, 443, 439, 438, 452, 442, - 462, 453, 454, 455, 456, 787, 458, 440, 414, 414, 440, 460, - 786, 414, 414, 414, 414, 414, 414, 444, 463, 464, 465, 467, - 444, 444, 444, 444, 452, 462, 444, 453, 454, 455, 456, 444, - 458, 466, 469, 444, 470, 460, 444, 785, 444, 471, 784, 444, - 472, 463, 473, 464, 465, 467, 444, 444, 444, 444, 474, 475, - 444, 476, 477, 478, 479, 444, 466, 480, 469, 444, 470, 444, - 482, 444, 483, 471, - - 444, 481, 472, 484, 473, 485, 486, 481, 487, 488, 508, 489, - 474, 475, 490, 476, 477, 478, 479, 491, 492, 480, 493, 494, - 783, 495, 482, 483, 497, 782, 496, 481, 484, 496, 496, 485, - 486, 481, 487, 488, 489, 501, 504, 501, 490, 503, 503, 505, - 503, 491, 492, 523, 493, 494, 495, 506, 499, 499, 497, 499, - 496, 510, 496, 496, 502, 502, 600, 502, 600, 613, 613, 613, - 504, 499, 499, 499, 499, 505, 615, 615, 523, 502, 502, 502, - 502, 506, 601, 601, 780, 601, 508, 510, 511, 511, 773, 511, - 511, 511, 511, 511, - - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 514, 511, - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 512, 512, 520, 514, 525, 527, 516, 516, - 532, 526, 528, 770, 521, 522, 526, 758, 607, 607, 529, 607, - 531, 528, 525, 529, - - 525, 693, 532, 693, 744, 527, 530, 609, 520, 531, 512, 512, - 513, 513, 513, 513, 516, 516, 521, 522, 526, 513, 513, 513, - 513, 513, 513, 528, 525, 529, 525, 535, 532, 530, 527, 733, - 539, 533, 545, 531, 609, 534, 533, 704, 535, 546, 545, 536, - 537, 539, 703, 513, 513, 513, 513, 513, 513, 517, 517, 517, - 517, 534, 530, 536, 537, 538, 517, 517, 517, 517, 517, 517, - 533, 540, 535, 546, 545, 699, 550, 539, 542, 547, 551, 538, - 541, 553, 543, 544, 554, 555, 556, 534, 557, 536, 537, 540, - 517, 517, 517, 517, - - 517, 517, 542, 541, 698, 542, 543, 544, 550, 557, 547, 551, - 558, 538, 553, 557, 560, 554, 559, 555, 556, 563, 606, 564, - 540, 565, 566, 692, 569, 570, 574, 542, 572, 541, 542, 573, - 543, 544, 576, 557, 577, 578, 558, 579, 581, 557, 560, 559, - 580, 582, 583, 563, 564, 584, 565, 586, 566, 569, 587, 570, - 574, 572, 588, 590, 573, 589, 591, 576, 592, 594, 577, 578, - 593, 579, 581, 595, 596, 580, 582, 583, 602, 595, 597, 584, - 603, 586, 604, 616, 587, 611, 611, 618, 588, 590, 589, 591, - 621, 624, 592, 594, - - 619, 593, 606, 686, 622, 595, 596, 701, 701, 602, 595, 623, - 597, 626, 603, 604, 622, 616, 625, 624, 618, 621, 628, 611, - 611, 612, 612, 612, 612, 623, 619, 625, 627, 626, 612, 612, - 612, 612, 612, 612, 628, 627, 629, 631, 630, 632, 622, 682, - 624, 629, 621, 630, 631, 634, 633, 774, 632, 774, 634, 623, - 635, 625, 636, 626, 612, 612, 612, 612, 612, 612, 628, 627, - 633, 636, 633, 637, 639, 640, 638, 629, 637, 630, 631, 643, - 635, 641, 632, 642, 634, 639, 641, 668, 644, 645, 648, 640, - 643, 664, 647, 650, - - 655, 653, 633, 636, 633, 638, 648, 642, 658, 654, 637, 653, - 657, 635, 659, 661, 662, 663, 665, 639, 641, 644, 666, 645, - 648, 640, 643, 647, 667, 650, 655, 653, 669, 670, 638, 671, - 648, 642, 654, 673, 653, 674, 657, 659, 675, 661, 662, 663, - 665, 676, 679, 666, 678, 680, 681, 683, 684, 685, 667, 687, - 688, 669, 670, 689, 671, 690, 691, 694, 695, 673, 674, 696, - 696, 675, 696, 700, 700, 700, 711, 676, 679, 678, 680, 707, - 681, 683, 684, 685, 709, 687, 688, 710, 689, 702, 702, 690, - 691, 694, 695, 708, - - 707, 712, 711, 709, 708, 713, 716, 710, 714, 718, 721, 715, - 720, 712, 717, 716, 719, 722, 727, 1147, 1147, 734, 718, 652, - 720, 727, 724, 713, 721, 723, 707, 711, 714, 709, 708, 715, - 717, 710, 725, 722, 729, 719, 723, 712, 726, 716, 724, 725, - 730, 729, 728, 734, 718, 735, 720, 727, 713, 728, 721, 730, - 738, 714, 726, 737, 715, 717, 739, 740, 722, 741, 719, 742, - 723, 737, 617, 743, 724, 725, 745, 729, 746, 747, 735, 748, - 749, 750, 752, 728, 751, 730, 738, 754, 726, 737, 756, 760, - 739, 740, 741, 761, - - 742, 762, 765, 737, 743, 767, 771, 776, 745, 776, 746, 747, - 778, 748, 749, 750, 752, 751, 772, 795, 849, 754, 849, 756, - 795, 760, 764, 764, 793, 761, 762, 764, 765, 794, 764, 767, - 771, 764, 768, 768, 796, 778, 764, 768, 797, 809, 768, 799, - 772, 768, 794, 798, 793, 801, 795, 796, 764, 764, 802, 799, - 797, 764, 800, 803, 764, 804, 806, 764, 768, 768, 807, 764, - 803, 768, 809, 798, 768, 801, 805, 768, 794, 793, 802, 811, - 800, 796, 814, 804, 808, 799, 797, 805, 810, 812, 610, 816, - 806, 817, 608, 818, - - 807, 819, 803, 820, 798, 821, 801, 823, 825, 826, 828, 802, - 811, 800, 832, 814, 804, 833, 808, 834, 837, 805, 810, 812, - 816, 836, 828, 817, 818, 838, 839, 819, 820, 840, 842, 821, - 841, 823, 825, 826, 828, 835, 598, 844, 832, 835, 833, 845, - 835, 834, 837, 848, 875, 843, 836, 828, 843, 874, 835, 838, - 839, 876, 878, 840, 842, 841, 843, 877, 879, 880, 883, 835, - 844, 881, 884, 835, 845, 885, 835, 886, 848, 874, 875, 843, - 888, 889, 843, 835, 890, 571, 891, 876, 878, 892, 893, 843, - 877, 894, 879, 880, - - 883, 895, 881, 897, 884, 898, 899, 885, 900, 886, 874, 901, - 902, 888, 904, 889, 905, 908, 890, 891, 906, 909, 910, 892, - 893, 911, 912, 894, 913, 915, 895, 914, 916, 897, 916, 898, - 899, 918, 900, 918, 901, 902, 943, 944, 904, 945, 905, 908, - 914, 906, 946, 909, 910, 947, 911, 912, 948, 913, 915, 949, - 950, 914, 951, 568, 952, 953, 954, 552, 955, 956, 958, 943, - 959, 944, 960, 945, 961, 914, 962, 963, 946, 964, 965, 947, - 967, 969, 948, 970, 971, 949, 950, 972, 951, 952, 953, 973, - 954, 955, 975, 956, - - 958, 959, 976, 960, 978, 961, 977, 979, 962, 963, 977, 964, - 965, 967, 969, 993, 970, 994, 971, 995, 996, 972, 997, 998, - 999, 973, 1001, 1002, 975, 1004, 1005, 976, 1006, 978, 1007, 977, - 1008, 979, 1009, 977, 1010, 1012, 1016, 1017, 1018, 993, 1021, 994, - 995, 1022, 996, 997, 998, 999, 1023, 1031, 1001, 1002, 1004, 1005, - 1024, 1025, 1006, 1026, 1007, 1028, 1008, 1029, 1009, 1030, 1010, 1012, - 1016, 1017, 1018, 1021, 1032, 1033, 1034, 1022, 1037, 524, 1039, 1041, - 1023, 1031, 1044, 1047, 1048, 1024, 1025, 1049, 1026, 1050, 1028, 1051, - 1029, 1052, 1030, 1053, - - 1054, 1055, 1056, 1058, 515, 1059, 1032, 1033, 1034, 1060, 1037, 1039, - 1061, 1041, 1063, 1067, 1044, 1047, 1048, 1068, 1049, 1069, 1070, 1050, - 1072, 1051, 1073, 1052, 1074, 1053, 1054, 1055, 1056, 1058, 1059, 1075, - 1076, 1077, 1060, 1078, 1081, 1083, 1061, 1063, 1084, 1067, 1085, 468, - 1086, 1068, 1069, 1087, 1070, 1088, 1072, 1090, 1073, 1093, 1074, 1094, - 1097, 437, 1098, 1099, 1102, 1075, 1076, 1077, 1078, 1081, 1103, 1083, - 1160, 1084, 1160, 419, 1085, 1086, 392, 1189, 1087, 1189, 1088, 377, - 351, 1090, 341, 1093, 1094, 339, 1097, 1098, 1099, 334, 1102, 301, - 300, 299, 296, 285, - - 1103, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, - 1107, 1107, 1107, 1107, 1107, 1107, 1108, 1108, 1108, 1108, 1108, 1108, - 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1109, - 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1109, - 1109, 1109, 1109, 1109, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1110, - 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1111, 1111, 1111, - 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, - 1111, 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, - 1112, 1112, 1112, 1112, - - 1112, 1112, 1112, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, - 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1114, 1114, 1114, 1114, - 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, - 1114, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, - 1115, 1115, 1115, 1115, 1115, 1115, 1116, 1116, 1116, 1116, 1116, 1116, - 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1117, - 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, - 1117, 1117, 1117, 1117, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, - 1118, 1118, 1118, 1118, - - 1118, 1118, 1118, 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, 1119, - 1119, 1119, 1119, 1119, 1119, 1119, 1119, 1119, 1119, 1119, 1120, 1120, - 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, - 1120, 1120, 1120, 1121, 1121, 1121, 1121, 1121, 1121, 1121, 1121, 1121, - 1121, 1121, 1121, 1121, 1121, 1121, 1121, 1121, 1122, 1122, 1122, 1122, - 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, - 1122, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, - 1123, 1123, 1123, 1123, 1123, 1123, 1124, 1124, 1124, 1124, 1124, 1124, - 1124, 1124, 1124, 1124, - - 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1125, 1125, 1125, 1125, 1125, - 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, - 1126, 1126, 282, 1126, 1126, 274, 273, 272, 1126, 1127, 1127, 1127, - 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, - 1127, 1128, 1128, 271, 1128, 1128, 268, 266, 265, 1128, 1129, 256, - 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, - 1129, 1129, 1129, 1130, 255, 1130, 1130, 1130, 1130, 1130, 1130, 1130, - 1130, 1130, 1130, 1130, 1130, 1130, 1130, 1130, 1131, 1131, 1131, 252, - 1131, 1131, 251, 234, - - 230, 1131, 1132, 227, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, - 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1133, 226, 1133, 1133, 1133, - 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, - 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, - 222, 1134, 208, 1134, 1134, 1135, 207, 206, 1135, 1135, 1135, 1135, - 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1136, 1136, - 202, 1136, 1136, 175, 174, 172, 1136, 1137, 170, 1137, 1137, 1137, - 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1137, - 1138, 169, 1138, 1138, - - 1138, 1138, 1138, 1138, 1138, 1138, 1138, 1138, 1138, 1138, 166, 1138, - 1138, 1139, 165, 1139, 164, 158, 1139, 1139, 1139, 1139, 1139, 155, - 154, 153, 1139, 1140, 152, 1140, 1140, 1140, 1140, 1140, 1140, 1140, - 1140, 1140, 1140, 1140, 1140, 1140, 1140, 1140, 1141, 1141, 144, 1141, - 1141, 143, 139, 136, 1141, 1142, 1142, 1142, 1142, 1142, 1142, 1142, - 1142, 1142, 1142, 1142, 1142, 1142, 1142, 1142, 1142, 1142, 1143, 131, - 1143, 129, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 124, - 1143, 1143, 1143, 1144, 120, 1144, 1144, 1144, 1144, 1144, 1144, 1144, - 1144, 1144, 1144, 1144, - - 1144, 1144, 1144, 1144, 1145, 114, 1145, 1145, 1145, 1145, 1145, 1145, - 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1146, 1146, 109, - 107, 1146, 1146, 1148, 106, 1148, 1148, 1148, 1148, 1148, 1148, 1148, - 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1149, 103, 1149, 1149, - 1149, 101, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, - 1149, 1150, 1150, 99, 1150, 1150, 98, 97, 94, 1150, 1151, 91, - 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, - 1151, 1151, 1151, 1152, 90, 1152, 1152, 1152, 1152, 1152, 1152, 1152, - 1152, 1152, 1152, 1152, - - 1152, 1152, 1152, 1152, 1153, 1153, 88, 86, 84, 1153, 1154, 1154, - 80, 78, 72, 1154, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, - 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1156, 1156, 71, - 1156, 1156, 68, 65, 60, 1156, 1157, 1157, 1157, 1157, 1157, 1157, - 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1158, - 57, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, - 1158, 53, 1158, 1158, 1159, 49, 1159, 1159, 1159, 1159, 1159, 1159, - 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1161, 1161, 16, - 1161, 1161, 15, 0, - - 0, 1161, 1161, 1162, 0, 1162, 1162, 1162, 1162, 1162, 1162, 1162, - 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1163, 0, 1163, 1163, - 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, - 1163, 1164, 0, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, - 1164, 1164, 1164, 1164, 1164, 1164, 1165, 0, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1166, - 0, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, - 1166, 1166, 1166, 1166, 1167, 1167, 1167, 1167, 1167, 1167, 1167, 1167, - 1167, 1167, 1167, 1167, - - 0, 1167, 0, 1167, 1167, 1168, 1168, 1168, 1168, 1168, 1168, 1168, - 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1169, 0, - 0, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, - 1169, 1169, 1169, 1170, 1170, 0, 1170, 1170, 0, 0, 0, 1170, - 1171, 0, 1171, 0, 0, 1171, 1171, 1171, 1171, 1171, 0, 0, - 0, 1171, 1172, 0, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, - 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1173, 1173, 0, 1173, 1173, - 0, 0, 0, 1173, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, - 1174, 1174, 1174, 1174, - - 1174, 1174, 1174, 1174, 1174, 1175, 0, 1175, 0, 1175, 1175, 1175, - 1175, 1175, 1175, 1175, 1175, 1175, 0, 1175, 1175, 1175, 1176, 0, - 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - 1176, 1176, 1176, 1177, 0, 1177, 1177, 1177, 1177, 1177, 1177, 1177, - 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1178, 1178, 0, 0, - 1178, 1178, 1179, 0, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, - 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1180, 0, 1180, 1180, 1180, - 0, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, - 1181, 0, 1181, 1181, - - 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, - 1181, 1182, 0, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, - 1182, 1182, 1182, 1182, 1182, 1182, 1183, 1183, 1183, 1183, 1183, 1183, - 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1184, - 1184, 0, 1184, 1184, 0, 0, 0, 1184, 1185, 1185, 0, 1185, - 1185, 0, 0, 0, 1185, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1187, 1187, - 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, - 1187, 1187, 1187, 1188, - - 0, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, - 1188, 0, 1188, 1188, 1190, 1190, 0, 1190, 1190, 0, 0, 0, - 1190, 1190, 1191, 0, 1191, 1191, 1191, 1191, 1191, 1191, 1191, 1191, - 1191, 1191, 1191, 1191, 1191, 1191, 1191, 1192, 0, 1192, 1192, 1192, - 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, - 1193, 0, 1193, 1193, 1193, 1193, 1193, 1193, 1193, 1193, 1193, 1193, - 1193, 1193, 1193, 1193, 1193, 1194, 1194, 1194, 1194, 1194, 1194, 1194, - 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1195, 1195, - 1195, 1196, 1196, 0, - - 1196, 1196, 0, 0, 0, 1196, 1197, 0, 1197, 1197, 1197, 1197, - 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1198, - 0, 1198, 1198, 1198, 1198, 1198, 1198, 1198, 1198, 1198, 1198, 1198, - 1198, 1198, 1198, 1198, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, - 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1200, 1200, 1200, - 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, - 1200, 1200, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, - - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, - 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106}; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -static yy_state_type *yy_state_buf = 0, *yy_state_ptr = 0; -static char *yy_full_match; -static int yy_lp; -#define REJECT \ - { \ - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ - yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ - ++(yy_lp); \ - goto find_rule; \ - } - -static int yy_more_flag = 0; -static int yy_more_len = 0; -#define yymore() ((yy_more_flag) = 1) -#define YY_MORE_ADJ (yy_more_len) -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -/* $OpenBSD: scan.l,v 1.12 2015/11/19 23:34:56 mmcc Exp $ */ -/* scan.l - scanner for flex input -*-C-*- */ -/* 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. */ - -#include "flexdef.h" -#include "parse.h" -extern bool tablesverify, tablesext; -extern int trlcontxt; /* Set in parse.y for each rule. */ -extern const char *escaped_qstart, *escaped_qend; - -#define ACTION_ECHO add_action(yytext) -#define ACTION_IFDEF(def, should_define) \ - { \ - if (should_define) action_define(def, 1); \ - } - -#define ACTION_ECHO_QSTART add_action(escaped_qstart) -#define ACTION_ECHO_QEND add_action(escaped_qend) - -#define ACTION_M4_IFDEF(def, should_define) \ - do { \ - if (should_define) \ - buf_m4_define(&m4defs_buf, def, NULL); \ - else \ - buf_m4_undefine(&m4defs_buf, def); \ - } while (0) - -#define MARK_END_OF_PROLOG mark_prolog(); - -#define YY_DECL int flexscan() - -#define RETURNCHAR \ - yylval = (unsigned char)yytext[0]; \ - return CHAR; - -#define RETURNNAME \ - if (yyleng < MAXLINE) { \ - strlcpy(nmstr, yytext, sizeof nmstr); \ - } else { \ - synerr(_("Input line too long\n")); \ - FLEX_EXIT(EXIT_FAILURE); \ - } \ - return NAME; - -#define PUT_BACK_STRING(str, start) \ - for (i = strlen(str) - 1; i >= start; --i) unput((str)[i]) - -#define CHECK_REJECT(str) \ - if (all_upper(str)) reject = true; - -#define CHECK_YYMORE(str) \ - if (all_lower(str)) yymore_used = true; - -#define YY_USER_INIT \ - if (getenv("POSIXLY_CORRECT")) posix_compat = true; - -#define INITIAL 0 -#define SECT2 1 -#define SECT2PROLOG 2 -#define SECT3 3 -#define CODEBLOCK 4 -#define PICKUPDEF 5 -#define SC 6 -#define CARETISBOL 7 -#define NUM 8 -#define QUOTE 9 -#define FIRSTCCL 10 -#define CCL 11 -#define ACTION 12 -#define RECOVER 13 -#define COMMENT 14 -#define ACTION_STRING 15 -#define PERCENT_BRACE_ACTION 16 -#define OPTION 17 -#define LINEDIR 18 -#define CODEBLOCK_MATCH_BRACE 19 -#define GROUP_WITH_PARAMS 20 -#define GROUP_MINUS_PARAMS 21 -#define EXTENDED_COMMENT 22 -#define COMMENT_DISCARD 23 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include "libc/calls/calls.h" -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals(void); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy(void); - -int yyget_debug(void); - -void yyset_debug(int debug_flag); - -YY_EXTRA_TYPE yyget_extra(void); - -void yyset_extra(YY_EXTRA_TYPE user_defined); - -FILE *yyget_in(void); - -void yyset_in(FILE *in_str); - -FILE *yyget_out(void); - -void yyset_out(FILE *out_str); - -yy_size_t yyget_leng(void); - -char *yyget_text(void); - -int yyget_lineno(void); - -void yyset_lineno(int line_number); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap(void); -#else -extern int yywrap(void); -#endif -#endif - -static void yyunput(int c, char *buf_ptr); - -#ifndef yytext_ptr -static void yy_flex_strncpy(char *, yyconst char *, int); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen(yyconst char *); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput(void); -#else -static int input(void); -#endif - -#endif - -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = NULL; - -static void yy_push_state(int new_state); - -static void yy_pop_state(void); - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO \ - do { \ - if (fwrite(yytext, yyleng, 1, yyout)) { \ - } \ - } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) { \ - int c = '*'; \ - size_t n; \ - for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) \ - buf[n] = (char)c; \ - if (c == '\n') buf[n++] = (char)c; \ - if (c == EOF && ferror(yyin)) \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - result = n; \ - } else { \ - errno = 0; \ - while ((result = fread(buf, 1, max_size, yyin)) == 0 && ferror(yyin)) { \ - if (errno != EINTR) { \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - break; \ - } \ - errno = 0; \ - clearerr(yyin); \ - } \ - } - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error(msg) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex(void); - -#define YY_DECL int yylex(void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if (yyleng > 0) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL { - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - - if (!(yy_init)) { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - /* Create the reject buffer large enough to save one state per allowed - * character. */ - if (!(yy_state_buf)) - (yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE); - if (!(yy_state_buf)) YY_FATAL_ERROR("out of dynamic memory in yylex()"); - - if (!(yy_start)) (yy_start) = 1; /* first start state */ - - if (!yyin) yyin = stdin; - - if (!yyout) yyout = stdout; - - if (!YY_CURRENT_BUFFER) { - yyensure_buffer_stack(); - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); - } - - yy_load_buffer_state(); - } - - { - static int bracelevel, didadef, indented_code; - static int doing_rule_action = false; - static int option_sense; - - int doing_codeblock = false; - int i, brace_depth = 0, brace_start_line = 0; - u_char nmdef[MAXLINE]; - - while (1) /* loops until end-of-file is reached */ - { - (yy_more_len) = 0; - if ((yy_more_flag)) { - (yy_more_len) = (yy_c_buf_p) - (yytext_ptr); - (yy_more_flag) = 0; - } - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - - yy_match: - do { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 1107) yy_c = yy_meta[(unsigned int)yy_c]; - } - yy_current_state = - yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; - *(yy_state_ptr)++ = yy_current_state; - ++yy_cp; - } while (yy_base[yy_current_state] != 3975); - - yy_find_action: - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; - find_rule: /* we branch to this label when backing up */ - for (;;) /* until we find what rule we matched */ - { - if ((yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1]) { - yy_act = yy_acclist[(yy_lp)]; - { - (yy_full_match) = yy_cp; - break; - } - } - --yy_cp; - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - do_action: /* This label is used only to access EOF actions. */ - - switch (yy_act) { /* beginning of action switch */ - - case 1: - YY_RULE_SETUP - indented_code = true; - BEGIN(CODEBLOCK); - YY_BREAK - case 2: - YY_RULE_SETUP - ACTION_ECHO; - yy_push_state(COMMENT); - YY_BREAK - case 3: - YY_RULE_SETUP - yy_push_state(LINEDIR); - YY_BREAK - case 4: - YY_RULE_SETUP - return SCDECL; - YY_BREAK - case 5: - YY_RULE_SETUP - return XSCDECL; - YY_BREAK - case 6: - /* rule 6 can match eol */ - YY_RULE_SETUP { - ++linenum; - line_directive_out((FILE *)0, 1); - indented_code = false; - BEGIN(CODEBLOCK); - } - YY_BREAK - case 7: - /* rule 7 can match eol */ - YY_RULE_SETUP { - brace_start_line = linenum; - ++linenum; - buf_linedir(&top_buf, infilename ? infilename : "", linenum); - brace_depth = 1; - yy_push_state(CODEBLOCK_MATCH_BRACE); - } - YY_BREAK - case 8: - YY_RULE_SETUP - synerr(_("malformed '%top' directive")); - YY_BREAK - case 9: - YY_RULE_SETUP - /* discard */ - YY_BREAK - case 10: - YY_RULE_SETUP { - sectnum = 2; - bracelevel = 0; - mark_defs1(); - line_directive_out((FILE *)0, 1); - BEGIN(SECT2PROLOG); - return SECTEND; - } - YY_BREAK - case 11: - /* rule 11 can match eol */ - YY_RULE_SETUP - yytext_is_array = false; - ++linenum; - YY_BREAK - case 12: - /* rule 12 can match eol */ - YY_RULE_SETUP - yytext_is_array = true; - ++linenum; - YY_BREAK - case 13: - YY_RULE_SETUP - BEGIN(OPTION); - return OPTION_OP; - YY_BREAK - case 14: - /* rule 14 can match eol */ - YY_RULE_SETUP - ++linenum; /* ignore */ - YY_BREAK - case 15: - /* rule 15 can match eol */ - YY_RULE_SETUP - ++linenum; /* ignore */ - YY_BREAK - /* xgettext: no-c-format */ - case 16: - /* rule 16 can match eol */ - YY_RULE_SETUP - synerr(_("unrecognized '%' directive")); - YY_BREAK - case 17: - YY_RULE_SETUP { - if (yyleng < MAXLINE) { - strlcpy(nmstr, yytext, sizeof nmstr); - } else { - synerr(_("Definition name too long\n")); - FLEX_EXIT(EXIT_FAILURE); - } - - didadef = false; - BEGIN(PICKUPDEF); - } - YY_BREAK - case 18: - YY_RULE_SETUP - RETURNNAME; - YY_BREAK - case 19: - /* rule 19 can match eol */ - YY_RULE_SETUP - ++linenum; /* allows blank lines in section 1 */ - YY_BREAK - case 20: - /* rule 20 can match eol */ - YY_RULE_SETUP - ACTION_ECHO; - ++linenum; /* maybe end of comment line */ - YY_BREAK - - case 21: - YY_RULE_SETUP - ACTION_ECHO; - yy_pop_state(); - YY_BREAK - case 22: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 23: - YY_RULE_SETUP - ACTION_ECHO_QSTART; - YY_BREAK - case 24: - YY_RULE_SETUP - ACTION_ECHO_QEND; - YY_BREAK - case 25: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 26: - /* rule 26 can match eol */ - YY_RULE_SETUP - ++linenum; - ACTION_ECHO; - YY_BREAK - - /* This is the same as COMMENT, but is discarded rather than output. */ - case 27: - YY_RULE_SETUP - yy_pop_state(); - YY_BREAK - case 28: - YY_RULE_SETUP; - YY_BREAK - case 29: - YY_RULE_SETUP; - YY_BREAK - case 30: - /* rule 30 can match eol */ - YY_RULE_SETUP - ++linenum; - YY_BREAK - - case 31: - YY_RULE_SETUP - yy_pop_state(); - YY_BREAK - case 32: - YY_RULE_SETUP; - YY_BREAK - case 33: - /* rule 33 can match eol */ - YY_RULE_SETUP - ++linenum; - YY_BREAK - - case 34: - /* rule 34 can match eol */ - YY_RULE_SETUP - yy_pop_state(); - YY_BREAK - case 35: - YY_RULE_SETUP - linenum = myctoi(yytext); - YY_BREAK - case 36: - YY_RULE_SETUP { - free((void *)infilename); - infilename = copy_string(yytext + 1); - infilename[strlen(infilename) - 1] = '\0'; - } - YY_BREAK - case 37: - YY_RULE_SETUP - /* ignore spurious characters */ - YY_BREAK - - case 38: - /* rule 38 can match eol */ - YY_RULE_SETUP - ++linenum; - BEGIN(INITIAL); - YY_BREAK - case 39: - YY_RULE_SETUP - ACTION_ECHO_QSTART; - YY_BREAK - case 40: - YY_RULE_SETUP - ACTION_ECHO_QEND; - YY_BREAK - case 41: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 42: - /* rule 42 can match eol */ - YY_RULE_SETUP { - ++linenum; - ACTION_ECHO; - if (indented_code) BEGIN(INITIAL); - } - YY_BREAK - - case 43: - YY_RULE_SETUP { - if (--brace_depth == 0) { - /* TODO: Matched. */ - yy_pop_state(); - } else - buf_strnappend(&top_buf, yytext, yyleng); - } - YY_BREAK - case 44: - YY_RULE_SETUP { - brace_depth++; - buf_strnappend(&top_buf, yytext, yyleng); - } - YY_BREAK - case 45: - /* rule 45 can match eol */ - YY_RULE_SETUP { - ++linenum; - buf_strnappend(&top_buf, yytext, yyleng); - } - YY_BREAK - case 46: - YY_RULE_SETUP - buf_strnappend(&top_buf, escaped_qstart, strlen(escaped_qstart)); - YY_BREAK - case 47: - YY_RULE_SETUP - buf_strnappend(&top_buf, escaped_qend, strlen(escaped_qend)); - YY_BREAK - case 48: - YY_RULE_SETUP { buf_strnappend(&top_buf, yytext, yyleng); } - YY_BREAK - case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE): { - linenum = brace_start_line; - synerr(_("Unmatched '{'")); - yyterminate(); - } - YY_BREAK - - case 49: - YY_RULE_SETUP - /* separates name and definition */ - YY_BREAK - case 50: - YY_RULE_SETUP { - if (yyleng < MAXLINE) { - strlcpy((char *)nmdef, yytext, sizeof nmdef); - } else { - format_synerr(_("Definition value for {%s} too long\n"), nmstr); - FLEX_EXIT(EXIT_FAILURE); - } - /* Skip trailing whitespace. */ - for (i = strlen((char *)nmdef) - 1; - i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t'); --i) - ; - - nmdef[i + 1] = '\0'; - - ndinstal(nmstr, nmdef); - didadef = true; - } - YY_BREAK - case 51: - /* rule 51 can match eol */ - YY_RULE_SETUP { - if (!didadef) synerr(_("incomplete name definition")); - BEGIN(INITIAL); - ++linenum; - } - YY_BREAK - - case 52: - /* rule 52 can match eol */ - YY_RULE_SETUP - ++linenum; - BEGIN(INITIAL); - YY_BREAK - case 53: - YY_RULE_SETUP - option_sense = true; - YY_BREAK - case 54: - YY_RULE_SETUP - return '='; - YY_BREAK - case 55: - YY_RULE_SETUP - option_sense = !option_sense; - YY_BREAK - case 56: - YY_RULE_SETUP - csize = option_sense ? 128 : 256; - YY_BREAK - case 57: - YY_RULE_SETUP - csize = option_sense ? 256 : 128; - YY_BREAK - case 58: - YY_RULE_SETUP - long_align = option_sense; - YY_BREAK - case 59: - YY_RULE_SETUP { - ACTION_M4_IFDEF( - "M4" - "_YY_ALWAYS_INTERACTIVE", - option_sense); - interactive = option_sense; - } - YY_BREAK - case 60: - YY_RULE_SETUP - yytext_is_array = option_sense; - YY_BREAK - case 61: - YY_RULE_SETUP - ansi_func_defs = option_sense; - YY_BREAK - case 62: - YY_RULE_SETUP - ansi_func_protos = option_sense; - YY_BREAK - case 63: - YY_RULE_SETUP - backing_up_report = option_sense; - YY_BREAK - case 64: - YY_RULE_SETUP - interactive = !option_sense; - YY_BREAK - case 65: - YY_RULE_SETUP - bison_bridge_lval = option_sense; - YY_BREAK - case 66: - YY_RULE_SETUP { - if ((bison_bridge_lloc = option_sense)) bison_bridge_lval = true; - } - YY_BREAK - case 67: - YY_RULE_SETUP - C_plus_plus = option_sense; - YY_BREAK - case 68: - YY_RULE_SETUP - sf_set_case_ins(!option_sense); - YY_BREAK - case 69: - YY_RULE_SETUP - sf_set_case_ins(option_sense); - YY_BREAK - case 70: - YY_RULE_SETUP - ddebug = option_sense; - YY_BREAK - case 71: - YY_RULE_SETUP - spprdflt = !option_sense; - YY_BREAK - case 72: - YY_RULE_SETUP - useecs = option_sense; - YY_BREAK - case 73: - YY_RULE_SETUP { - useecs = usemecs = false; - use_read = fullspd = true; - } - YY_BREAK - case 74: - YY_RULE_SETUP { - useecs = usemecs = false; - use_read = fulltbl = true; - } - YY_BREAK - case 75: - YY_RULE_SETUP - ACTION_IFDEF("YY_NO_INPUT", !option_sense); - YY_BREAK - case 76: - YY_RULE_SETUP - interactive = option_sense; - YY_BREAK - case 77: - YY_RULE_SETUP - lex_compat = option_sense; - YY_BREAK - case 78: - YY_RULE_SETUP - posix_compat = option_sense; - YY_BREAK - case 79: - YY_RULE_SETUP { - ACTION_M4_IFDEF( - "M4" - "_YY_MAIN", - option_sense); - /* Override yywrap */ - if (option_sense == true) do_yywrap = false; - } - YY_BREAK - case 80: - YY_RULE_SETUP - usemecs = option_sense; - YY_BREAK - case 81: - YY_RULE_SETUP { - ACTION_M4_IFDEF( - "M4" - "_YY_NEVER_INTERACTIVE", - option_sense); - interactive = !option_sense; - } - YY_BREAK - case 82: - YY_RULE_SETUP - performance_report += option_sense ? 1 : -1; - YY_BREAK - case 83: - YY_RULE_SETUP - yytext_is_array = !option_sense; - YY_BREAK - case 84: - YY_RULE_SETUP - use_read = option_sense; - YY_BREAK - case 85: - YY_RULE_SETUP - reentrant = option_sense; - YY_BREAK - case 86: - YY_RULE_SETUP - reject_really_used = option_sense; - YY_BREAK - case 87: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_STACK_USED", - option_sense); - YY_BREAK - case 88: - YY_RULE_SETUP - do_stdinit = option_sense; - YY_BREAK - case 89: - YY_RULE_SETUP - use_stdout = option_sense; - YY_BREAK - case 90: - YY_RULE_SETUP - ACTION_IFDEF("YY_NO_UNISTD_H", !option_sense); - YY_BREAK - case 91: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_UNPUT", - !option_sense); - YY_BREAK - case 92: - YY_RULE_SETUP - printstats = option_sense; - YY_BREAK - case 93: - YY_RULE_SETUP - nowarn = !option_sense; - YY_BREAK - case 94: - YY_RULE_SETUP - do_yylineno = option_sense; - ACTION_M4_IFDEF( - "M4" - "_YY_USE_LINENO", - option_sense); - YY_BREAK - case 95: - YY_RULE_SETUP - yymore_really_used = option_sense; - YY_BREAK - case 96: - YY_RULE_SETUP - do_yywrap = option_sense; - YY_BREAK - case 97: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_PUSH_STATE", - !option_sense); - YY_BREAK - case 98: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_POP_STATE", - !option_sense); - YY_BREAK - case 99: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_TOP_STATE", - !option_sense); - YY_BREAK - case 100: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SCAN_BUFFER", - !option_sense); - YY_BREAK - case 101: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SCAN_BYTES", - !option_sense); - YY_BREAK - case 102: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SCAN_STRING", - !option_sense); - YY_BREAK - case 103: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_FLEX_ALLOC", - !option_sense); - YY_BREAK - case 104: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_FLEX_REALLOC", - !option_sense); - YY_BREAK - case 105: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_FLEX_FREE", - !option_sense); - YY_BREAK - case 106: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_DEBUG", - !option_sense); - YY_BREAK - case 107: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_DEBUG", - !option_sense); - YY_BREAK - case 108: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_EXTRA", - !option_sense); - YY_BREAK - case 109: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_EXTRA", - !option_sense); - YY_BREAK - case 110: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_LENG", - !option_sense); - YY_BREAK - case 111: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_TEXT", - !option_sense); - YY_BREAK - case 112: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_LINENO", - !option_sense); - YY_BREAK - case 113: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_LINENO", - !option_sense); - YY_BREAK - case 114: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_IN", - !option_sense); - YY_BREAK - case 115: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_IN", - !option_sense); - YY_BREAK - case 116: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_OUT", - !option_sense); - YY_BREAK - case 117: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_OUT", - !option_sense); - YY_BREAK - case 118: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_LVAL", - !option_sense); - YY_BREAK - case 119: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_LVAL", - !option_sense); - YY_BREAK - case 120: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_GET_LLOC", - !option_sense); - YY_BREAK - case 121: - YY_RULE_SETUP - ACTION_M4_IFDEF( - "M4" - "_YY_NO_SET_LLOC", - !option_sense); - YY_BREAK - case 122: - YY_RULE_SETUP - return OPT_EXTRA_TYPE; - YY_BREAK - case 123: - YY_RULE_SETUP - return OPT_OUTFILE; - YY_BREAK - case 124: - YY_RULE_SETUP - return OPT_PREFIX; - YY_BREAK - case 125: - YY_RULE_SETUP - return OPT_YYCLASS; - YY_BREAK - case 126: - YY_RULE_SETUP - return OPT_HEADER; - YY_BREAK - case 127: - YY_RULE_SETUP - return OPT_TABLES; - YY_BREAK - case 128: - YY_RULE_SETUP { - tablesverify = option_sense; - if (!tablesext && option_sense) tablesext = true; - } - YY_BREAK - case 129: - YY_RULE_SETUP { - if (yyleng - 1 < MAXLINE) { - strlcpy(nmstr, yytext + 1, sizeof nmstr); - } else { - synerr(_("Option line too long\n")); - FLEX_EXIT(EXIT_FAILURE); - } - if (nmstr[strlen(nmstr) - 1] == '"') - nmstr[strlen(nmstr) - 1] = '\0'; - return NAME; - } - YY_BREAK - case 130: - YY_RULE_SETUP { - format_synerr(_("unrecognized %%option: %s"), yytext); - BEGIN(RECOVER); - } - YY_BREAK - - case 131: - /* rule 131 can match eol */ - YY_RULE_SETUP - ++linenum; - BEGIN(INITIAL); - YY_BREAK - - case 132: - YY_RULE_SETUP - ++bracelevel; - yyless(2); /* eat only %{ */ - YY_BREAK - case 133: - YY_RULE_SETUP - --bracelevel; - yyless(2); /* eat only %} */ - YY_BREAK - case 134: - YY_RULE_SETUP - ACTION_ECHO; /* indented code in prolog */ - YY_BREAK - case 135: - YY_RULE_SETUP { /* non-indented code */ - if (bracelevel <= 0) { /* not in %{ ... %} */ - yyless(0); /* put it all back */ - yy_set_bol(1); - mark_prolog(); - BEGIN(SECT2); - } else - ACTION_ECHO; - } - YY_BREAK - case 136: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 137: - /* rule 137 can match eol */ - YY_RULE_SETUP - ++linenum; - ACTION_ECHO; - YY_BREAK - case YY_STATE_EOF(SECT2PROLOG): { - mark_prolog(); - sectnum = 0; - yyterminate(); /* to stop the parser */ - } - YY_BREAK - - case 138: - /* rule 138 can match eol */ - YY_RULE_SETUP - ++linenum; /* allow blank lines in section 2 */ - YY_BREAK - case 139: - YY_RULE_SETUP { - indented_code = false; - doing_codeblock = true; - bracelevel = 1; - BEGIN(PERCENT_BRACE_ACTION); - } - YY_BREAK - case 140: - YY_RULE_SETUP { - /* Allow "<" to appear in (?x) patterns. */ - if (!sf_skip_ws()) BEGIN(SC); - return '<'; - } - YY_BREAK - case 141: - YY_RULE_SETUP - return '^'; - YY_BREAK - case 142: - YY_RULE_SETUP - BEGIN(QUOTE); - return '"'; - YY_BREAK - case 143: - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ - (yy_c_buf_p) = yy_cp = yy_bp + 1; - YY_DO_BEFORE_ACTION; /* set up yytext again */ - YY_RULE_SETUP { - BEGIN(NUM); - if (lex_compat || posix_compat) - return BEGIN_REPEAT_POSIX; - else - return BEGIN_REPEAT_FLEX; - } - YY_BREAK - case 144: - /* rule 144 can match eol */ - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ - YY_LINENO_REWIND_TO(yy_bp + 1); - (yy_c_buf_p) = yy_cp = yy_bp + 1; - YY_DO_BEFORE_ACTION; /* set up yytext again */ - YY_RULE_SETUP - return '$'; - YY_BREAK - case 145: - YY_RULE_SETUP { - bracelevel = 1; - BEGIN(PERCENT_BRACE_ACTION); - - if (in_rule) { - doing_rule_action = true; - in_rule = false; - return '\n'; - } - } - YY_BREAK - case 146: - /* rule 146 can match eol */ - YY_RULE_SETUP { - if (sf_skip_ws()) { - /* We're in the middle of a (?x: ) pattern. */ - /* Push back everything starting at the "|" */ - size_t amt; - amt = strchr(yytext, '|') - yytext; - yyless(amt); - } else { - continued_action = true; - ++linenum; - return '\n'; - } - } - YY_BREAK - case 147: - YY_RULE_SETUP { - if (sf_skip_ws()) { - /* We're in the middle of a (?x: ) pattern. */ - yy_push_state(COMMENT_DISCARD); - } else { - yyless(yyleng - 2); /* put back '/', '*' */ - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - } - } - YY_BREAK - case 148: - YY_RULE_SETUP - /* allow indented rules */; - YY_BREAK - case 149: - YY_RULE_SETUP { - if (sf_skip_ws()) { - /* We're in the middle of a (?x: ) pattern. */ - } else { - /* This rule is separate from the one below because - * otherwise we get variable trailing context, so - * we can't build the scanner using -{f,F}. - */ - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - - if (in_rule) { - doing_rule_action = true; - in_rule = false; - return '\n'; - } - } - } - YY_BREAK - case 150: - /* rule 150 can match eol */ - YY_RULE_SETUP { - if (sf_skip_ws()) { - /* We're in the middle of a (?x: ) pattern. */ - ++linenum; - } else { - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - unput('\n'); /* so sees it */ - - if (in_rule) { - doing_rule_action = true; - in_rule = false; - return '\n'; - } - } - } - YY_BREAK - case 151: - case 152: - YY_RULE_SETUP - return EOF_OP; - YY_BREAK - case 153: - YY_RULE_SETUP { - sectnum = 3; - BEGIN(SECT3); - outn("/* Begin user sect3 */"); - yyterminate(); /* to stop the parser */ - } - YY_BREAK - case 154: - YY_RULE_SETUP { - int cclval; - - if (yyleng < MAXLINE) { - strlcpy(nmstr, yytext, sizeof nmstr); - } else { - synerr(_("Input line too long\n")); - FLEX_EXIT(EXIT_FAILURE); - } - - /* Check to see if we've already encountered this - * ccl. - */ - if (0 /* <--- This "0" effectively disables the reuse of a - * character class (purely based on its source text). - * The reason it was disabled is so yacc/bison can parse - * ccl operations, such as ccl difference and union. - */ - && (cclval = ccllookup((u_char *)nmstr)) != 0) { - if (input() != ']') synerr(_("bad character class")); - - yylval = cclval; - ++cclreuse; - return PREVCCL; - } else { - /* We fudge a bit. We know that this ccl will - * soon be numbered as lastccl + 1 by cclinit. - */ - cclinstal((u_char *)nmstr, lastccl + 1); - - /* Push back everything but the leading bracket - * so the ccl can be rescanned. - */ - yyless(1); - - BEGIN(FIRSTCCL); - return '['; - } - } - YY_BREAK - case 155: - YY_RULE_SETUP - return CCL_OP_DIFF; - YY_BREAK - case 156: - YY_RULE_SETUP - return CCL_OP_UNION; - YY_BREAK - /* Check for :space: at the end of the rule so we don't - * wrap the expanded regex in '(' ')' -- breaking trailing - * context. - */ - case 157: - /* rule 157 can match eol */ - YY_RULE_SETUP { - u_char *nmdefptr; - int end_is_ws, end_ch; - - end_ch = yytext[yyleng - 1]; - end_is_ws = end_ch != '}' ? 1 : 0; - - if (yyleng - 1 < MAXLINE) { - strlcpy(nmstr, yytext + 1, sizeof nmstr); - } else { - synerr(_("Input line too long\n")); - FLEX_EXIT(EXIT_FAILURE); - } - nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ - - if ((nmdefptr = ndlookup(nmstr)) == 0) - format_synerr(_("undefined definition {%s}"), nmstr); - - else { /* push back name surrounded by ()'s */ - int len = strlen((char *)nmdefptr); - if (end_is_ws) unput(end_ch); - - if (lex_compat || nmdefptr[0] == '^' || - (len > 0 && nmdefptr[len - 1] == '$') || - (end_is_ws && trlcontxt && - !sf_skip_ws())) { /* don't use ()'s after all */ - PUT_BACK_STRING((char *)nmdefptr, 0); - - if (nmdefptr[0] == '^') BEGIN(CARETISBOL); - } - - else { - unput(')'); - PUT_BACK_STRING((char *)nmdefptr, 0); - unput('('); - } - } - } - YY_BREAK - case 158: - YY_RULE_SETUP { - if (sf_skip_ws()) - yy_push_state(COMMENT_DISCARD); - else { - /* Push back the "*" and return "/" as usual. */ - yyless(1); - return '/'; - } - } - YY_BREAK - case 159: - YY_RULE_SETUP { - if (lex_compat || posix_compat) { - /* Push back the "?#" and treat it like a normal parens. */ - yyless(1); - sf_push(); - return '('; - } else - yy_push_state(EXTENDED_COMMENT); - } - YY_BREAK - case 160: - YY_RULE_SETUP { - sf_push(); - if (lex_compat || posix_compat) - /* Push back the "?" and treat it like a normal parens. */ - yyless(1); - else - BEGIN(GROUP_WITH_PARAMS); - return '('; - } - YY_BREAK - case 161: - YY_RULE_SETUP - sf_push(); - return '('; - YY_BREAK - case 162: - YY_RULE_SETUP - sf_pop(); - return ')'; - YY_BREAK - case 163: - YY_RULE_SETUP - return (unsigned char)yytext[0]; - YY_BREAK - case 164: - YY_RULE_SETUP - RETURNCHAR; - YY_BREAK - - case 165: - /* rule 165 can match eol */ - YY_RULE_SETUP - ++linenum; /* Allow blank lines & continuations */ - YY_BREAK - case 166: - YY_RULE_SETUP - return (unsigned char)yytext[0]; - YY_BREAK - case 167: - YY_RULE_SETUP - BEGIN(SECT2); - return '>'; - YY_BREAK - case 168: - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ - (yy_c_buf_p) = yy_cp = yy_bp + 1; - YY_DO_BEFORE_ACTION; /* set up yytext again */ - YY_RULE_SETUP - BEGIN(CARETISBOL); - return '>'; - YY_BREAK - case 169: - YY_RULE_SETUP - RETURNNAME; - YY_BREAK - case 170: - YY_RULE_SETUP { - format_synerr(_("bad : %s"), yytext); - } - YY_BREAK - - case 171: - YY_RULE_SETUP - BEGIN(SECT2); - return '^'; - YY_BREAK - - case 172: - YY_RULE_SETUP - RETURNCHAR; - YY_BREAK - case 173: - YY_RULE_SETUP - BEGIN(SECT2); - return '"'; - YY_BREAK - case 174: - /* rule 174 can match eol */ - YY_RULE_SETUP { - synerr(_("missing quote")); - BEGIN(SECT2); - ++linenum; - return '"'; - } - YY_BREAK - - case 175: - YY_RULE_SETUP - BEGIN(SECT2); - YY_BREAK - case 176: - YY_RULE_SETUP - BEGIN(GROUP_MINUS_PARAMS); - YY_BREAK - case 177: - YY_RULE_SETUP - sf_set_case_ins(1); - YY_BREAK - case 178: - YY_RULE_SETUP - sf_set_dot_all(1); - YY_BREAK - case 179: - YY_RULE_SETUP - sf_set_skip_ws(1); - YY_BREAK - - case 180: - YY_RULE_SETUP - BEGIN(SECT2); - YY_BREAK - case 181: - YY_RULE_SETUP - sf_set_case_ins(0); - YY_BREAK - case 182: - YY_RULE_SETUP - sf_set_dot_all(0); - YY_BREAK - case 183: - YY_RULE_SETUP - sf_set_skip_ws(0); - YY_BREAK - - case 184: - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ - (yy_c_buf_p) = yy_cp = yy_bp + 1; - YY_DO_BEFORE_ACTION; /* set up yytext again */ - YY_RULE_SETUP - BEGIN(CCL); - return '^'; - YY_BREAK - case 185: - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ - (yy_c_buf_p) = yy_cp = yy_bp + 1; - YY_DO_BEFORE_ACTION; /* set up yytext again */ - YY_RULE_SETUP - return '^'; - YY_BREAK - case 186: - YY_RULE_SETUP - BEGIN(CCL); - RETURNCHAR; - YY_BREAK - - case 187: - *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ - (yy_c_buf_p) = yy_cp = yy_bp + 1; - YY_DO_BEFORE_ACTION; /* set up yytext again */ - YY_RULE_SETUP - return '-'; - YY_BREAK - case 188: - YY_RULE_SETUP - RETURNCHAR; - YY_BREAK - case 189: - YY_RULE_SETUP - BEGIN(SECT2); - return ']'; - YY_BREAK - case 190: - /* rule 190 can match eol */ - YY_RULE_SETUP { - synerr(_("bad character class")); - BEGIN(SECT2); - return ']'; - } - YY_BREAK - - case 191: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_ALNUM; - YY_BREAK - case 192: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_ALPHA; - YY_BREAK - case 193: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_BLANK; - YY_BREAK - case 194: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_CNTRL; - YY_BREAK - case 195: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_DIGIT; - YY_BREAK - case 196: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_GRAPH; - YY_BREAK - case 197: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_LOWER; - YY_BREAK - case 198: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_PRINT; - YY_BREAK - case 199: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_PUNCT; - YY_BREAK - case 200: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_SPACE; - YY_BREAK - case 201: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_UPPER; - YY_BREAK - case 202: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_XDIGIT; - YY_BREAK - case 203: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_ALNUM; - YY_BREAK - case 204: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_ALPHA; - YY_BREAK - case 205: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_BLANK; - YY_BREAK - case 206: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_CNTRL; - YY_BREAK - case 207: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_DIGIT; - YY_BREAK - case 208: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_GRAPH; - YY_BREAK - case 209: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_LOWER; - YY_BREAK - case 210: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_PRINT; - YY_BREAK - case 211: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_PUNCT; - YY_BREAK - case 212: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_SPACE; - YY_BREAK - case 213: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_UPPER; - YY_BREAK - case 214: - YY_RULE_SETUP - BEGIN(CCL); - return CCE_NEG_XDIGIT; - YY_BREAK - case 215: - YY_RULE_SETUP { - format_synerr(_("bad character class expression: %s"), yytext); - BEGIN(CCL); - return CCE_ALNUM; - } - YY_BREAK - - case 216: - YY_RULE_SETUP { - yylval = myctoi(yytext); - return NUMBER; - } - YY_BREAK - case 217: - YY_RULE_SETUP - return ','; - YY_BREAK - case 218: - YY_RULE_SETUP { - BEGIN(SECT2); - if (lex_compat || posix_compat) - return END_REPEAT_POSIX; - else - return END_REPEAT_FLEX; - } - YY_BREAK - case 219: - YY_RULE_SETUP { - synerr(_("bad character inside {}'s")); - BEGIN(SECT2); - return '}'; - } - YY_BREAK - case 220: - /* rule 220 can match eol */ - YY_RULE_SETUP { - synerr(_("missing }")); - BEGIN(SECT2); - ++linenum; - return '}'; - } - YY_BREAK - - case 221: - YY_RULE_SETUP - bracelevel = 0; - YY_BREAK - case 222: - YY_RULE_SETUP - ACTION_ECHO; - yy_push_state(COMMENT); - YY_BREAK - - case 223: - YY_RULE_SETUP { - ACTION_ECHO; - CHECK_REJECT(yytext); - } - YY_BREAK - case 224: - YY_RULE_SETUP { - ACTION_ECHO; - CHECK_YYMORE(yytext); - } - YY_BREAK - - case 225: - YY_RULE_SETUP - ACTION_ECHO_QSTART; - YY_BREAK - case 226: - YY_RULE_SETUP - ACTION_ECHO_QEND; - YY_BREAK - case 227: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 228: - /* rule 228 can match eol */ - YY_RULE_SETUP { - ++linenum; - ACTION_ECHO; - if (bracelevel == 0 || (doing_codeblock && indented_code)) { - if (doing_rule_action) add_action("\tYY_BREAK\n"); - - doing_rule_action = doing_codeblock = false; - BEGIN(SECT2); - } - } - YY_BREAK - - /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION - */ - - case 229: - YY_RULE_SETUP - ACTION_ECHO; - ++bracelevel; - YY_BREAK - case 230: - YY_RULE_SETUP - ACTION_ECHO; - --bracelevel; - YY_BREAK - case 231: - YY_RULE_SETUP - ACTION_ECHO_QSTART; - YY_BREAK - case 232: - YY_RULE_SETUP - ACTION_ECHO_QEND; - YY_BREAK - case 233: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 234: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 235: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 236: - YY_RULE_SETUP - ACTION_ECHO; /* character constant */ - YY_BREAK - case 237: - YY_RULE_SETUP - ACTION_ECHO; - BEGIN(ACTION_STRING); - YY_BREAK - case 238: - /* rule 238 can match eol */ - YY_RULE_SETUP { - ++linenum; - ACTION_ECHO; - if (bracelevel == 0) { - if (doing_rule_action) add_action("\tYY_BREAK\n"); - - doing_rule_action = false; - BEGIN(SECT2); - } - } - YY_BREAK - case 239: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - - case 240: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 241: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - case 242: - /* rule 242 can match eol */ - YY_RULE_SETUP - ++linenum; - ACTION_ECHO; - BEGIN(ACTION); - YY_BREAK - case 243: - YY_RULE_SETUP - ACTION_ECHO; - BEGIN(ACTION); - YY_BREAK - case 244: - YY_RULE_SETUP - ACTION_ECHO; - YY_BREAK - - case YY_STATE_EOF(COMMENT): - case YY_STATE_EOF(COMMENT_DISCARD): - case YY_STATE_EOF(ACTION): - case YY_STATE_EOF(ACTION_STRING): { - synerr(_("EOF encountered inside an action")); - yyterminate(); - } - YY_BREAK - case YY_STATE_EOF(EXTENDED_COMMENT): - case YY_STATE_EOF(GROUP_WITH_PARAMS): - case YY_STATE_EOF(GROUP_MINUS_PARAMS): { - synerr(_("EOF encountered inside pattern")); - yyterminate(); - } - YY_BREAK - case 245: - YY_RULE_SETUP { - yylval = myesc((u_char *)yytext); - - if (YY_START == FIRSTCCL) BEGIN(CCL); - - return CHAR; - } - YY_BREAK - - case 246: - YY_RULE_SETUP - fwrite(escaped_qstart, 1, strlen(escaped_qstart), yyout); - YY_BREAK - case 247: - YY_RULE_SETUP - fwrite(escaped_qend, 1, strlen(escaped_qend), yyout); - YY_BREAK - case 248: - /* rule 248 can match eol */ - YY_RULE_SETUP - ECHO; - YY_BREAK - case 249: - /* rule 249 can match eol */ - YY_RULE_SETUP - ECHO; - YY_BREAK - case YY_STATE_EOF(SECT3): - sectnum = 0; - yyterminate(); - YY_BREAK - - case 250: - /* rule 250 can match eol */ - YY_RULE_SETUP - format_synerr(_("bad character: %s"), yytext); - YY_BREAK - case 251: - YY_RULE_SETUP - YY_FATAL_ERROR("flex scanner jammed"); - YY_BREAK - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(SECT2): - case YY_STATE_EOF(CODEBLOCK): - case YY_STATE_EOF(PICKUPDEF): - case YY_STATE_EOF(SC): - case YY_STATE_EOF(CARETISBOL): - case YY_STATE_EOF(NUM): - case YY_STATE_EOF(QUOTE): - case YY_STATE_EOF(FIRSTCCL): - case YY_STATE_EOF(CCL): - case YY_STATE_EOF(RECOVER): - case YY_STATE_EOF(PERCENT_BRACE_ACTION): - case YY_STATE_EOF(OPTION): - case YY_STATE_EOF(LINEDIR): - yyterminate(); - - case YY_END_OF_BUFFER: { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int)(yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW) { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ((yy_c_buf_p) <= - &YY_CURRENT_BUFFER_LVALUE - ->yy_ch_buf[(yy_n_chars)]) { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans(yy_current_state); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if (yy_next_state) { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else { - switch (yy_get_next_buffer()) { - case EOB_ACT_END_OF_FILE: { - (yy_did_buffer_switch_on_eof) = 0; - - if (yywrap()) { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else { - if (!(yy_did_buffer_switch_on_eof)) YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - } - break; - } - - default: - YY_FATAL_ERROR("fatal flex scanner internal error--no action found"); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer(void) { - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - int number_to_move, i; - int ret_val; - - if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1]) - YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed"); - - if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == - 0) { /* Don't try to fill the buffer, so this is an EOF. */ - if ((yy_c_buf_p) - (yytext_ptr)-YY_MORE_ADJ == 1) { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int)((yy_c_buf_p) - (yytext_ptr)) - 1; - - for (i = 0; i < number_to_move; ++i) *(dest++) = *(source++); - - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( - "input buffer overflow, can't enlarge buffer because scanner uses " - "REJECT"); - } - - if (num_to_read > YY_READ_BUF_SIZE) num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ((yy_n_chars) == 0) { - if (number_to_move == YY_MORE_ADJ) { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin); - } - - else { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t)((yy_n_chars) + number_to_move) > - YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *)yyrealloc( - (void *)YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size); - if (!YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()"); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int)(new_size - 2); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state(void) { - yy_state_type yy_current_state; - char *yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - - for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 1107) yy_c = yy_meta[(unsigned int)yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; - *(yy_state_ptr)++ = yy_current_state; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ -static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state) { - int yy_is_jam; - - YY_CHAR yy_c = 1; - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 1107) yy_c = yy_meta[(unsigned int)yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; - yy_is_jam = (yy_current_state == 1106); - if (!yy_is_jam) *(yy_state_ptr)++ = yy_current_state; - - return yy_is_jam ? 0 : yy_current_state; -} - -static void yyunput(int c, char *yy_bp) { - char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + - 2) { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - yy_size_t number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE - ->yy_ch_buf[YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while (source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) *--dest = *--source; - - yy_cp += (int)(dest - source); - yy_bp += (int)(dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2) - YY_FATAL_ERROR("flex scanner push-back overflow"); - } - - *--yy_cp = (char)c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput(void) -#else -static int input(void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if (*(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR) { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ((yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch (yy_get_next_buffer()) { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: { - if (yywrap()) return EOF; - - if (!(yy_did_buffer_switch_on_eof)) YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *)(yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ -void yyrestart(FILE *input_file) { - if (!YY_CURRENT_BUFFER) { - yyensure_buffer_stack(); - YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); - } - - yy_init_buffer(YY_CURRENT_BUFFER, input_file); - yy_load_buffer_state(); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ -void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) { - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack(); - if (YY_CURRENT_BUFFER == new_buffer) return; - - if (YY_CURRENT_BUFFER) { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state(void) { - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c - * YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ -YY_BUFFER_STATE yy_create_buffer(FILE *file, int size) { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state)); - if (!b) YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()"); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *)yyalloc(b->yy_buf_size + 2); - if (!b->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()"); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b, file); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ -void yy_delete_buffer(YY_BUFFER_STATE b) { - if (!b) return; - - if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE)0; - - if (b->yy_is_our_buffer) yyfree((void *)b->yy_ch_buf); - - yyfree((void *)b); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file) - -{ - int oerrno = errno; - - yy_flush_buffer(b); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER) { - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ -void yy_flush_buffer(YY_BUFFER_STATE b) { - if (!b) return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if (b == YY_CURRENT_BUFFER) yy_load_buffer_state(); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state(YY_BUFFER_STATE new_buffer) { - if (new_buffer == NULL) return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if (YY_CURRENT_BUFFER) { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state(); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state(void) { - if (!YY_CURRENT_BUFFER) return; - - yy_delete_buffer(YY_CURRENT_BUFFER); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state(); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack(void) { - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state **)yyalloc( - num_to_alloc * sizeof(struct yy_buffer_state *)); - if (!(yy_buffer_stack)) - YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - - memset((yy_buffer_stack), 0, - num_to_alloc * sizeof(struct yy_buffer_state *)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) { - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state **)yyrealloc( - (yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state *)); - if (!(yy_buffer_stack)) - YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, - grow_size * sizeof(struct yy_buffer_state *)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified - * character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size) { - YY_BUFFER_STATE b; - - if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR || - base[size - 1] != YY_END_OF_BUFFER_CHAR) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state)); - if (!b) YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()"); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string(yyconst char *yystr) { - return yy_scan_bytes(yystr, strlen(yystr)); -} - -/** Setup the input buffer state to scan the given bytes. The next call to - * yylex() will scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes(yyconst char *yybytes, yy_size_t _yybytes_len) { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *)yyalloc(n); - if (!buf) YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()"); - - for (i = 0; i < _yybytes_len; ++i) buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf, n); - if (!b) YY_FATAL_ERROR("bad buffer in yy_scan_bytes()"); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -static void yy_push_state(int new_state) { - if ((yy_start_stack_ptr) >= (yy_start_stack_depth)) { - yy_size_t new_size; - - (yy_start_stack_depth) += YY_START_STACK_INCR; - new_size = (yy_start_stack_depth) * sizeof(int); - - if (!(yy_start_stack)) - (yy_start_stack) = (int *)yyalloc(new_size); - - else - (yy_start_stack) = (int *)yyrealloc((void *)(yy_start_stack), new_size); - - if (!(yy_start_stack)) - YY_FATAL_ERROR("out of memory expanding start-condition stack"); - } - - (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; - - BEGIN(new_state); -} - -static void yy_pop_state(void) { - if (--(yy_start_stack_ptr) < 0) - YY_FATAL_ERROR("start-condition stack underflow"); - - BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error(yyconst char *msg) { - (void)fprintf(stderr, "%s\n", msg); - exit(YY_EXIT_FAILURE); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } while (0) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno(void) { return yylineno; } - -/** Get the input stream. - * - */ -FILE *yyget_in(void) { return yyin; } - -/** Get the output stream. - * - */ -FILE *yyget_out(void) { return yyout; } - -/** Get the length of the current token. - * - */ -yy_size_t yyget_leng(void) { return yyleng; } - -/** Get the current token. - * - */ - -char *yyget_text(void) { return yytext; } - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno(int line_number) { yylineno = line_number; } - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in(FILE *in_str) { yyin = in_str; } - -void yyset_out(FILE *out_str) { yyout = out_str; } - -int yyget_debug(void) { return yy_flex_debug; } - -void yyset_debug(int bdebug) { yy_flex_debug = bdebug; } - -static int yy_init_globals(void) { - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *)0; - (yy_init) = 0; - (yy_start) = 0; - - (yy_start_stack_ptr) = 0; - (yy_start_stack_depth) = 0; - (yy_start_stack) = NULL; - - (yy_state_buf) = 0; - (yy_state_ptr) = 0; - (yy_full_match) = 0; - (yy_lp) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *)0; - yyout = (FILE *)0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy(void) { - /* Pop the buffer stack, destroying each element. */ - while (YY_CURRENT_BUFFER) { - yy_delete_buffer(YY_CURRENT_BUFFER); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack)); - (yy_buffer_stack) = NULL; - - /* Destroy the start condition stack. */ - yyfree((yy_start_stack)); - (yy_start_stack) = NULL; - - yyfree((yy_state_buf)); - (yy_state_buf) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next - * time yylex() is called, initialization will occur. */ - yy_init_globals(); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy(char *s1, yyconst char *s2, int n) { - int i; - for (i = 0; i < n; ++i) s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen(yyconst char *s) { - int n; - for (n = 0; s[n]; ++n) - ; - - return n; -} -#endif - -void *yyalloc(yy_size_t size) { return (void *)malloc(size); } - -void *yyrealloc(void *ptr, yy_size_t size) { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *)realloc((char *)ptr, size); -} - -void yyfree(void *ptr) { - free((char *)ptr); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -int yywrap() { - if (--num_input_files > 0) { - set_input_file(*++input_files); - return 0; - } - - else - return 1; -} - -/* set_input_file - open the given file (if NULL, stdin) for scanning */ - -void set_input_file(file) char *file; -{ - if (file && strcmp(file, "-")) { - infilename = copy_string(file); - yyin = fopen(infilename, "r"); - - if (yyin == NULL) lerrsf(_("can't open %s"), file); - } - - else { - yyin = stdin; - infilename = copy_string(""); - } - - linenum = 1; -} diff --git a/third_party/lex/scan.l b/third_party/lex/scan.l deleted file mode 100644 index 5d31cbc5..00000000 --- a/third_party/lex/scan.l +++ /dev/null @@ -1,1010 +0,0 @@ -/* $OpenBSD: scan.l,v 1.12 2015/11/19 23:34:56 mmcc Exp $ */ - -/* scan.l - scanner for flex input -*-C-*- */ - -%{ -/* 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. */ - -#include "flexdef.h" -#include "parse.h" -extern bool tablesverify, tablesext; -extern int trlcontxt; /* Set in parse.y for each rule. */ -extern const char *escaped_qstart, *escaped_qend; - -#define ACTION_ECHO add_action( yytext ) -#define ACTION_IFDEF(def, should_define) \ - { \ - if ( should_define ) \ - action_define( def, 1 ); \ - } - -#define ACTION_ECHO_QSTART add_action (escaped_qstart) -#define ACTION_ECHO_QEND add_action (escaped_qend) - -#define ACTION_M4_IFDEF(def, should_define) \ - do{ \ - if ( should_define ) \ - buf_m4_define( &m4defs_buf, def, NULL);\ - else \ - buf_m4_undefine( &m4defs_buf, def);\ - } while(0) - -#define MARK_END_OF_PROLOG mark_prolog(); - -#define YY_DECL \ - int flexscan() - -#define RETURNCHAR \ - yylval = (unsigned char) yytext[0]; \ - return CHAR; - -#define RETURNNAME \ - if(yyleng < MAXLINE) \ - { \ - strlcpy( nmstr, yytext, sizeof nmstr ); \ - } \ - else \ - { \ - synerr(_("Input line too long\n")); \ - FLEX_EXIT(EXIT_FAILURE); \ - } \ - return NAME; - -#define PUT_BACK_STRING(str, start) \ - for ( i = strlen( str ) - 1; i >= start; --i ) \ - unput((str)[i]) - -#define CHECK_REJECT(str) \ - if ( all_upper( str ) ) \ - reject = true; - -#define CHECK_YYMORE(str) \ - if ( all_lower( str ) ) \ - yymore_used = true; - -#define YY_USER_INIT \ - if ( getenv("POSIXLY_CORRECT") ) \ - posix_compat = true; - -%} - -%option caseless nodefault stack noyy_top_state -%option nostdinit - -%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE -%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION -%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE -%x GROUP_WITH_PARAMS -%x GROUP_MINUS_PARAMS -%x EXTENDED_COMMENT -%x COMMENT_DISCARD - -WS [[:blank:]]+ -OPTWS [[:blank:]]* -NOT_WS [^[:blank:]\r\n] - -NL \r?\n - -NAME ([[:alpha:]_][[:alnum:]_-]*) -NOT_NAME [^[:alpha:]_*\n]+ - -SCNAME {NAME} - -ESCSEQ (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2})) - -FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ}) -CCL_CHAR ([^\\\n\]]|{ESCSEQ}) -CCL_EXPR ("[:"^?[[:alpha:]]+":]") - -LEXOPT [aceknopr] - -M4QSTART "[[" -M4QEND "]]" - -%% - static int bracelevel, didadef, indented_code; - static int doing_rule_action = false; - static int option_sense; - - int doing_codeblock = false; - int i, brace_depth=0, brace_start_line=0; - u_char nmdef[MAXLINE]; - - -{ - ^{WS} indented_code = true; BEGIN(CODEBLOCK); - ^"/*" ACTION_ECHO; yy_push_state( COMMENT ); - ^#{OPTWS}line{WS} yy_push_state( LINEDIR ); - ^"%s"{NAME}? return SCDECL; - ^"%x"{NAME}? return XSCDECL; - ^"%{".*{NL} { - ++linenum; - line_directive_out( (FILE *) 0, 1 ); - indented_code = false; - BEGIN(CODEBLOCK); - } - ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} { - brace_start_line = linenum; - ++linenum; - buf_linedir( &top_buf, infilename?infilename:"", linenum); - brace_depth = 1; - yy_push_state(CODEBLOCK_MATCH_BRACE); - } - - ^"%top".* synerr( _("malformed '%top' directive") ); - - {WS} /* discard */ - - ^"%%".* { - sectnum = 2; - bracelevel = 0; - mark_defs1(); - line_directive_out( (FILE *) 0, 1 ); - BEGIN(SECT2PROLOG); - return SECTEND; - } - - ^"%pointer".*{NL} yytext_is_array = false; ++linenum; - ^"%array".*{NL} yytext_is_array = true; ++linenum; - - ^"%option" BEGIN(OPTION); return OPTION_OP; - - ^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */ - ^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */ - - /* xgettext: no-c-format */ - ^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) ); - - ^{NAME} { - if(yyleng < MAXLINE) - { - strlcpy( nmstr, yytext, sizeof nmstr ); - } - else - { - synerr( _("Definition name too long\n")); - FLEX_EXIT(EXIT_FAILURE); - } - - didadef = false; - BEGIN(PICKUPDEF); - } - - {SCNAME} RETURNNAME; - ^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */ - {OPTWS}{NL} ACTION_ECHO; ++linenum; /* maybe end of comment line */ -} - - -{ - "*/" ACTION_ECHO; yy_pop_state(); - "*" ACTION_ECHO; - {M4QSTART} ACTION_ECHO_QSTART; - {M4QEND} ACTION_ECHO_QEND; - [^*\n] ACTION_ECHO; - {NL} ++linenum; ACTION_ECHO; -} - -{ - /* This is the same as COMMENT, but is discarded rather than output. */ - "*/" yy_pop_state(); - "*" ; - [^*\n] ; - {NL} ++linenum; -} - -{ - ")" yy_pop_state(); - [^\n\)]+ ; - {NL} ++linenum; -} - -{ - \n yy_pop_state(); - [[:digit:]]+ linenum = myctoi( yytext ); - - \"[^"\n]*\" { - free( (void *) infilename ); - infilename = copy_string( yytext + 1 ); - infilename[strlen( infilename ) - 1] = '\0'; - } - . /* ignore spurious characters */ -} - -{ - ^"%}".*{NL} ++linenum; BEGIN(INITIAL); - - {M4QSTART} ACTION_ECHO_QSTART; - {M4QEND} ACTION_ECHO_QEND; - . ACTION_ECHO; - - {NL} { - ++linenum; - ACTION_ECHO; - if ( indented_code ) - BEGIN(INITIAL); - } -} - -{ - "}" { - if( --brace_depth == 0){ - /* TODO: Matched. */ - yy_pop_state(); - }else - buf_strnappend(&top_buf, yytext, yyleng); - } - - "{" { - brace_depth++; - buf_strnappend(&top_buf, yytext, yyleng); - } - - {NL} { - ++linenum; - buf_strnappend(&top_buf, yytext, yyleng); - } - - {M4QSTART} buf_strnappend(&top_buf, escaped_qstart, strlen(escaped_qstart)); - {M4QEND} buf_strnappend(&top_buf, escaped_qend, strlen(escaped_qend)); - - [^{}\r\n] { - buf_strnappend(&top_buf, yytext, yyleng); - } - - <> { - linenum = brace_start_line; - synerr(_("Unmatched '{'")); - yyterminate(); - } -} - - -{ - {WS} /* separates name and definition */ - - {NOT_WS}[^\r\n]* { - if(yyleng < MAXLINE) - { - strlcpy( (char *) nmdef, yytext, sizeof nmdef ); - } - else - { - format_synerr( _("Definition value for {%s} too long\n"), nmstr); - FLEX_EXIT(EXIT_FAILURE); - } - /* Skip trailing whitespace. */ - for ( i = strlen( (char *) nmdef ) - 1; - i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t'); - --i ) - ; - - nmdef[i + 1] = '\0'; - - ndinstal( nmstr, nmdef ); - didadef = true; - } - - {NL} { - if ( ! didadef ) - synerr( _( "incomplete name definition" ) ); - BEGIN(INITIAL); - ++linenum; - } -} - - -