2006-05-25 04:32:20 +00:00
|
|
|
/* $Id: actions.cc,v 1.35 2006/02/25 12:57:50 helly Exp $ */
|
2006-02-24 04:48:15 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
2006-05-25 04:32:20 +00:00
|
|
|
#include <cctype>
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#include "globals.h"
|
|
|
|
#include "parser.h"
|
|
|
|
#include "dfa.h"
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
namespace re2c
|
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void Symbol::ClearTable()
|
|
|
|
{
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
for (SymbolTable::iterator it = symbol_table.begin(); it != symbol_table.end(); ++it)
|
|
|
|
{
|
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
symbol_table.clear();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
Symbol::SymbolTable Symbol::symbol_table;
|
|
|
|
|
|
|
|
Symbol *Symbol::find(const SubStr &str)
|
|
|
|
{
|
|
|
|
const std::string ss(str.to_string());
|
|
|
|
SymbolTable::const_iterator it = symbol_table.find(ss);
|
|
|
|
|
|
|
|
if (it == symbol_table.end())
|
|
|
|
{
|
|
|
|
return (*symbol_table.insert(SymbolTable::value_type(ss, new Symbol(str))).first).second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (*it).second;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void showIns(std::ostream &o, const Ins &i, const Ins &base)
|
|
|
|
{
|
|
|
|
o.width(3);
|
|
|
|
o << &i - &base << ": ";
|
|
|
|
|
|
|
|
switch (i.i.tag)
|
|
|
|
{
|
|
|
|
|
|
|
|
case CHAR:
|
|
|
|
{
|
|
|
|
o << "match ";
|
|
|
|
|
|
|
|
for (const Ins *j = &(&i)[1]; j < (Ins*) i.i.link; ++j)
|
|
|
|
prtCh(o, j->c.value);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GOTO:
|
|
|
|
o << "goto " << ((Ins*) i.i.link - &base);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FORK:
|
|
|
|
o << "fork " << ((Ins*) i.i.link - &base);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CTXT:
|
|
|
|
o << "ctxt";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TERM:
|
|
|
|
o << "term " << ((RuleOp*) i.i.link)->accept;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
o << "\n";
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
uint RegExp::fixedLength()
|
|
|
|
{
|
|
|
|
return ~0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *NullOp::type = "NullOp";
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void NullOp::calcSize(Char*)
|
|
|
|
{
|
|
|
|
size = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
uint NullOp::fixedLength()
|
|
|
|
{
|
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void NullOp::compile(Char*, Ins*)
|
|
|
|
{
|
|
|
|
;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void NullOp::split(CharSet&)
|
|
|
|
{
|
|
|
|
;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
std::ostream& operator<<(std::ostream &o, const Range &r)
|
|
|
|
{
|
|
|
|
if ((r.ub - r.lb) == 1)
|
|
|
|
{
|
|
|
|
prtCh(o, r.lb);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prtCh(o, r.lb);
|
|
|
|
o << "-";
|
|
|
|
prtCh(o, r.ub - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return o << r.next;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
Range *doUnion(Range *r1, Range *r2)
|
|
|
|
{
|
|
|
|
Range *r, **rP = &r;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
Range *s;
|
|
|
|
|
|
|
|
if (r1->lb <= r2->lb)
|
|
|
|
{
|
|
|
|
s = new Range(*r1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
s = new Range(*r2);
|
|
|
|
}
|
|
|
|
|
|
|
|
*rP = s;
|
|
|
|
rP = &s->next;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (r1->lb <= r2->lb)
|
|
|
|
{
|
|
|
|
if (r1->lb > s->ub)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (r1->ub > s->ub)
|
|
|
|
s->ub = r1->ub;
|
|
|
|
|
|
|
|
if (!(r1 = r1->next))
|
|
|
|
{
|
|
|
|
uint ub = 0;
|
|
|
|
|
|
|
|
for (; r2 && r2->lb <= s->ub; r2 = r2->next)
|
|
|
|
ub = r2->ub;
|
|
|
|
|
|
|
|
if (ub > s->ub)
|
|
|
|
s->ub = ub;
|
|
|
|
|
|
|
|
*rP = r2;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (r2->lb > s->ub)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (r2->ub > s->ub)
|
|
|
|
s->ub = r2->ub;
|
|
|
|
|
|
|
|
if (!(r2 = r2->next))
|
|
|
|
{
|
|
|
|
uint ub = 0;
|
|
|
|
|
|
|
|
for (; r1 && r1->lb <= s->ub; r1 = r1->next)
|
|
|
|
ub = r1->ub;
|
|
|
|
|
|
|
|
if (ub > s->ub)
|
|
|
|
s->ub = ub;
|
|
|
|
|
|
|
|
*rP = r1;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
*rP = NULL;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
Range *doDiff(Range *r1, Range *r2)
|
|
|
|
{
|
|
|
|
Range *r, *s, **rP = &r;
|
|
|
|
|
|
|
|
for (; r1; r1 = r1->next)
|
|
|
|
{
|
|
|
|
uint lb = r1->lb;
|
|
|
|
|
|
|
|
for (; r2 && r2->ub <= r1->lb; r2 = r2->next)
|
|
|
|
|
|
|
|
;
|
|
|
|
for (; r2 && r2->lb < r1->ub; r2 = r2->next)
|
|
|
|
{
|
|
|
|
if (lb < r2->lb)
|
|
|
|
{
|
|
|
|
*rP = s = new Range(lb, r2->lb);
|
|
|
|
rP = &s->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((lb = r2->ub) >= r1->ub)
|
|
|
|
goto noMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rP = s = new Range(lb, r1->ub);
|
2006-02-24 04:48:15 +00:00
|
|
|
rP = &s->next;
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
noMore:
|
|
|
|
;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
*rP = NULL;
|
|
|
|
return r;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
MatchOp *merge(MatchOp *m1, MatchOp *m2)
|
|
|
|
{
|
|
|
|
if (!m1)
|
|
|
|
return m2;
|
|
|
|
|
|
|
|
if (!m2)
|
|
|
|
return m1;
|
|
|
|
|
|
|
|
return new MatchOp(doUnion(m1->match, m2->match));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *MatchOp::type = "MatchOp";
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void MatchOp::display(std::ostream &o) const
|
|
|
|
{
|
|
|
|
o << match;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void MatchOp::calcSize(Char *rep)
|
|
|
|
{
|
|
|
|
size = 1;
|
|
|
|
|
|
|
|
for (Range *r = match; r; r = r->next)
|
|
|
|
for (uint c = r->lb; c < r->ub; ++c)
|
|
|
|
if (rep[c] == c)
|
|
|
|
++size;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
uint MatchOp::fixedLength()
|
|
|
|
{
|
|
|
|
return 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void MatchOp::compile(Char *rep, Ins *i)
|
|
|
|
{
|
|
|
|
i->i.tag = CHAR;
|
|
|
|
i->i.link = &i[size];
|
|
|
|
Ins *j = &i[1];
|
|
|
|
uint bump = size;
|
|
|
|
|
|
|
|
for (Range *r = match; r; r = r->next)
|
|
|
|
{
|
|
|
|
for (uint c = r->lb; c < r->ub; ++c)
|
|
|
|
{
|
|
|
|
if (rep[c] == c)
|
|
|
|
{
|
|
|
|
j->c.value = c;
|
|
|
|
j->c.bump = --bump;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MatchOp::split(CharSet &s)
|
|
|
|
{
|
|
|
|
for (Range *r = match; r; r = r->next)
|
|
|
|
{
|
|
|
|
for (uint c = r->lb; c < r->ub; ++c)
|
|
|
|
{
|
|
|
|
CharPtn *x = s.rep[c], *a = x->nxt;
|
|
|
|
|
|
|
|
if (!a)
|
|
|
|
{
|
|
|
|
if (x->card == 1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
x->nxt = a = s.freeHead;
|
|
|
|
|
|
|
|
if (!(s.freeHead = s.freeHead->nxt))
|
|
|
|
s.freeTail = &s.freeHead;
|
|
|
|
|
|
|
|
a->nxt = NULL;
|
|
|
|
|
|
|
|
x->fix = s.fix;
|
|
|
|
|
|
|
|
s.fix = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (--(x->card) == 0)
|
|
|
|
{
|
|
|
|
*s.freeTail = x;
|
|
|
|
*(s.freeTail = &x->nxt) = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
s.rep[c] = a;
|
|
|
|
++(a->card);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
for (; s.fix; s.fix = s.fix->fix)
|
|
|
|
if (s.fix->card)
|
|
|
|
s.fix->nxt = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegExp * mkDiff(RegExp *e1, RegExp *e2)
|
|
|
|
{
|
|
|
|
MatchOp *m1, *m2;
|
|
|
|
|
|
|
|
if (!(m1 = (MatchOp*) e1->isA(MatchOp::type)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!(m2 = (MatchOp*) e2->isA(MatchOp::type)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Range *r = doDiff(m1->match, m2->match);
|
|
|
|
|
|
|
|
return r ? (RegExp*) new MatchOp(r) : (RegExp*) new NullOp;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegExp *doAlt(RegExp *e1, RegExp *e2)
|
|
|
|
{
|
|
|
|
if (!e1)
|
|
|
|
return e2;
|
|
|
|
|
|
|
|
if (!e2)
|
|
|
|
return e1;
|
|
|
|
|
|
|
|
return new AltOp(e1, e2);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
RegExp *mkAlt(RegExp *e1, RegExp *e2)
|
|
|
|
{
|
|
|
|
AltOp *a;
|
|
|
|
MatchOp *m1, *m2;
|
|
|
|
|
|
|
|
if ((a = (AltOp*) e1->isA(AltOp::type)))
|
|
|
|
{
|
|
|
|
if ((m1 = (MatchOp*) a->exp1->isA(MatchOp::type)))
|
|
|
|
e1 = a->exp2;
|
|
|
|
}
|
|
|
|
else if ((m1 = (MatchOp*) e1->isA(MatchOp::type)))
|
|
|
|
{
|
|
|
|
e1 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((a = (AltOp*) e2->isA(AltOp::type)))
|
|
|
|
{
|
|
|
|
if ((m2 = (MatchOp*) a->exp1->isA(MatchOp::type)))
|
|
|
|
e2 = a->exp2;
|
|
|
|
}
|
|
|
|
else if ((m2 = (MatchOp*) e2->isA(MatchOp::type)))
|
|
|
|
{
|
|
|
|
e2 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return doAlt(merge(m1, m2), doAlt(e1, e2));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *AltOp::type = "AltOp";
|
|
|
|
|
|
|
|
void AltOp::calcSize(Char *rep)
|
|
|
|
{
|
|
|
|
exp1->calcSize(rep);
|
|
|
|
exp2->calcSize(rep);
|
|
|
|
size = exp1->size + exp2->size + 2;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
uint AltOp::fixedLength()
|
|
|
|
{
|
|
|
|
uint l1 = exp1->fixedLength();
|
|
|
|
uint l2 = exp1->fixedLength();
|
|
|
|
|
|
|
|
if (l1 != l2 || l1 == ~0u)
|
|
|
|
return ~0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
return l1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void AltOp::compile(Char *rep, Ins *i)
|
|
|
|
{
|
|
|
|
i->i.tag = FORK;
|
|
|
|
Ins *j = &i[exp1->size + 1];
|
|
|
|
i->i.link = &j[1];
|
|
|
|
exp1->compile(rep, &i[1]);
|
|
|
|
j->i.tag = GOTO;
|
|
|
|
j->i.link = &j[exp2->size + 1];
|
|
|
|
exp2->compile(rep, &j[1]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void AltOp::split(CharSet &s)
|
|
|
|
{
|
|
|
|
exp1->split(s);
|
|
|
|
exp2->split(s);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *CatOp::type = "CatOp";
|
|
|
|
|
|
|
|
void CatOp::calcSize(Char *rep)
|
|
|
|
{
|
|
|
|
exp1->calcSize(rep);
|
|
|
|
exp2->calcSize(rep);
|
|
|
|
size = exp1->size + exp2->size;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
uint CatOp::fixedLength()
|
|
|
|
{
|
|
|
|
uint l1, l2;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
if ((l1 = exp1->fixedLength()) != ~0u )
|
|
|
|
if ((l2 = exp2->fixedLength()) != ~0u)
|
|
|
|
return l1 + l2;
|
|
|
|
|
|
|
|
return ~0u;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void CatOp::compile(Char *rep, Ins *i)
|
|
|
|
{
|
|
|
|
exp1->compile(rep, &i[0]);
|
|
|
|
exp2->compile(rep, &i[exp1->size]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void CatOp::split(CharSet &s)
|
|
|
|
{
|
|
|
|
exp1->split(s);
|
|
|
|
exp2->split(s);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *CloseOp::type = "CloseOp";
|
|
|
|
|
|
|
|
void CloseOp::calcSize(Char *rep)
|
|
|
|
{
|
|
|
|
exp->calcSize(rep);
|
|
|
|
size = exp->size + 1;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void CloseOp::compile(Char *rep, Ins *i)
|
|
|
|
{
|
|
|
|
exp->compile(rep, &i[0]);
|
|
|
|
i += exp->size;
|
|
|
|
i->i.tag = FORK;
|
|
|
|
i->i.link = i - exp->size;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void CloseOp::split(CharSet &s)
|
|
|
|
{
|
|
|
|
exp->split(s);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *CloseVOp::type = "CloseVOp";
|
|
|
|
|
|
|
|
void CloseVOp::calcSize(Char *rep)
|
|
|
|
{
|
|
|
|
exp->calcSize(rep);
|
|
|
|
|
|
|
|
if (max >= 0)
|
|
|
|
{
|
|
|
|
size = (exp->size * min) + ((1 + exp->size) * (max - min));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size = (exp->size * min) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloseVOp::compile(Char *rep, Ins *i)
|
|
|
|
{
|
|
|
|
Ins *jumppoint;
|
|
|
|
int st;
|
|
|
|
jumppoint = i + ((1 + exp->size) * (max - min));
|
|
|
|
|
|
|
|
for (st = min; st < max; st++)
|
|
|
|
{
|
|
|
|
i->i.tag = FORK;
|
|
|
|
i->i.link = jumppoint;
|
|
|
|
i++;
|
|
|
|
exp->compile(rep, &i[0]);
|
|
|
|
i += exp->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (st = 0; st < min; st++)
|
|
|
|
{
|
|
|
|
exp->compile(rep, &i[0]);
|
|
|
|
i += exp->size;
|
|
|
|
|
|
|
|
if (max < 0 && st == 0)
|
|
|
|
{
|
|
|
|
i->i.tag = FORK;
|
|
|
|
i->i.link = i - exp->size;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloseVOp::split(CharSet &s)
|
|
|
|
{
|
|
|
|
exp->split(s);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RegExp *expr(Scanner &);
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
uint Scanner::unescape(SubStr &s) const
|
|
|
|
{
|
|
|
|
static const char * hex = "0123456789abcdef";
|
|
|
|
static const char * oct = "01234567";
|
|
|
|
|
|
|
|
s.len--;
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
uint c, ucb = 0;
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
if ((c = *s.str++) != '\\' || s.len == 0)
|
|
|
|
{
|
|
|
|
return xlat(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
s.len--;
|
|
|
|
|
|
|
|
switch (c = *s.str++)
|
|
|
|
{
|
|
|
|
case 'n': return xlat('\n');
|
|
|
|
case 't': return xlat('\t');
|
|
|
|
case 'v': return xlat('\v');
|
|
|
|
case 'b': return xlat('\b');
|
|
|
|
case 'r': return xlat('\r');
|
|
|
|
case 'f': return xlat('\f');
|
|
|
|
case 'a': return xlat('\a');
|
|
|
|
|
|
|
|
case 'x':
|
|
|
|
{
|
|
|
|
if (s.len < 2)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+s.len, "Illegal hexadecimal character code, two hexadecimal digits are required");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *p1 = strchr(hex, tolower(s.str[0]));
|
|
|
|
const char *p2 = strchr(hex, tolower(s.str[1]));
|
|
|
|
|
|
|
|
if (!p1 || !p2)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+(p1?1:0), "Illegal hexadecimal character code");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s.len -= 2;
|
|
|
|
s.str += 2;
|
|
|
|
|
|
|
|
uint v = (uint)((p1 - hex) << 4)
|
|
|
|
+ (uint)((p2 - hex));
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'U':
|
|
|
|
{
|
|
|
|
if (s.len < 8)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+s.len, "Illegal unicode character, eight hexadecimal digits are required");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint l = 0;
|
|
|
|
|
|
|
|
if (s.str[0] == '0')
|
|
|
|
{
|
|
|
|
l++;
|
|
|
|
if (s.str[1] == '0')
|
|
|
|
{
|
|
|
|
l++;
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
if (s.str[2] == '0' || (s.str[2] == '1' && uFlag))
|
2006-05-25 04:32:20 +00:00
|
|
|
{
|
|
|
|
l++;
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
if (uFlag) {
|
|
|
|
const char *u3 = strchr(hex, tolower(s.str[2]));
|
|
|
|
const char *u4 = strchr(hex, tolower(s.str[3]));
|
|
|
|
if (u3 && u4)
|
|
|
|
{
|
|
|
|
ucb = (uint)((u3 - hex) << 20)
|
|
|
|
+ (uint)((u4 - hex) << 16);
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (s.str[3] == '0')
|
2006-05-25 04:32:20 +00:00
|
|
|
{
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l != 4)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+l, "Illegal unicode character, eight hexadecimal digits are required");
|
|
|
|
}
|
|
|
|
|
|
|
|
s.len -= 4;
|
|
|
|
s.str += 4;
|
|
|
|
|
|
|
|
// no break;
|
|
|
|
}
|
|
|
|
case 'X':
|
|
|
|
case 'u':
|
|
|
|
{
|
|
|
|
if (s.len < 4)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+s.len,
|
|
|
|
c == 'X'
|
|
|
|
? "Illegal hexadecimal character code, four hexadecimal digits are required"
|
|
|
|
: "Illegal unicode character, four hexadecimal digits are required");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *p1 = strchr(hex, tolower(s.str[0]));
|
|
|
|
const char *p2 = strchr(hex, tolower(s.str[1]));
|
|
|
|
const char *p3 = strchr(hex, tolower(s.str[2]));
|
|
|
|
const char *p4 = strchr(hex, tolower(s.str[3]));
|
|
|
|
|
|
|
|
if (!p1 || !p2 || !p3 || !p4)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+(p1?1:0)+(p2?1:0)+(p3?1:0),
|
|
|
|
c == 'X'
|
|
|
|
? "Illegal hexadecimal character code, non hexxdecimal digit found"
|
|
|
|
: "Illegal unicode character, non hexadecimal digit found");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s.len -= 4;
|
|
|
|
s.str += 4;
|
|
|
|
|
|
|
|
uint v = (uint)((p1 - hex) << 12)
|
|
|
|
+ (uint)((p2 - hex) << 8)
|
|
|
|
+ (uint)((p3 - hex) << 4)
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
+ (uint)((p4 - hex))
|
|
|
|
+ ucb;
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
if (v >= nRealChars)
|
|
|
|
{
|
|
|
|
fatal(s.ofs(),
|
|
|
|
c == 'X'
|
|
|
|
? "Illegal hexadecimal character code, out of range"
|
|
|
|
: "Illegal unicode character, out of range");
|
|
|
|
}
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
{
|
|
|
|
fatal(s.ofs()-1, "Illegal octal character code, first digit must be 0 thru 3");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case '0':
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
{
|
|
|
|
if (s.len < 2)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+s.len, "Illegal octal character code, three octal digits are required");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *p0 = strchr(oct, c);
|
|
|
|
const char *p1 = strchr(oct, s.str[0]);
|
|
|
|
const char *p2 = strchr(oct, s.str[1]);
|
|
|
|
|
|
|
|
if (!p0 || !p1 || !p2)
|
|
|
|
{
|
|
|
|
fatal(s.ofs()+(p1?1:0), "Illegal octal character code, non octal digit found");
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s.len -= 2;
|
|
|
|
s.str += 2;
|
|
|
|
|
|
|
|
uint v = (uint)((p0 - oct) << 6) + (uint)((p1 - oct) << 3) + (uint)(p2 - oct);
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return xlat(c);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
std::string& Scanner::unescape(SubStr& str_in, std::string& str_out) const
|
|
|
|
{
|
|
|
|
str_out.clear();
|
|
|
|
|
|
|
|
while(str_in.len)
|
|
|
|
{
|
|
|
|
uint c = unescape(str_in);
|
|
|
|
|
|
|
|
if (c > 0xFF)
|
|
|
|
{
|
|
|
|
fatal(str_in.ofs(), "Illegal character");
|
|
|
|
}
|
|
|
|
|
|
|
|
str_out += static_cast<char>(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return str_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
Range * Scanner::getRange(SubStr &s) const
|
|
|
|
{
|
|
|
|
uint lb = unescape(s), ub, xlb, xub, c;
|
|
|
|
|
|
|
|
if (s.len < 2 || *s.str != '-')
|
|
|
|
{
|
|
|
|
ub = lb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s.len--;
|
|
|
|
s.str++;
|
|
|
|
ub = unescape(s);
|
|
|
|
|
|
|
|
if (ub < lb)
|
|
|
|
{
|
|
|
|
uint tmp = lb;
|
|
|
|
lb = ub;
|
|
|
|
ub = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
xlb = xlat(lb);
|
|
|
|
xub = xlat(ub);
|
|
|
|
|
|
|
|
for(c = lb; c <= ub; c++)
|
|
|
|
{
|
|
|
|
if (!(xlb <= xlat(c) && xlat(c) <= ub))
|
|
|
|
{
|
|
|
|
/* range doesn't work */
|
|
|
|
Range * r = new Range(xlb, xlb + 1);
|
|
|
|
for (c = lb + 1; c <= ub; c++)
|
|
|
|
{
|
|
|
|
r = doUnion(r, new Range(xlat(c), xlat(c) + 1));
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lb = xlb;
|
|
|
|
ub = xub;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Range(lb, ub + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegExp * Scanner::matchChar(uint c) const
|
|
|
|
{
|
|
|
|
return new MatchOp(new Range(c, c + 1));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
RegExp * Scanner::strToRE(SubStr s) const
|
|
|
|
{
|
|
|
|
s.len -= 2;
|
|
|
|
s.str += 1;
|
|
|
|
|
|
|
|
if (s.len == 0)
|
|
|
|
return new NullOp;
|
|
|
|
|
|
|
|
RegExp *re = matchChar(unescape(s));
|
|
|
|
|
|
|
|
while (s.len > 0)
|
|
|
|
re = new CatOp(re, matchChar(unescape(s)));
|
|
|
|
|
|
|
|
return re;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
RegExp * Scanner::strToCaseInsensitiveRE(SubStr s) const
|
|
|
|
{
|
|
|
|
s.len -= 2;
|
|
|
|
s.str += 1;
|
|
|
|
|
|
|
|
if (s.len == 0)
|
|
|
|
return new NullOp;
|
|
|
|
|
|
|
|
uint c = unescape(s);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
RegExp *re, *reL, *reU;
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
|
|
|
{
|
|
|
|
reL = matchChar(xlat(tolower(c)));
|
|
|
|
reU = matchChar(xlat(toupper(c)));
|
|
|
|
re = mkAlt(reL, reU);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
re = matchChar(c);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
while (s.len > 0)
|
|
|
|
{
|
|
|
|
uint c = unescape(s);
|
|
|
|
|
|
|
|
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
|
|
|
{
|
|
|
|
reL = matchChar(xlat(tolower(c)));
|
|
|
|
reU = matchChar(xlat(toupper(c)));
|
2006-02-24 04:48:15 +00:00
|
|
|
re = new CatOp(re, mkAlt(reL, reU));
|
2006-05-25 04:32:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
re = new CatOp(re, matchChar(c));
|
|
|
|
}
|
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegExp * Scanner::ranToRE(SubStr s) const
|
|
|
|
{
|
|
|
|
s.len -= 2;
|
|
|
|
s.str += 1;
|
|
|
|
|
|
|
|
if (s.len == 0)
|
|
|
|
return new NullOp;
|
|
|
|
|
|
|
|
Range *r = getRange(s);
|
|
|
|
|
|
|
|
while (s.len > 0)
|
|
|
|
r = doUnion(r, getRange(s));
|
|
|
|
|
|
|
|
return new MatchOp(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegExp * Scanner::invToRE(SubStr s) const
|
|
|
|
{
|
|
|
|
s.len--;
|
|
|
|
s.str++;
|
|
|
|
|
|
|
|
RegExp * any = ranToRE(SubStr(wFlag ? "[\\X0000-\\XFFFF]" : "[\\000-\\377]"));
|
|
|
|
|
|
|
|
if (s.len <= 2)
|
|
|
|
{
|
|
|
|
return any;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegExp * ran = ranToRE(s);
|
|
|
|
RegExp * inv = mkDiff(any, ran);
|
|
|
|
|
|
|
|
delete ran;
|
|
|
|
delete any;
|
|
|
|
|
|
|
|
return inv;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
RegExp * Scanner::mkDot() const
|
|
|
|
{
|
|
|
|
RegExp * any = ranToRE(SubStr(wFlag ? "[\\X0000-\\XFFFF]" : "[\\000-\\377]"));
|
|
|
|
RegExp * ran = matchChar(xlat('\n'));
|
|
|
|
RegExp * inv = mkDiff(any, ran);
|
|
|
|
|
|
|
|
delete ran;
|
|
|
|
delete any;
|
|
|
|
|
|
|
|
return inv;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
const char *RuleOp::type = "RuleOp";
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
RuleOp::RuleOp(RegExp *e, RegExp *c, Token *t, uint a)
|
2006-05-25 04:32:20 +00:00
|
|
|
: exp(e)
|
|
|
|
, ctx(c)
|
|
|
|
, ins(NULL)
|
|
|
|
, accept(a)
|
|
|
|
, code(t)
|
|
|
|
, line(0)
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuleOp::calcSize(Char *rep)
|
|
|
|
{
|
|
|
|
exp->calcSize(rep);
|
|
|
|
ctx->calcSize(rep);
|
|
|
|
size = exp->size + (ctx->size ? ctx->size + 2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuleOp::compile(Char *rep, Ins *i)
|
|
|
|
{
|
|
|
|
ins = i;
|
|
|
|
exp->compile(rep, &i[0]);
|
|
|
|
i += exp->size;
|
|
|
|
if (ctx->size)
|
|
|
|
{
|
|
|
|
i->i.tag = CTXT;
|
|
|
|
i->i.link = &i[1];
|
|
|
|
i++;
|
|
|
|
ctx->compile(rep, &i[0]);
|
|
|
|
i += ctx->size;
|
|
|
|
}
|
|
|
|
i->i.tag = TERM;
|
|
|
|
i->i.link = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuleOp::split(CharSet &s)
|
|
|
|
{
|
|
|
|
exp->split(s);
|
|
|
|
ctx->split(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void optimize(Ins *i)
|
|
|
|
{
|
|
|
|
while (!isMarked(i))
|
|
|
|
{
|
|
|
|
mark(i);
|
|
|
|
|
|
|
|
if (i->i.tag == CHAR)
|
|
|
|
{
|
|
|
|
i = (Ins*) i->i.link;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
else if (i->i.tag == GOTO || i->i.tag == FORK)
|
|
|
|
{
|
|
|
|
Ins *target = (Ins*) i->i.link;
|
|
|
|
optimize(target);
|
|
|
|
|
|
|
|
if (target->i.tag == GOTO)
|
|
|
|
i->i.link = target->i.link == target ? i : target;
|
|
|
|
|
|
|
|
if (i->i.tag == FORK)
|
|
|
|
{
|
|
|
|
Ins *follow = (Ins*) & i[1];
|
|
|
|
optimize(follow);
|
|
|
|
|
|
|
|
if (follow->i.tag == GOTO && follow->i.link == follow)
|
|
|
|
{
|
|
|
|
i->i.tag = GOTO;
|
|
|
|
}
|
|
|
|
else if (i->i.link == i)
|
|
|
|
{
|
|
|
|
i->i.tag = GOTO;
|
|
|
|
i->i.link = follow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void genCode(std::ostream& o, RegExp *re)
|
|
|
|
{
|
|
|
|
genCode(o, 0, re);
|
|
|
|
}
|
|
|
|
|
|
|
|
CharSet::CharSet()
|
|
|
|
: fix(0)
|
|
|
|
, freeHead(0)
|
|
|
|
, freeTail(0)
|
|
|
|
, rep(new CharPtr[nRealChars])
|
|
|
|
, ptn(new CharPtn[nRealChars])
|
|
|
|
{
|
|
|
|
for (uint j = 0; j < nRealChars; ++j)
|
|
|
|
{
|
|
|
|
rep[j] = &ptn[0];
|
|
|
|
ptn[j].nxt = &ptn[j + 1]; /* wrong for j=nRealChars but will be corrected below */
|
|
|
|
ptn[j].card = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
freeHead = &ptn[1];
|
|
|
|
*(freeTail = &ptn[nRealChars - 1].nxt) = NULL;
|
|
|
|
ptn[0].card = nRealChars;
|
|
|
|
ptn[0].nxt = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CharSet::~CharSet()
|
|
|
|
{
|
|
|
|
delete[] rep;
|
|
|
|
delete[] ptn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void genCode(std::ostream& o, uint ind, RegExp *re)
|
|
|
|
{
|
|
|
|
CharSet cs;
|
|
|
|
uint j;
|
|
|
|
|
|
|
|
re->split(cs);
|
|
|
|
/*
|
|
|
|
for(uint k = 0; k < nChars;){
|
|
|
|
for(j = k; ++k < nRealChars && cs.rep[k] == cs.rep[j];);
|
|
|
|
printSpan(cerr, j, k);
|
|
|
|
cerr << "\t" << cs.rep[j] - &cs.ptn[0] << endl;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
*/
|
|
|
|
Char *rep = new Char[nRealChars];
|
|
|
|
|
|
|
|
for (j = 0; j < nRealChars; ++j)
|
|
|
|
{
|
|
|
|
if (!cs.rep[j]->nxt)
|
|
|
|
cs.rep[j]->nxt = &cs.ptn[j];
|
|
|
|
|
|
|
|
rep[j] = (Char) (cs.rep[j]->nxt - &cs.ptn[0]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
re->calcSize(rep);
|
|
|
|
Ins *ins = new Ins[re->size + 1];
|
|
|
|
memset(ins, 0, (re->size + 1)*sizeof(Ins));
|
|
|
|
re->compile(rep, ins);
|
|
|
|
Ins *eoi = &ins[re->size];
|
|
|
|
eoi->i.tag = GOTO;
|
|
|
|
eoi->i.link = eoi;
|
|
|
|
|
|
|
|
optimize(ins);
|
|
|
|
|
|
|
|
for (j = 0; j < re->size;)
|
|
|
|
{
|
|
|
|
unmark(&ins[j]);
|
|
|
|
|
|
|
|
if (ins[j].i.tag == CHAR)
|
|
|
|
{
|
|
|
|
j = (Ins*) ins[j].i.link - ins;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
j++;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
DFA *dfa = new DFA(ins, re->size, 0, nRealChars, rep);
|
|
|
|
dfa->emit(o, ind);
|
|
|
|
delete dfa;
|
|
|
|
delete [] ins;
|
|
|
|
delete [] rep;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
} // end namespace re2c
|
|
|
|
|