]> granicus.if.org Git - re2c/log
re2c
8 years agoRelease 0.15.1. 0.15.1
Ulya Trofimovich [Sun, 22 Nov 2015 21:03:29 +0000 (21:03 +0000)]
Release 0.15.1.

8 years agoPrepare release 0.15.1: updated CHANGELOG.
Ulya Trofimovich [Sun, 22 Nov 2015 20:59:29 +0000 (20:59 +0000)]
Prepare release 0.15.1: updated CHANGELOG.

8 years agorun_tests.sh: fix the order of files in test results.
Ulya Trofimovich [Sun, 22 Nov 2015 20:55:04 +0000 (20:55 +0000)]
run_tests.sh: fix the order of files in test results.

'sort' behavior depends on current locale; set 'LC_ALL=C LANG=C'
before doing locale-sensitive things. Updated test results.

8 years agorelease.sh: don't forget to push tags.
Ulya Trofimovich [Sun, 22 Nov 2015 20:50:15 +0000 (20:50 +0000)]
release.sh: don't forget to push tags.

8 years agoRelease 0.15. 0.15
Ulya Trofimovich [Sun, 22 Nov 2015 19:53:04 +0000 (19:53 +0000)]
Release 0.15.

8 years agoPrepare release 0.15: updated release instructions.
Ulya Trofimovich [Sun, 22 Nov 2015 19:48:37 +0000 (19:48 +0000)]
Prepare release 0.15: updated release instructions.

8 years agoPrepare release 0.15: updated CHANGELOG.
Ulya Trofimovich [Sun, 22 Nov 2015 19:46:45 +0000 (19:46 +0000)]
Prepare release 0.15: updated CHANGELOG.

8 years agoUse 'rst2man.py' to build manpage; updated manpage.
Ulya Trofimovich [Sun, 22 Nov 2015 19:42:21 +0000 (19:42 +0000)]
Use 'rst2man.py' to build manpage; updated manpage.

8 years agoMerge branch 'master' into simplified_codegen.
Ulya Trofimovich [Sat, 21 Nov 2015 20:03:10 +0000 (20:03 +0000)]
Merge branch 'master' into simplified_codegen.

* master:
  Updated version to 0.14.4.dev
  Release 0.14.3.
  Added simple test for yacc-style brackets (see patch #27)
  Fixed '#27 re2c crashes reading files containing %{ %}' (patch by Rui)
  Makefile.am: dropped distfiles for MSVC (they are broken anyway)
  Added full another test for bug #57.
  Updated version to 0.14.3.dev
  Release 0.14.2.
  Fixed bug #57: Wrong result only if another rule is present
  Updated version to 0.14.2.dev
  Release 0.14.1.
  Pad version with '0' instead of nulls

8 years agoSkeleton: data generation (linear): don't forget to dump path in end nodes.
Ulya Trofimovich [Wed, 18 Nov 2015 14:45:49 +0000 (14:45 +0000)]
Skeleton: data generation (linear): don't forget to dump path in end nodes.

8 years agoSkeleton: changed formatting of the generated code (no significant changes).
Ulya Trofimovich [Mon, 16 Nov 2015 14:48:53 +0000 (14:48 +0000)]
Skeleton: changed formatting of the generated code (no significant changes).

8 years agoSkeleton: disregard default rule when estimating maximum rule size (in bytes).
Ulya Trofimovich [Mon, 16 Nov 2015 14:10:49 +0000 (14:10 +0000)]
Skeleton: disregard default rule when estimating maximum rule size (in bytes).

Default rule '*' (not to be confused with 'none' rule) used to have
normal number just like other rules. Now that re2c has to distinguish
default rule fro other rules (because of [-Wunreachable-rules]),
it reserves a special number (UINT32_MAX - 1) for it.

8 years agoLex strings and character classes in a more elegant way.
Ulya Trofimovich [Tue, 10 Nov 2015 15:28:28 +0000 (15:28 +0000)]
Lex strings and character classes in a more elegant way.

8 years agoRecognize escaped dash '\-' in character class.
Ulya Trofimovich [Mon, 9 Nov 2015 16:06:40 +0000 (16:06 +0000)]
Recognize escaped dash '\-' in character class.

8 years agoFixed tests for bug #119: "-f with -b/-g generates incorrect dispatch on fill labels".
Ulya Trofimovich [Fri, 16 Oct 2015 12:21:50 +0000 (13:21 +0100)]
Fixed tests for bug #119: "-f with -b/-g generates incorrect dispatch on fill labels".

Somehow configuration 're2c:state:abort = 1;' was present in all the
tests; it was meant to be only in half of them.

8 years agorun_tests.sh: tried to clarify regexp that splits options from filename.
Ulya Trofimovich [Thu, 15 Oct 2015 13:54:17 +0000 (14:54 +0100)]
run_tests.sh: tried to clarify regexp that splits options from filename.

Note: should keep to POSIX, so no '+' or '?' is allowed.

8 years agorun_tests.sh: run each test in a separate directory and paste all generated files...
Ulya Trofimovich [Wed, 14 Oct 2015 22:11:01 +0000 (23:11 +0100)]
run_tests.sh: run each test in a separate directory and paste all generated files into one.

Updated tests: changes are insignificant (the order in which multiple
generated files are concatenated has changed).

8 years agorun_tests.sh: don't change filenames to '<stdout>'.
Ulya Trofimovich [Wed, 14 Oct 2015 14:09:41 +0000 (15:09 +0100)]
run_tests.sh: don't change filenames to '<stdout>'.

Updated test. Used the following shell script to validate changes:

    #!/bin/bash

    for f2 in *.temp
    do
        f1=${f2%.temp}

        diff1=`diff $f1 $f2 | grep '^< ' | wc -l`
        diff1_fname=`diff $f1 $f2 | grep '^<\( #line [0-9]\+ "<stdout>"\|[ ]\+("<stdout>[^"]\+"\)' | wc -l`
        diff2=`diff $f1 $f2 | grep '^> ' | wc -l`
        diff2_fname=`diff $f1 $f2 | grep '^>\( #line [0-9]\+ "[^"]\+"\|[ ]\+("[^"]\+"\)' | wc -l`

        # missing: only changed filenames
        [ $diff1 -ne $diff1_fname ] && echo "FAIL1: $f1" && exit 1

        # added: only changed filenames
        [ $diff2 -ne $diff2_fname ] && echo "FAIL2: $f1" && exit 1

        # the number of missing changed filenames
        # equals to the number of added changed filenames
        [ $diff1_fname -ne $diff2_fname ] && echo "FAIL4: $f1" && exit 1
    done

    echo "OK"

8 years agorun_tests.sh: paste type headers into source file and diff all at once.
Ulya Trofimovich [Wed, 14 Oct 2015 13:19:55 +0000 (14:19 +0100)]
run_tests.sh: paste type headers into source file and diff all at once.

8 years agorun_tests.sh: use '-o' option. Added tests for '--skeleton' option.
Ulya Trofimovich [Wed, 14 Oct 2015 12:04:19 +0000 (13:04 +0100)]
run_tests.sh: use '-o' option. Added tests for '--skeleton' option.

8 years agoOmit unnecessary null pointer check (suggested by Markus Elfring).
Ulya Trofimovich [Tue, 13 Oct 2015 20:20:22 +0000 (21:20 +0100)]
Omit unnecessary null pointer check (suggested by Markus Elfring).

8 years agorun_tests.sh: added option '--keep-tmp-files'.
Ulya Trofimovich [Tue, 13 Oct 2015 14:36:44 +0000 (15:36 +0100)]
run_tests.sh: added option '--keep-tmp-files'.

8 years agorun_tests.sh: added '--skeleton' option.
Ulya Trofimovich [Tue, 13 Oct 2015 13:26:33 +0000 (14:26 +0100)]
run_tests.sh: added '--skeleton' option.

With this option script runs re2c with '--skeleton' and
'-Werror-undefined-control-flow' and instead of comparing results with
reference test results, it compiles the generated skeleton programs and
runs them. If C compiler or binary return nonzero error status, script
reports an error. Note that cases when re2c failed to generate code are
not considered errors (re2c has lots of test cases for its errors).

8 years agoSplit main lexer and configuration lexer in two separate files.
Ulya Trofimovich [Mon, 12 Oct 2015 14:14:16 +0000 (15:14 +0100)]
Split main lexer and configuration lexer in two separate files.

8 years agoFactored out some common lexing pieces into separate routines.
Ulya Trofimovich [Mon, 12 Oct 2015 13:12:11 +0000 (14:12 +0100)]
Factored out some common lexing pieces into separate routines.

re2c lacks submatch extraction; it would be much more convenient
to memorize input positions for some parts of regular expressions
than break each regexp in the middle and move parts to separate blocks.

Submatch extraction is dificult to implement in general, but supporting
submatch in some simple cases (like the case where trailing context is
allowed) would be not so difficult and most helpful.

8 years agoParse inplace configurations in lexer; don't pass them to parser.
Ulya Trofimovich [Mon, 12 Oct 2015 12:32:45 +0000 (13:32 +0100)]
Parse inplace configurations in lexer; don't pass them to parser.

This removes a lot of copy-pasting.

The change of error location in test is insignificant: the reported
location was incorrect and it still remains imprecise.

8 years agoImproved '-Wmatch-empty-string' warning.
Ulya Trofimovich [Thu, 8 Oct 2015 13:38:19 +0000 (14:38 +0100)]
Improved '-Wmatch-empty-string' warning.

- recognize empty match with nonempty trailing context
- don't report unreachable empty match

8 years agoAdded '-Wunreachable-rules' warning.
Ulya Trofimovich [Thu, 8 Oct 2015 09:51:08 +0000 (10:51 +0100)]
Added '-Wunreachable-rules' warning.

Warns about unreachable rules:
  - rules that are shadowed by other rules, e.g. rule '[a]' is shadowed by
    '[a] [^]'
  - infinite rules that consume infinitely many characters and fail on
    YYFILL, e.g. '[^]*'
  - rules that contain never-matching link, e.g. '[]' with option
    '--empty-class match-none'
default rule '*' should not be reported

8 years agoFixed memleaks and grouped options in one big macro.
Ulya Trofimovich [Wed, 7 Oct 2015 17:30:19 +0000 (18:30 +0100)]
Fixed memleaks and grouped options in one big macro.

8 years agoMerge default rules on the fly, assign them the same lowest priority.
Ulya Trofimovich [Wed, 7 Oct 2015 15:20:38 +0000 (16:20 +0100)]
Merge default rules on the fly, assign them the same lowest priority.

re2c used to postpone merging default rules because rank counter could
only assign consequtive ranks to rules, and default rules must have
the lowest priority. Now rank counter has been modified to return
special value as defult rule rank.

8 years agoAutogenerated configuration tests: added default rule to each test.
Ulya Trofimovich [Mon, 5 Oct 2015 20:20:23 +0000 (21:20 +0100)]
Autogenerated configuration tests: added default rule to each test.

It's not a bunch of unnecessary warnings I want to avoid, it's a bunch of
unnecessary runtime failures in programs generated with '--skeleton'
(failures caused by undefined control flow; re2c recogizes such cases
and the generated program reports a warning before failing).

8 years agoSupport trailing context with '--skeleton'.
Ulya Trofimovich [Mon, 5 Oct 2015 14:44:50 +0000 (15:44 +0100)]
Support trailing context with '--skeleton'.

Trialing contexts are currently broken (overlapping trailing contexts
cannot be tracked with a single 'YYCTXMARKER'). For now, re2c with
'--skeleton' mimics this incorrect behaviour: information about context
is lost by the time DFA is constructed, so skeleton has no way to
figure out the right order of things.

8 years agoMoved path-combining magic closer to path definition.
Ulya Trofimovich [Sun, 4 Oct 2015 18:46:34 +0000 (19:46 +0100)]
Moved path-combining magic closer to path definition.

8 years agoFixed bug #116: "empty string with non-empty trailing context consumes code units".
Ulya Trofimovich [Sun, 4 Oct 2015 18:25:00 +0000 (19:25 +0100)]
Fixed bug #116: "empty string with non-empty trailing context consumes code units".

Prior to this commit backup of trailing context position was done
before advancing input position and re2c either had to emit
    YYCTXMARKER = YYCURSOR + 1;
(with default input API), or
    YYRESTORECTX ();
    YYSKIP ();
(with custom input API).

The problem is that sometimes initial state doesn't sdvance input position
at all. Now re2c emits context backup after advancing input position and it
no longer needs '+1' or 'YYSKIP' hacks. It always backups the correct position.

8 years ago'--skeleton': don't forget to jump to start label when needed.
Ulya Trofimovich [Wed, 30 Sep 2015 16:33:58 +0000 (17:33 +0100)]
'--skeleton': don't forget to jump to start label when needed.

8 years ago'--skeleton': give more info when reporting unused data and keys.
Ulya Trofimovich [Wed, 30 Sep 2015 16:04:29 +0000 (17:04 +0100)]
'--skeleton': give more info when reporting unused data and keys.

8 years ago'--skeleton': fixed codegen error with '-b' (don't forget last bitmap element).
Ulya Trofimovich [Wed, 30 Sep 2015 15:12:27 +0000 (16:12 +0100)]
'--skeleton': fixed codegen error with '-b' (don't forget last bitmap element).

8 years ago'--skeleton': added missing newline in the generated code.
Ulya Trofimovich [Wed, 30 Sep 2015 15:11:45 +0000 (16:11 +0100)]
'--skeleton': added missing newline in the generated code.

8 years ago'--skeleton': tell function name when reporting errors and warnings.
Ulya Trofimovich [Wed, 30 Sep 2015 15:10:38 +0000 (16:10 +0100)]
'--skeleton': tell function name when reporting errors and warnings.

8 years ago'--skeleton': respect empty string match.
Ulya Trofimovich [Tue, 29 Sep 2015 15:47:25 +0000 (16:47 +0100)]
'--skeleton': respect empty string match.

8 years agoFixed skeleton generation in '-r' mode.
Ulya Trofimovich [Tue, 29 Sep 2015 15:04:27 +0000 (16:04 +0100)]
Fixed skeleton generation in '-r' mode.

'-r' is different from normal mode in two aspects:
    - single DFA may be used multiple times (unchanged, we only
      need a single copy for skeleton)
    - DFA may be generated but not used at all

8 years agoSplit skeleton arc count limits for permutations, cover and default paths.
Ulya Trofimovich [Mon, 28 Sep 2015 21:34:06 +0000 (22:34 +0100)]
Split skeleton arc count limits for permutations, cover and default paths.

8 years agoDocs: updated descriptions of some inplace configurations.
Ulya Trofimovich [Mon, 28 Sep 2015 14:30:20 +0000 (15:30 +0100)]
Docs: updated descriptions of some inplace configurations.

8 years agoUnified meaning and mutual relations of some inplace configurations.
Ulya Trofimovich [Mon, 28 Sep 2015 12:54:26 +0000 (13:54 +0100)]
Unified meaning and mutual relations of some inplace configurations.

This commit changes the behaviour of three groups of options:

    re2c:define:YYSETCONDITION
    re2c:define:YYSETCONDITION@cond
    re2c:define:YYSETCONDITION:naked

    re2c:define:YYSETSTATE
    re2c:define:YYSETSTATE@state
    re2c:define:YYSETSTATE:naked (added by this commit)

    re2c:define:YYFILL
    re2c:define:YYFILL@len
    re2c:yyfill:parameter
    re2c:define:YYFILL:naked

The changes should be backwards compatible (meaning that old code that
compiled should still compile), but it may add empty statements or statements
with no effect for some configurations, e.g.:
    YYSETCONDTITION(0);(0);
These changes were necessary to unify re2c behaviour, remove counter-intuitive
cases and make it possible to write comprehensible option descriptions.

In short, the changes are:
    - 'naked' triggers generation of argument-in-braces and semicolon;
    - 'parameter' triggers generation of argument-in-braces (when applicable,
      'naked' has priority over 'parameter');
    - argument templates ('@cond', '@state', '@len') don't force other
      configurations, they also don't influence on argument-in-braces;

Added test generator and autogenerated tests.

8 years agorun_tests.sh: preserve nested directory structure when dumping errors.
Ulya Trofimovich [Mon, 28 Sep 2015 12:49:05 +0000 (13:49 +0100)]
run_tests.sh: preserve nested directory structure when dumping errors.

8 years agoDon't hang forever trying to replace empty configuration arguments.
Ulya Trofimovich [Sun, 27 Sep 2015 11:03:03 +0000 (12:03 +0100)]
Don't hang forever trying to replace empty configuration arguments.

8 years agoDefault options should be syncronized as well.
Ulya Trofimovich [Sun, 27 Sep 2015 10:58:40 +0000 (11:58 +0100)]
Default options should be syncronized as well.

8 years agoReduced redundant global flags.
Ulya Trofimovich [Thu, 24 Sep 2015 14:21:45 +0000 (15:21 +0100)]
Reduced redundant global flags.

8 years agoHandle all inplace configurations in a uniform way.
Ulya Trofimovich [Thu, 24 Sep 2015 13:52:24 +0000 (14:52 +0100)]
Handle all inplace configurations in a uniform way.

This commit removes check (and error) for overwritten configurations
(like setting 're2c:define:YYCYRSOR' twice in the same block).
This check was in principle useful, but it was applied to somehow
randomly chosen set of parameters. If in future we'll feel a need
for such check, it should respect all options equally and report
warning rather than error.

8 years agoAutomatically resync options on read acccess (if they have been updated).
Ulya Trofimovich [Wed, 23 Sep 2015 21:08:39 +0000 (22:08 +0100)]
Automatically resync options on read acccess (if they have been updated).

8 years agoMerged 'DFlag' and 'flag_skeleton' into one option 'target'.
Ulya Trofimovich [Wed, 23 Sep 2015 16:32:36 +0000 (17:32 +0100)]
Merged 'DFlag' and 'flag_skeleton' into one option 'target'.

The nature of these options makes them mutually exclusive; so instead
of checking that they are not both set just make them a single option.

8 years agoSeparated user config and effective config.
Ulya Trofimovich [Wed, 23 Sep 2015 14:45:54 +0000 (15:45 +0100)]
Separated user config and effective config.

8 years agoPrepare to separate user config and effective config.
Ulya Trofimovich [Tue, 22 Sep 2015 12:15:31 +0000 (13:15 +0100)]
Prepare to separate user config and effective config.

8 years agoKeep name table together with other options.
Ulya Trofimovich [Mon, 21 Sep 2015 21:14:45 +0000 (22:14 +0100)]
Keep name table together with other options.

8 years agoGrouped options together in a struct.
Ulya Trofimovich [Mon, 21 Sep 2015 20:50:55 +0000 (21:50 +0100)]
Grouped options together in a struct.

8 years agoDocumentation: added warning descriptions to manpage and online manual.
Ulya Trofimovich [Thu, 17 Sep 2015 14:16:38 +0000 (15:16 +0100)]
Documentation: added warning descriptions to manpage and online manual.

8 years agoDocumentation: added warning descriptions to '-h, -?, --help' option.
Ulya Trofimovich [Thu, 17 Sep 2015 14:03:24 +0000 (15:03 +0100)]
Documentation: added warning descriptions to '-h, -?, --help' option.

8 years agoRemoved unused method declaration.
Ulya Trofimovich [Thu, 17 Sep 2015 12:55:46 +0000 (13:55 +0100)]
Removed unused method declaration.

8 years agoGather some DFA statistics and use it to omit unused code with '--skeleton'.
Ulya Trofimovich [Thu, 17 Sep 2015 12:52:09 +0000 (13:52 +0100)]
Gather some DFA statistics and use it to omit unused code with '--skeleton'.

8 years agoOmit usseless 'yyaccept' variable in '--skeleton' programs.
Ulya Trofimovich [Thu, 17 Sep 2015 09:53:35 +0000 (10:53 +0100)]
Omit usseless 'yyaccept' variable in '--skeleton' programs.

Normally re2c generates single 'yyaccept' variable for all conditions.
With '--skeleton' re2c handles conditions separately, so each condition
needs (or needs not) its own 'yyaccept'.

Prior to this commit re2c used the same criterion to determine if
'yyaccept' is needed with '--skeleton' as it uses generally: whether
'yyaccept' was used in any of conditions. Now re2c looks if 'yyaccept'
was used with this particular condition.

8 years agoGenerate better code with '--skeleton': C90-compliant, free resources on errors.
Ulya Trofimovich [Thu, 17 Sep 2015 09:27:57 +0000 (10:27 +0100)]
Generate better code with '--skeleton': C90-compliant, free resources on errors.

8 years agoCheck 'fread' return value in program generated with '--skeleton'.
Ulya Trofimovich [Wed, 16 Sep 2015 11:19:28 +0000 (12:19 +0100)]
Check 'fread' return value in program generated with '--skeleton'.

8 years agoSupport '--skeleton' with conditions and multiple re2c blocks.
Ulya Trofimovich [Wed, 16 Sep 2015 10:25:29 +0000 (11:25 +0100)]
Support '--skeleton' with conditions and multiple re2c blocks.

8 years agoMake 'filesize' function for '--skeleton' preserve original file position.
Ulya Trofimovich [Tue, 15 Sep 2015 12:35:27 +0000 (13:35 +0100)]
Make 'filesize' function for '--skeleton' preserve original file position.

8 years agoFixed MINGW builds where 'sizeof (int)' is equal to 'sizeof (long)'.
Ulya Trofimovich [Tue, 15 Sep 2015 12:08:10 +0000 (13:08 +0100)]
Fixed MINGW builds where 'sizeof (int)' is equal to 'sizeof (long)'.

8 years agoChanged '-Wcondition-order' to warn even if 'YYSETCONDITION' is used.
Ulya Trofimovich [Tue, 15 Sep 2015 10:51:36 +0000 (11:51 +0100)]
Changed '-Wcondition-order' to warn even if 'YYSETCONDITION' is used.

Tests 'condtype_yysetcondition.c{s,g}.re' show the reason why I changed
how '-Wcondition-order' works in presence of 'YYSETCONDITION' calls:
programs generated from these tests work differently depending on
condition numbering. Explicit use of condition names cannot guarantee
that these explicit names were generated by re2c (and not hardcoded as
in these examples).

8 years agoMore accurate handling of default rule for '--skeleton'.
Ulya Trofimovich [Tue, 15 Sep 2015 09:45:19 +0000 (10:45 +0100)]
More accurate handling of default rule for '--skeleton'.

8 years agoThe generated '--skeleton' program now warns about undefined control flow.
Ulya Trofimovich [Mon, 14 Sep 2015 22:11:51 +0000 (23:11 +0100)]
The generated '--skeleton' program now warns about undefined control flow.

8 years agoFixed error in calculation of maximal path length in skeleton.
Ulya Trofimovich [Mon, 14 Sep 2015 14:28:52 +0000 (15:28 +0100)]
Fixed error in calculation of maximal path length in skeleton.

8 years agoCompacted keys representation (with '--skeleton').
Ulya Trofimovich [Mon, 14 Sep 2015 12:19:15 +0000 (13:19 +0100)]
Compacted keys representation (with '--skeleton').

Determine maximal path length and maximal rule number while constructing
skeleton; take maximim of these two values; choose unsigned integer type
of minimal width capable of holding maximim.

Note: re2c operates on exact-width integers, but the generated program
doesn't (it might not have <stdint.h>). When generating the program,
re2c choses one of unsigned 'char', 'short', 'int' and 'long' types
(that one 'sizeof' which is equal to the disired key size). re2c makes
some implicit assumptions (generated program is run on the same platform
as re2c, byte consists of 8 bits, etc.). Perhaps re2c should hardcode
these assumptions in the generated program and check them on start.

8 years agoStore keys for '--skeleton' in binary.
Ulya Trofimovich [Fri, 11 Sep 2015 17:48:35 +0000 (18:48 +0100)]
Store keys for '--skeleton' in binary.

A single key is formed of three values:
    1. the length of string
    2. the length of matched part of string
    3. the number of matched rule
All these values are guaranteed to fit 32 bits, so for now we just
dump them as 'uint32_t' and read as 'unsigned int'. re2c asserts that
'sizeof (uint32_t) == sizeof (unsigned int)'.

Avoid structs, as they cause padding issues.

8 years agoEstimate maximal path length in skeleton and abort if it overflows.
Ulya Trofimovich [Wed, 9 Sep 2015 21:43:31 +0000 (22:43 +0100)]
Estimate maximal path length in skeleton and abort if it overflows.

Maximal skeleton path length is a bit different from YYMAXFILL:
it assumes that loops are iterated once (unlike YYMAXFILL calculation,
which disregards loops) and returns zero for empty regexp.

We need to know it in order:
    - to be sure it won't overflow
    - to store keys in a compact form (yet to be done)

This commit also makes DFA and skeleton store condition name and
source file line corresponding to current condition: it gets quite
annoying to pass these things around. This change caused another
change of test results (line numbers in error messages changed
for tests that use '-r' and reuse old DFA (don't reconstruct DFA
in 'use:re2c' blocks).

8 years agoFixed memleaks (skeleton nodes were not destructed properly).
Ulya Trofimovich [Wed, 9 Sep 2015 15:26:28 +0000 (16:26 +0100)]
Fixed memleaks (skeleton nodes were not destructed properly).

Found with 'make vtests'

8 years agoMake skeleton a part of DFA.
Ulya Trofimovich [Wed, 9 Sep 2015 14:30:09 +0000 (15:30 +0100)]
Make skeleton a part of DFA.

This let us create skeletom right after DFA creation (but befor DFA
has been mangled in different ways), but call skeleton methods any time.

Undefined control flow is now checked at the time of real code generation,
that's why all those tests that use '-r' changed: re2c stopped reporting
'rules:re2c' blocks and reports 'use:re2c' blocks instead.

8 years agoSuffixes of skeleton end nodes should be initialized by algorithm that uses them.
Ulya Trofimovich [Wed, 9 Sep 2015 12:09:25 +0000 (13:09 +0100)]
Suffixes of skeleton end nodes should be initialized by algorithm that uses them.

8 years agoRenamed function.
Ulya Trofimovich [Tue, 8 Sep 2015 16:57:06 +0000 (17:57 +0100)]
Renamed function.

8 years agoA more logical way to update rules when constructing skeleton paths.
Ulya Trofimovich [Tue, 8 Sep 2015 16:33:34 +0000 (17:33 +0100)]
A more logical way to update rules when constructing skeleton paths.

There's no need to keep rule one step behind path's arcs and update
it manually. Also, it is reasonable to set rule in constructor.

8 years agoReduced the time of path generation with '--skeleton'.
Ulya Trofimovich [Tue, 8 Sep 2015 14:14:09 +0000 (15:14 +0100)]
Reduced the time of path generation with '--skeleton'.

The algorithm now stores partially constructed paths in a compact
form and delays expansion until it reaches the end of current
branch of recursion. This has several advantages:
    - no need to store large structures in memory
    - write data to file in large chunks
    - path expansion is faster than step-by-step construction

Speedup is actually tenfold (but the way keys are dumped to file is
still not optimized and spoils benchmarks). Real speedup can be
observed on such files as:
    test/php20150211_zend_ini_scanner_trimmed.icF.re
, which cause ~5Gb dumps. Time has gone down: 8.5m -> 2.5m and will
be furter reduced to ~1m when key dumps are fixed. This will result
in generation speed ~20Mb/s which is quite good.

8 years agoRenamed and restructured various kinds of skeleton paths.
Ulya Trofimovich [Tue, 8 Sep 2015 11:06:52 +0000 (12:06 +0100)]
Renamed and restructured various kinds of skeleton paths.

8 years agoFixed eternal loop in path cover generation algorithm for '--skeleton'.
Ulya Trofimovich [Sun, 6 Sep 2015 21:22:12 +0000 (22:22 +0100)]
Fixed eternal loop in path cover generation algorithm for '--skeleton'.

The simplest example I was able to come up with that reveals eternal
loop is the following:
    /*!re2c
        ( [^acf] | "0b" | "a"[^] | "a0"[^] )+ {}
    */
The problem was caused by my assumption that from any node there is
at least one non-looping path to end node. The assumption is true;
what I didn't take into account was that all such paths may go via
nodes that have already occured twice on the way to current node
(their loop counter is greater than 1). In this case the algorithm
would find no path to end node. Since not all prefixes would have
been covered (exactly none of them) the algorithm would loop forever.

Such branch may be abandoned safely: the algorithm will later find
another path to current state without loops.

As soon as I realized the problem the fix was trivial: if all outgoing
arcs have been exhausted and none of them yielded any results, abandon
current branch.

8 years agoWith '--skeleton', store input data in binary form (rather than C/C++ code).
Ulya Trofimovich [Sat, 5 Sep 2015 08:39:28 +0000 (09:39 +0100)]
With '--skeleton', store input data in binary form (rather than C/C++ code).

There's a limitation on the size of input files for C/C++ compiler and
the compiled binary will have to contain all that data (and thus may grow
very large).

Storing data in binary form and reading it from file dynamically is
the way it should be.

8 years agoWith '-skeleton', dump data to file immediately as it is generated.
Ulya Trofimovich [Fri, 4 Sep 2015 14:07:06 +0000 (15:07 +0100)]
With '-skeleton', dump data to file immediately as it is generated.

This way re2c won't consume memory even on large inputs.

8 years agoChanged '.keys' file format (generated with '--skeleton').
Ulya Trofimovich [Thu, 3 Sep 2015 14:18:45 +0000 (15:18 +0100)]
Changed '.keys' file format (generated with '--skeleton').

Store length of strings instead of pointers to string start and end.

Storing pointers requires us to remember total length of strings already
written to file by the time we want to write next string. This is very
inconvenient if we want to dump strings as we perform DFS on graph:
we'll have to track size all the time (path-cover-generator already does
that, but all-paths-generator doesn't).

This adds a new local variable to the generated code ('token'), which
is used to backup cursor position when enterind DFA.

8 years agoSplit ".data" files (generated with '--skeleton') into two parts.
Ulya Trofimovich [Thu, 3 Sep 2015 12:26:47 +0000 (13:26 +0100)]
Split ".data" files (generated with '--skeleton') into two parts.

This is necessary to dump generated data as soon as possible instead
of keeping it until all data has been generated: we generate input
strings and keys simultaneously, but have to write all input strings
at once as one big string. Keys alone occupy lots of space, so
keeping only keys instead of keys and strings won't help.

8 years agoCombined path cover generation with path cover size estimation.
Ulya Trofimovich [Thu, 3 Sep 2015 11:33:02 +0000 (12:33 +0100)]
Combined path cover generation with path cover size estimation.

We don't have any fallback algorithm in case path cover is too large.
We want to generate some paths anyway, so we have to construct path cover.
We shouldn't generate arbitrary large amounts of data.

8 years agoOmit some highly unlikely conditional exits from deep-first search.
Ulya Trofimovich [Wed, 2 Sep 2015 12:28:48 +0000 (13:28 +0100)]
Omit some highly unlikely conditional exits from deep-first search.

With '--skeleton' re2c builds DFA skeleton and performs DFS in order to
estimate the size of data to be generated. It maintains size counter: as
soon as the counter reaches certain limit, DFS should stop.

Size counter is always checked when recursion returns.
Sometimes it is clear that size counter will overflow upon recursion
return (when arguments overflow already) and DFS can exit early (before
entering recursion).

This commit omits checks of some arguments (and correponding early exits
from DFS): first, path length is very unlikely to overflow (one has to
write/generate a regular expression with length of ~1Gb, in which case
skeleton generation won't be the worst problem); second, the number of
outgoing arcs in each vertex is also highly unlikely to exceed 1Gb limit.

8 years agoSplit large source file into smaller files with distinct functionality.
Ulya Trofimovich [Wed, 2 Sep 2015 12:11:36 +0000 (13:11 +0100)]
Split large source file into smaller files with distinct functionality.

8 years agoNarrowed the scope of ".data" file.
Ulya Trofimovich [Wed, 2 Sep 2015 11:39:47 +0000 (12:39 +0100)]
Narrowed the scope of ".data" file.

8 years agoHid internals of skeleton paths under construction.
Ulya Trofimovich [Wed, 2 Sep 2015 10:44:25 +0000 (11:44 +0100)]
Hid internals of skeleton paths under construction.

8 years agoRenamed and fixed warning about undefined control flow in generated lexer.
Ulya Trofimovich [Tue, 1 Sep 2015 14:27:48 +0000 (15:27 +0100)]
Renamed and fixed warning about undefined control flow in generated lexer.

Renamed '-Wnaked-default' to '-Wundefined-control-flow': the latter sounds
much scarier. :D

Completely changed the algorithm that is used to determine if default case
is not handled properly. Prior to this commit a simple and incorrent criterion
was used: whether there are code units that (alone) do not match any rule.
This gived false positives in cases like this:
    [^] [^] { rule }
here all code units meet the criterion: no single code unit matches a rule.
But obviously, default case is handled properly, because any input string
matches 'rule' (strictly speaking, any input string of length 2 or more, but
that's YYFILL's problem).

The new algorithm is more complex (in terms of time and space), yet it is
less heuristic: re2c parforms exhaustive deep-first-search on graph skeleton
and collects all bad paths.

8 years agoNo need to NULL-terminate array of known size.
Ulya Trofimovich [Fri, 28 Aug 2015 22:15:40 +0000 (23:15 +0100)]
No need to NULL-terminate array of known size.

For some reason (which I yet do not understand) re2c uses size of DFA
state's "kernel" to determine whether a new state should be constructed
or some already constructed state (of the same "kernel" size) will do.

Since re2c knows "kernel" size for each state anyway, there's no need
to NULL-terminate "kernel" array while iterating over it: we can use
pre-calculated size instead.

8 years agoNarrowed scope of local variables.
Ulya Trofimovich [Fri, 28 Aug 2015 22:10:33 +0000 (23:10 +0100)]
Narrowed scope of local variables.

8 years agoSimplified array bounds check.
Ulya Trofimovich [Fri, 28 Aug 2015 22:00:56 +0000 (23:00 +0100)]
Simplified array bounds check.

Comparing against pointer to the end of array is easier than calculating
array length, then setting next-to-last element to NULL and iterating
while not NULL.

8 years agoAnother minor simplification of control flow.
Ulya Trofimovich [Fri, 28 Aug 2015 21:33:51 +0000 (22:33 +0100)]
Another minor simplification of control flow.

8 years agoClarified control flow in nested loops.
Ulya Trofimovich [Fri, 28 Aug 2015 21:03:51 +0000 (22:03 +0100)]
Clarified control flow in nested loops.

8 years agoNarrowed scope of local variables.
Ulya Trofimovich [Fri, 28 Aug 2015 20:52:28 +0000 (21:52 +0100)]
Narrowed scope of local variables.

8 years agoPass signed integer to 'std::setw' to avoid [-Wsign-conversion] warning.
Ulya Trofimovich [Fri, 28 Aug 2015 14:09:35 +0000 (15:09 +0100)]
Pass signed integer to 'std::setw' to avoid [-Wsign-conversion] warning.

8 years agoDon't mix up empty code block with nonexistent one in rule actions.
Ulya Trofimovich [Thu, 27 Aug 2015 22:30:03 +0000 (23:30 +0100)]
Don't mix up empty code block with nonexistent one in rule actions.

Turns out that re2c allows empty code blocks:
    /*!re2c
    <a> "a" :=
    */

re2c up to 0.14.3 handled this correctly (generated empty action).
Since then this behaviour has been broken: re2c started to autogenerate
jump to nonexistent condition.

8 years agoDelay '-Wcondition-order' reporting until we have necessary info.
Ulya Trofimovich [Thu, 27 Aug 2015 13:03:26 +0000 (14:03 +0100)]
Delay '-Wcondition-order' reporting until we have necessary info.

'-Wcondition-order' depends on 'YYSETCONDITION' calls and 'types:re2c'
directive which may occur after condition dispatch is generated.

8 years agoAdded warning '-Wcondition-order'.
Ulya Trofimovich [Thu, 27 Aug 2015 11:42:24 +0000 (12:42 +0100)]
Added warning '-Wcondition-order'.

See parent commit 8c1fe4f0113685b599bf906360814e4715e05447
"Simplified tracking of condition order." for details.