Ulya Trofimovich [Mon, 18 Feb 2019 22:48:00 +0000 (22:48 +0000)]
libre2c: hid some of the implementation details behind a pointer in regex_t struct.
Ulya Trofimovich [Mon, 18 Feb 2019 22:15:50 +0000 (22:15 +0000)]
libre2c: simplified construction of configurations.
Ulya Trofimovich [Mon, 18 Feb 2019 21:44:29 +0000 (21:44 +0000)]
libre2c: added GOR1 algorithm for POSIX closure construction.
Ulya Trofimovich [Mon, 18 Feb 2019 16:42:07 +0000 (16:42 +0000)]
libre2c: compare histories in a trie without reconstructing them.
Previously we used to unwing each history, store it as a linear sequence
in a separate buffer, and then iterate buffers from the beginning of
histories to fing the fork point.
This reconstruction step can be avoided, because we can find fork by
tracing both histories together from tail to root, element by element,
until their indices coincide (this is the fork point. Someone called
thos "two-fingers algorithm".
Ulya Trofimovich [Mon, 18 Feb 2019 16:26:44 +0000 (16:26 +0000)]
libre2c: use signed indices in tag history (this way root index -1 is the least one).
Ulya Trofimovich [Mon, 18 Feb 2019 12:46:38 +0000 (12:46 +0000)]
libre2c: marked hot function as inline.
Ulya Trofimovich [Mon, 18 Feb 2019 12:36:40 +0000 (12:36 +0000)]
libre2c: updating marker of last matched rule after closure has been constructed.
Ulya Trofimovich [Mon, 18 Feb 2019 12:27:19 +0000 (12:27 +0000)]
libre2c: use lookahead to to filter leftmost closure before computing offsets.
Ulya Trofimovich [Mon, 18 Feb 2019 11:59:55 +0000 (11:59 +0000)]
libre2c: use lookahead to filter POSIX closure before computing offsets and precedence matrix.
This significantly reduces the amount of work on each step.
Ulya Trofimovich [Mon, 18 Feb 2019 11:32:30 +0000 (11:32 +0000)]
libre2c: implemented constant-memory (non trie-based) TNFA POSIX matching algorithm.
Ulya Trofimovich [Mon, 18 Feb 2019 11:30:57 +0000 (11:30 +0000)]
libre2c: renamed a couple of struct fields (cosmetic).
Ulya Trofimovich [Mon, 18 Feb 2019 10:52:26 +0000 (10:52 +0000)]
Correctly set values on main diagonal of POSIX precedence matrix (configuration compared to itself).
It doesn't show any difference on the tests, probably because previously
these values were set to zero, which unpacks to symmetrical (though
incorrect) values, and thus doesn't affect comparison.
Ulya Trofimovich [Thu, 14 Feb 2019 13:35:58 +0000 (13:35 +0000)]
libre2c: added (stub for) constant-memory (non trie-based) TNFA POSIX matching algorithm.
Ulya Trofimovich [Thu, 14 Feb 2019 13:10:42 +0000 (13:10 +0000)]
libre2c: use preallocated buffer.
Ulya Trofimovich [Thu, 14 Feb 2019 12:56:29 +0000 (12:56 +0000)]
libre2c: added constant-memory (non trie-based) TNFA matching algorithm for leftmost greedy.
Ulya Trofimovich [Thu, 14 Feb 2019 12:52:50 +0000 (12:52 +0000)]
Assign indices to core TNFA states (those that are final or have transitions on symbols).
During epsilon closure constructions, many operations only need to be
performed for core states. This allows to save some memory, e.g.
precedence matrix can be indexed by core states.
Ulya Trofimovich [Thu, 14 Feb 2019 12:51:06 +0000 (12:51 +0000)]
Structural tags are only needed for POSIX disambiguation, not for POSIX syntax.
Ulya Trofimovich [Wed, 13 Feb 2019 15:27:55 +0000 (15:27 +0000)]
Added option --verbose that prints a message to stderr in case of success.
Ulya Trofimovich [Wed, 13 Feb 2019 15:22:01 +0000 (15:22 +0000)]
Removed useless code in tests for misused option arguments.
Ulya Trofimovich [Wed, 13 Feb 2019 14:33:39 +0000 (14:33 +0000)]
Tweaked error messages for misused option arguments, added some tests for them.
Ulya Trofimovich [Wed, 13 Feb 2019 13:50:00 +0000 (13:50 +0000)]
Added option --location-format <gnu | msvc> (default is gnu).
This option controls the formatting of locations in error messages
and warnings.
With --location-format gnu:
filename:line:column: ...
With --location-format msvc:
filename(line,column): ...
Ulya Trofimovich [Wed, 13 Feb 2019 07:23:27 +0000 (07:23 +0000)]
Moved files.
Ulya Trofimovich [Tue, 12 Feb 2019 22:53:54 +0000 (22:53 +0000)]
Deduplicated filename strings in locations by interning them in a table and using indices.
Ulya Trofimovich [Tue, 12 Feb 2019 17:31:25 +0000 (17:31 +0000)]
Unified location handling by grouping relevant information in a struct.
Massive test updates are caused by refined locations for various error
messages and warnings (re2c now reports not only line, but also column).
Ulya Trofimovich [Mon, 11 Feb 2019 21:43:52 +0000 (21:43 +0000)]
Added test for EOF rule.
Ulya Trofimovich [Mon, 11 Feb 2019 13:11:47 +0000 (13:11 +0000)]
Use GNU-style location format 'file:line:column: ...' in warnings and error messages.
Ulya Trofimovich [Sat, 9 Feb 2019 18:18:48 +0000 (18:18 +0000)]
Added build script that uses '-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC'.
Ulya Trofimovich [Sat, 9 Feb 2019 17:54:25 +0000 (17:54 +0000)]
Fixed out of bounds read when sorting one-element initial closure.
The error only occurred on some libc implementations, e.g. on debug
glibc (options -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC).
Ulya Trofimovich [Fri, 8 Feb 2019 23:15:21 +0000 (23:15 +0000)]
Fixed use of invalidated iterator after erase on std::map.
Problem reported by Denis Naumov.
Ulya Trofimovich [Fri, 8 Feb 2019 16:40:47 +0000 (16:40 +0000)]
Use per-tag cache of history comparisons to avoid repeated computation.
Ulya Trofimovich [Fri, 8 Feb 2019 16:08:58 +0000 (16:08 +0000)]
Use counting sort for tag histories (the number tags is limited, so it is faster).
Ulya Trofimovich [Fri, 8 Feb 2019 15:25:54 +0000 (15:25 +0000)]
Use insertion sort instead of bubble sort (it is slightly faster).
Ulya Trofimovich [Fri, 8 Feb 2019 13:58:43 +0000 (13:58 +0000)]
Fixed typo.
Ulya Trofimovich [Fri, 8 Feb 2019 10:59:58 +0000 (10:59 +0000)]
Speedup in determinization (using a more efficient way to compare lookahead tags).
Ulya Trofimovich [Thu, 7 Feb 2019 22:40:18 +0000 (22:40 +0000)]
Yet another speedup in determinization (early exit when comparing history with itself).
Ulya Trofimovich [Thu, 7 Feb 2019 22:06:40 +0000 (22:06 +0000)]
Small speedup in determinization (by inlining small hot functions).
Ulya Trofimovich [Thu, 7 Feb 2019 21:41:18 +0000 (21:41 +0000)]
Small speedup in determinization by delaying computation of costly conditions.
Ulya Trofimovich [Thu, 7 Feb 2019 11:31:47 +0000 (11:31 +0000)]
libre2c: added comment.
Ulya Trofimovich [Thu, 7 Feb 2019 10:50:35 +0000 (10:50 +0000)]
libre2c: speedup of POSIX NFA matcher by lazy computation and caching of precedence.
A lot of the match time was taken by eagerly computing precedence values
on each step for each pair of closure states. Most of these values are not
needed: RE may be unambigous; or the given input string may be unambigous,
even if there is ambiguity, it may take only a few comparisons to resolve.
All the rest is wasted effort.
We can avoid it by delaying precedence computation until necessary, and
then unwinding all the steps backwards, computing precedence for each step
and caching the computed values (so that the same pair of histories is not
compared twice). It is still the same incremental comparison as with
precedence matrices: we compare step by step, going from the fork frame to
the join frame. The result of comparison on each step is folded to a triple
of numbers and recorded in cache. It is important that we do record each
step, not just the first step, because the next pair of ambiguous histories
may unwind to the same pair of prefixes that was compared before.
For all this to work, it is necessary that we can store all history until
the very end, because at any step we might need to unwind an arbitrary
number of steps back. We also need to address individual subhistories
efficiently in order to use them as keys in the cache. All this is achieved
by storing history in the form of a trie and addressing individual
histories by indices in the trie. We also use trie to compute the resulting
tag values (instead of storing tags in registers at each step).
Ulya Trofimovich [Tue, 5 Feb 2019 17:21:48 +0000 (17:21 +0000)]
libre2c: small performance improvement in POSIX TNFA matcher.
Ulya Trofimovich [Tue, 5 Feb 2019 15:47:01 +0000 (15:47 +0000)]
libre2c: extracted common parts of TNFA matchers (leftmost and POSIX).
Ulya Trofimovich [Tue, 5 Feb 2019 14:57:42 +0000 (14:57 +0000)]
libre2c: performance optimization: get all tag values in one scan of history.
Ulya Trofimovich [Tue, 5 Feb 2019 13:33:04 +0000 (13:33 +0000)]
Renamed libre2c_posix -> libre2c (as it now also supports leftmost greedy semantics).
Ulya Trofimovich [Tue, 5 Feb 2019 13:10:56 +0000 (13:10 +0000)]
Differentiate between "POSIX syntax" and "POSIX semantics" options.
This is needed because we may want to use POSIX syntax with leftmost
greedy disambiguation. In that case, we still need parentheses-as-tags
attitude, but we don't want all the overhead and heuristics to spped
up POSIX closure.
libre2c_posix: added test for leftmost TNFA matcher.
Ulya Trofimovich [Tue, 5 Feb 2019 11:05:51 +0000 (11:05 +0000)]
libre2c_posix: added TNFA matcher with leftmost greedy disambiguation semantics.
Ulya Trofimovich [Sat, 2 Feb 2019 19:08:45 +0000 (19:08 +0000)]
libre2c_posix: small performance improvement in NFA-based matcher.
Ulya Trofimovich [Sat, 2 Feb 2019 18:16:32 +0000 (18:16 +0000)]
libre2c_posix: added NFA-based matcher.
Ulya Trofimovich [Sat, 2 Feb 2019 18:12:18 +0000 (18:12 +0000)]
Constified function parameter.
Ulya Trofimovich [Sun, 27 Jan 2019 22:57:25 +0000 (22:57 +0000)]
libre2c_posix: another small improvement in regexec() implementation.
Ulya Trofimovich [Sun, 27 Jan 2019 18:05:23 +0000 (18:05 +0000)]
libre2c_posix: a small performance improvement in regexec() implementation.
Ulya Trofimovich [Sun, 27 Jan 2019 17:45:37 +0000 (17:45 +0000)]
libre2c_posix: regex_t definition must be exposed to users.
POSIX standard says that:
The regex_t structure is defined in <regex.h> and contains at
least the following member: re_nsub (number of parenthesized
subexpressions).
Ulya Trofimovich [Sun, 27 Jan 2019 11:35:18 +0000 (11:35 +0000)]
libre2c_posix: enable tag optimizations.
Ulya Trofimovich [Sun, 27 Jan 2019 10:23:23 +0000 (10:23 +0000)]
libre2c_posix: extended regex_t structure to hold more submatch data.
Added fields:
- re_nsub: total number of submatch groups, required by POSIX standard
- pmatch: buffer for submatch results, usually supplied by the user to
regexec(), but we allow to do the allocation and storage in regex_t.
This is convenient for users that have hard time managing memory, e.g.
java bindings to libre2c_posix.
- regs: buffer for internal use by regexec(), strored in regex_t to
avoid repeated memory allocation on each call to regexec() with the
same regex.
Ulya Trofimovich [Sun, 27 Jan 2019 10:06:22 +0000 (10:06 +0000)]
Adjusted build system to correctly build DLLs for windows.
Adjustments:
- configure.ac: pass win32-dll option to LT_INIT
- Makefile_libre2c_posix.am: use -no-undefined in LDFLAGS
- use slibtool: https://github.com/midipix-project/slibtool for windows
builds The problem with libtool is that it doesn't allow to link libstdc++
and libgcc statically, which is necessary to build portable DLLs with
Mingw. Libtool adds -nostdlib option to LDFLAGS and links some predefined
objects that pull in dependency on dynamic libstdc++ and libgcc, even in
the presence of -static-libstdc++ -static-libgcc.
Ulya Trofimovich [Sat, 19 Jan 2019 11:57:16 +0000 (11:57 +0000)]
Use libtool to build libraries.
Ulya Trofimovich [Thu, 17 Jan 2019 22:52:04 +0000 (22:52 +0000)]
Fixed operator precedence with --flex-syntax option.
Operator precedence was broken because re2c tried to parse whole strings
of characters at once instead of parsing one character at a time (in
much the same way as it would parse properly quotes string literals in
the original re2c format). This caused ab* being parsed as (ab)*, which
is clearly wrong (should be a(b)*).
This fixes bug #242:
"Operator precedence with --flex-syntax is broken."
Ulya Trofimovich [Wed, 16 Jan 2019 21:49:38 +0000 (21:49 +0000)]
libre2c_posix: handle empty group () in parser; added more tests.
Ulya Trofimovich [Tue, 15 Jan 2019 23:45:53 +0000 (23:45 +0000)]
Make re2c:eof usable with push-model lexers (-f, --storable-state option).
Ulya Trofimovich [Tue, 15 Jan 2019 00:24:22 +0000 (00:24 +0000)]
libre2c_posix: parse repetition counters in the lexer.
Ulya Trofimovich [Mon, 14 Jan 2019 23:04:23 +0000 (23:04 +0000)]
libre2c_posix: initial support for character classes in parser.
Ulya Trofimovich [Sun, 13 Jan 2019 11:11:45 +0000 (11:11 +0000)]
libre2c_posix (test): clear error status on expected failures.
Ulya Trofimovich [Sun, 13 Jan 2019 10:57:53 +0000 (10:57 +0000)]
libre2c_posix: skip fictive tags in regexec(); handle dot in parser; added more tests.
Ulya Trofimovich [Sat, 12 Jan 2019 20:32:15 +0000 (20:32 +0000)]
libre2c_posix: use C-array initializers instead of variadic functions for offset lists.
Variadic functions cause subtle toolchain-specific errors because integer
literals used to initialize offsets may have different type than the type
expected by variadic function (e.g. int vs long).
Ulya Trofimovich [Sat, 12 Jan 2019 14:42:24 +0000 (14:42 +0000)]
libre2c_posix (test): a more concise error message.
Ulya Trofimovich [Sat, 12 Jan 2019 14:19:21 +0000 (14:19 +0000)]
libre2c_posix: fixed -Wmaybe-uninitialized GCC warning.
Ulya Trofimovich [Sat, 12 Jan 2019 14:18:21 +0000 (14:18 +0000)]
libre2c_posix: fixed memleaks.
Ulya Trofimovich [Sat, 12 Jan 2019 12:50:47 +0000 (12:50 +0000)]
Experimental: initial implementation of libre2c_posix, POSIX regexp library based on re2c.
Ulya Trofimovich [Fri, 11 Jan 2019 08:16:00 +0000 (08:16 +0000)]
Paper: don't forget to pass precedence matrices to initial closure.
Ulya Trofimovich [Fri, 11 Jan 2019 00:34:07 +0000 (00:34 +0000)]
Makefile.am: further simplify parser generation rules and avoid copying file to itself.
Ulya Trofimovich [Fri, 11 Jan 2019 00:19:01 +0000 (00:19 +0000)]
Makefile.am: don't forget to run main test suite on `make check`.
Ulya Trofimovich [Thu, 10 Jan 2019 23:28:30 +0000 (23:28 +0000)]
Makefile.am: use more universal rules for autogenerated lexers and parsers.
Ulya Trofimovich [Thu, 10 Jan 2019 22:16:07 +0000 (22:16 +0000)]
Avoid unexpected removal of untracked files and directories.
Ulya Trofimovich [Thu, 10 Jan 2019 22:09:25 +0000 (22:09 +0000)]
Moved function declarations to the header they belong in.
Ulya Trofimovich [Sun, 6 Jan 2019 16:44:45 +0000 (16:44 +0000)]
Updated range test.
Ulya Trofimovich [Sun, 6 Jan 2019 16:25:39 +0000 (16:25 +0000)]
Use a simple fixed-size slab allocator for ranges.
Ulya Trofimovich [Sun, 6 Jan 2019 08:40:16 +0000 (08:40 +0000)]
Handle single chars and 1-char ranges in the same way.
Ulya Trofimovich [Sat, 5 Jan 2019 22:53:45 +0000 (22:53 +0000)]
Updated autogenerated files after change of directory layout.
Ulya Trofimovich [Sat, 5 Jan 2019 22:49:52 +0000 (22:49 +0000)]
Moved duplicated code into a separate function.
Ulya Trofimovich [Sat, 5 Jan 2019 22:41:45 +0000 (22:41 +0000)]
Changed directory layout (cosmetic).
Ulya Trofimovich [Sat, 5 Jan 2019 13:16:36 +0000 (13:16 +0000)]
Handle EBCDIC like other encodings instead of coupling it with character validation.
Ulya Trofimovich [Sat, 5 Jan 2019 11:42:29 +0000 (11:42 +0000)]
Moved repeated code into a separate function.
Ulya Trofimovich [Fri, 4 Jan 2019 20:59:25 +0000 (20:59 +0000)]
Fixed error in range difference with EBCDIC, added tests for various encodings.
Ulya Trofimovich [Fri, 4 Jan 2019 10:53:22 +0000 (10:53 +0000)]
Compute range difference before applying encoding expansion to operands.
Ulya Trofimovich [Fri, 4 Jan 2019 19:27:58 +0000 (19:27 +0000)]
Added test for bug #238.
Ulya Trofimovich [Fri, 4 Jan 2019 12:54:03 +0000 (12:54 +0000)]
Fixed out-of-bounds write caused by misuse of slab allocator in case of large allocation size.
This fixes bug #238.
Found by american fuzzy lop (thanks to Henri Salo).
Ulya Trofimovich [Thu, 3 Jan 2019 22:56:34 +0000 (22:56 +0000)]
Adjusting formatting, dropping old macros (cosmetic).
Ulya Trofimovich [Thu, 3 Jan 2019 22:37:54 +0000 (22:37 +0000)]
Added tests for debug options.
Ulya Trofimovich [Thu, 3 Jan 2019 21:58:53 +0000 (21:58 +0000)]
Added debug options --dump-cfg and --dump-interf.
Ulya Trofimovich [Thu, 3 Jan 2019 21:17:22 +0000 (21:17 +0000)]
Moved debug stuff to a separate subdirectory.
Ulya Trofimovich [Thu, 3 Jan 2019 20:26:36 +0000 (20:26 +0000)]
Disable --dump-* options in non-debug mode.
Ulya Trofimovich [Thu, 3 Jan 2019 11:33:04 +0000 (11:33 +0000)]
Adding --enable-debug to Travis CI configuration.
Ulya Trofimovich [Thu, 3 Jan 2019 11:26:51 +0000 (11:26 +0000)]
Added some tests for GTOP closure algorithm.
Ulya Trofimovich [Thu, 3 Jan 2019 11:13:15 +0000 (11:13 +0000)]
Added test comparing POSIX closure statistics with GOR1 and GTOP.
Ulya Trofimovich [Thu, 3 Jan 2019 10:44:24 +0000 (10:44 +0000)]
In debug build, add " (debug)" to version string.
Ulya Trofimovich [Thu, 3 Jan 2019 09:53:57 +0000 (09:53 +0000)]
Small simplifications in GOR1 initialization phase.
Instead of using two stacks to weed out low-precedence initial
configurations with duplicate target state, let them remain on the
bottom of topsort stack, which effectively makes them ignored.
Ulya Trofimovich [Wed, 2 Jan 2019 22:57:51 +0000 (22:57 +0000)]
Paper: simplifying GOR1 initialization pseudocode.
Ulya Trofimovich [Wed, 2 Jan 2019 17:54:11 +0000 (17:54 +0000)]
Small cosmetic simplifications in POSIX precedence.
Ulya Trofimovich [Wed, 2 Jan 2019 17:43:17 +0000 (17:43 +0000)]
Use a specialized simplified version of POSIX comparison for initial configurations.
Ulya Trofimovich [Tue, 1 Jan 2019 13:24:10 +0000 (13:24 +0000)]
Intrinsic options that do not have configurations should be immutable.
Ulya Trofimovich [Tue, 1 Jan 2019 13:13:14 +0000 (13:13 +0000)]
Added debug option --dump-closure-stats.