raze/tools/re2c/src/ir/regexp/fixed_length.cc
Christoph Oelckers 8c95516224 - added compile tools from GZDoom repo:
- updaterevision for automated revision string generation
- re2c as a prerequisite to use sc_man in the future
- zipdir to automatically generate an engine resource file.
2019-09-22 08:52:30 +02:00

55 lines
788 B
C++

#include "src/util/c99_stdint.h"
#include "src/ir/regexp/regexp.h"
#include "src/ir/regexp/regexp_alt.h"
#include "src/ir/regexp/regexp_cat.h"
#include "src/ir/regexp/regexp_match.h"
#include "src/ir/regexp/regexp_null.h"
namespace re2c
{
uint32_t RegExp::fixedLength ()
{
return ~0u;
}
uint32_t AltOp::fixedLength ()
{
uint32_t l1 = exp1->fixedLength ();
uint32_t l2 = exp1->fixedLength ();
if (l1 != l2 || l1 == ~0u)
{
return ~0u;
}
return l1;
}
uint32_t CatOp::fixedLength ()
{
const uint32_t l1 = exp1->fixedLength ();
if (l1 != ~0u)
{
const uint32_t l2 = exp2->fixedLength ();
if (l2 != ~0u)
{
return l1 + l2;
}
}
return ~0u;
}
uint32_t MatchOp::fixedLength ()
{
return 1;
}
uint32_t NullOp::fixedLength ()
{
return 0;
}
} // end namespace re2c