| 1 |
// Copyright (c) 1996 James Clark |
| 2 |
// See the file copying.txt for copying permission. |
| 3 |
|
| 4 |
#ifndef Interpreter_INCLUDED |
| 5 |
#define Interpreter_INCLUDED 1 |
| 6 |
|
| 7 |
#include "ELObj.h" |
| 8 |
#include "Expression.h" |
| 9 |
#include <OpenSP/Message.h> |
| 10 |
#include <OpenSP/PointerTable.h> |
| 11 |
#include <OpenSP/NamedTable.h> |
| 12 |
#include "Collector.h" |
| 13 |
#include <OpenSP/InputSource.h> |
| 14 |
#include <OpenSP/XcharMap.h> |
| 15 |
#include <OpenSP/Owner.h> |
| 16 |
#include "Style.h" |
| 17 |
#include "SosofoObj.h" |
| 18 |
#include "ProcessingMode.h" |
| 19 |
#include "NumberCache.h" |
| 20 |
#include <OpenSP/HashTable.h> |
| 21 |
#include "FOTBuilder.h" |
| 22 |
#include <OpenSP/Owner.h> |
| 23 |
#include <OpenSP/Boolean.h> |
| 24 |
#include "Node.h" |
| 25 |
#include "GroveManager.h" |
| 26 |
#include "Pattern.h" |
| 27 |
#include <OpenSP/CharMap.h> |
| 28 |
#include "TransformationMode.h" |
| 29 |
|
| 30 |
#ifdef DSSSL_NAMESPACE |
| 31 |
namespace DSSSL_NAMESPACE { |
| 32 |
#endif |
| 33 |
|
| 34 |
class Interpreter; |
| 35 |
|
| 36 |
class Identifier : public Named { |
| 37 |
public: |
| 38 |
enum SyntacticKey { |
| 39 |
notKey, |
| 40 |
keyQuote, |
| 41 |
keyLambda, |
| 42 |
keyIf, |
| 43 |
keyCond, |
| 44 |
keyAnd, |
| 45 |
keyOr, |
| 46 |
keyCase, |
| 47 |
keyLet, |
| 48 |
keyLetStar, |
| 49 |
keyLetrec, |
| 50 |
keyQuasiquote, |
| 51 |
keyUnquote, |
| 52 |
keyUnquoteSplicing, |
| 53 |
keyDefine, |
| 54 |
keyElse, |
| 55 |
keyArrow, |
| 56 |
keySet, |
| 57 |
keyBegin, |
| 58 |
keyThereExists, |
| 59 |
keyForAll, |
| 60 |
keySelectEach, |
| 61 |
keyUnionForEach, |
| 62 |
keyMake, |
| 63 |
keyStyle, |
| 64 |
keyWithMode, |
| 65 |
keyDefineUnit, |
| 66 |
keyQuery, |
| 67 |
keyElement, |
| 68 |
keyDefault, |
| 69 |
keyRoot, |
| 70 |
keyId, |
| 71 |
keyMode, |
| 72 |
keyDeclareInitialValue, |
| 73 |
keyDeclareCharacteristic, |
| 74 |
keyDeclareFlowObjectClass, |
| 75 |
keyDeclareCharCharacteristicAndProperty, |
| 76 |
keyDeclareReferenceValueType, |
| 77 |
keyDeclareDefaultLanguage, |
| 78 |
keyDeclareCharProperty, |
| 79 |
keyDefinePageModel, |
| 80 |
keyDefineColumnSetModel, |
| 81 |
keyDefineLanguage, |
| 82 |
keyAddCharProperties, |
| 83 |
keyUse, |
| 84 |
keyLabel, |
| 85 |
keyContentMap, |
| 86 |
keyIsKeepWithPrevious, |
| 87 |
keyIsKeepWithNext, |
| 88 |
keySpaceBefore, |
| 89 |
keySpaceAfter, |
| 90 |
keyLeftHeader, |
| 91 |
keyCenterHeader, |
| 92 |
keyRightHeader, |
| 93 |
keyLeftFooter, |
| 94 |
keyCenterFooter, |
| 95 |
keyRightFooter, |
| 96 |
keyDestination, |
| 97 |
keyType, |
| 98 |
keyCoalesceId, |
| 99 |
keyIsDisplay, |
| 100 |
keyScale, |
| 101 |
keyMaxWidth, |
| 102 |
keyMaxHeight, |
| 103 |
keyEntitySystemId, |
| 104 |
keyNotationSystemId, |
| 105 |
keyPositionPointX, |
| 106 |
keyPositionPointY, |
| 107 |
keyEscapementDirection, |
| 108 |
keyBreakBeforePriority, |
| 109 |
keyBreakAfterPriority, |
| 110 |
keyOrientation, |
| 111 |
keyLength, |
| 112 |
keyChar, |
| 113 |
keyGlyphId, |
| 114 |
keyIsSpace, |
| 115 |
keyIsRecordEnd, |
| 116 |
keyIsInputTab, |
| 117 |
keyIsInputWhitespace, |
| 118 |
keyIsPunct, |
| 119 |
keyIsDropAfterLineBreak, |
| 120 |
keyIsDropUnlessBeforeLineBreak, |
| 121 |
keyMathClass, |
| 122 |
keyMathFontPosture, |
| 123 |
keyScript, |
| 124 |
keyStretchFactor, |
| 125 |
keyKeep, |
| 126 |
keyBreakBefore, |
| 127 |
keyBreakAfter, |
| 128 |
keyIsMayViolateKeepBefore, |
| 129 |
keyIsMayViolateKeepAfter, |
| 130 |
keyBeforeRowBorder, |
| 131 |
keyAfterRowBorder, |
| 132 |
keyBeforeColumnBorder, |
| 133 |
keyAfterColumnBorder, |
| 134 |
keyColumnNumber, |
| 135 |
keyRowNumber, |
| 136 |
keyNColumnsSpanned, |
| 137 |
keyNRowsSpanned, |
| 138 |
keyWidth, |
| 139 |
keyIsStartsRow, |
| 140 |
keyIsEndsRow, |
| 141 |
keyTableWidth, |
| 142 |
keyMultiModes, |
| 143 |
keyData, |
| 144 |
keyMin, |
| 145 |
keyMax, |
| 146 |
keyIsConditional, |
| 147 |
keyPriority, |
| 148 |
keyGridNRows, |
| 149 |
keyGridNColumns, |
| 150 |
keyRadical, |
| 151 |
keyNull, |
| 152 |
keyIsRcs, |
| 153 |
keyParent, |
| 154 |
keyActive, |
| 155 |
keyAttributes, |
| 156 |
keyChildren, |
| 157 |
keyRepeat, |
| 158 |
keyPosition, |
| 159 |
keyOnly, |
| 160 |
keyClass, |
| 161 |
keyImportance, |
| 162 |
keyDeclareClassAttribute, |
| 163 |
keyDeclareIdAttribute, |
| 164 |
keyDeclareFlowObjectMacro, |
| 165 |
keyOrElement, |
| 166 |
keyPositionPreference, |
| 167 |
keyCollate, |
| 168 |
keyToupper, |
| 169 |
keyTolower, |
| 170 |
keySymbol, |
| 171 |
keyOrder, |
| 172 |
keyForward, |
| 173 |
keyBackward, |
| 174 |
keyWhitePoint, |
| 175 |
keyBlackPoint, |
| 176 |
keyRange, |
| 177 |
keyRangeAbc, |
| 178 |
keyRangeLmn, |
| 179 |
keyRangeA, |
| 180 |
keyDecodeAbc, |
| 181 |
keyDecodeLmn, |
| 182 |
keyDecodeA, |
| 183 |
keyMatrixAbc, |
| 184 |
keyMatrixLmn, |
| 185 |
keyMatrixA, |
| 186 |
keyArchitecture, |
| 187 |
keyDefineTransliterationMap, |
| 188 |
keyNode, |
| 189 |
keySubgrove, |
| 190 |
keyAdd, |
| 191 |
keyRemove, |
| 192 |
keySub, |
| 193 |
keySortChildren, |
| 194 |
keyOptional, |
| 195 |
keyUnique, |
| 196 |
keyProperty, |
| 197 |
keyResultPath, |
| 198 |
}; |
| 199 |
enum { lastSyntacticKey = keyWithMode }; |
| 200 |
Identifier(const StringC &name); |
| 201 |
// Return 0 is value can't yet be computed. |
| 202 |
ELObj *computeValue(bool force, Interpreter &) const; |
| 203 |
ELObj *computeBuiltinValue(bool force, Interpreter &) const; |
| 204 |
bool syntacticKey(SyntacticKey &) const; |
| 205 |
void setSyntacticKey(SyntacticKey); |
| 206 |
bool defined(unsigned &, Location &) const; |
| 207 |
void setDefinition(Owner<Expression> &, unsigned part, const Location &); |
| 208 |
void setBuiltinDefinition(Owner<Expression> &, unsigned part, const Location &); |
| 209 |
void setValue(ELObj *, unsigned defPart = unsigned(-1)); |
| 210 |
bool evaluated() const; |
| 211 |
const ConstPtr<InheritedC> &inheritedC() const; |
| 212 |
bool inheritedCDefined(unsigned &, Location &) const; |
| 213 |
bool charNICDefined(unsigned &, Location &) const; |
| 214 |
void setCharNIC(unsigned, const Location &); |
| 215 |
void setInheritedC(const ConstPtr<InheritedC> &); |
| 216 |
void setInheritedC(const ConstPtr<InheritedC> &, unsigned, const Location &); |
| 217 |
FlowObj *flowObj() const; |
| 218 |
bool flowObjDefined(unsigned &, Location &) const; |
| 219 |
void setFlowObj(FlowObj *); |
| 220 |
void setFlowObj(FlowObj *, unsigned part, const Location &); |
| 221 |
void setFeature(int); |
| 222 |
bool requireFeature(Interpreter &, const Location &, bool fo = 0) const; |
| 223 |
private: |
| 224 |
unsigned defPart_; |
| 225 |
Owner<Expression> def_; |
| 226 |
InsnPtr insn_; |
| 227 |
// Value in top-level environment. |
| 228 |
ELObj *value_; // must be permanent |
| 229 |
FlowObj *flowObj_; // prototype FlowObj with this name |
| 230 |
unsigned flowObjPart_; |
| 231 |
Location flowObjLoc_; |
| 232 |
Location defLoc_; |
| 233 |
SyntacticKey syntacticKey_; |
| 234 |
bool beingComputed_; |
| 235 |
bool charNIC_; |
| 236 |
ConstPtr<InheritedC> inheritedC_; |
| 237 |
unsigned inheritedCPart_; |
| 238 |
Location inheritedCLoc_; |
| 239 |
void maybeSaveBuiltin(); |
| 240 |
Identifier *builtin_; |
| 241 |
static bool preferBuiltin_; |
| 242 |
friend class Interpreter; |
| 243 |
// FIXME This should be Interpreter::Feature |
| 244 |
int feature_; |
| 245 |
}; |
| 246 |
|
| 247 |
class Unit : public Named { |
| 248 |
public: |
| 249 |
Unit(const StringC &); |
| 250 |
void setValue(long); |
| 251 |
void setValue(double); |
| 252 |
bool defined(unsigned &, Location &) const; |
| 253 |
// return 0 if it can't be done |
| 254 |
ELObj *resolveQuantity(bool force, Interpreter &, double val, int unitExp); |
| 255 |
ELObj *resolveQuantity(bool force, Interpreter &, long val, int valExp); |
| 256 |
void setDefinition(Owner<Expression> &, unsigned part, const Location &); |
| 257 |
private: |
| 258 |
void tryCompute(bool force, Interpreter &); |
| 259 |
static bool scale(long val, int valExp, long num, long &result); |
| 260 |
|
| 261 |
unsigned defPart_; |
| 262 |
Location defLoc_; |
| 263 |
Owner<Expression> def_; |
| 264 |
InsnPtr insn_; |
| 265 |
enum { |
| 266 |
notComputed, |
| 267 |
beingComputed, |
| 268 |
computedExact, |
| 269 |
computedInexact, |
| 270 |
computedError |
| 271 |
} computed_; |
| 272 |
union { |
| 273 |
long exact_; |
| 274 |
double inexact_; |
| 275 |
}; |
| 276 |
int dim_; |
| 277 |
}; |
| 278 |
|
| 279 |
class ELObjDynamicRoot : public Collector::DynamicRoot { |
| 280 |
public: |
| 281 |
ELObjDynamicRoot(Collector &c, ELObj *obj = 0) |
| 282 |
: Collector::DynamicRoot(c), obj_(obj) { } |
| 283 |
void operator=(ELObj *obj) { obj_ = obj; } |
| 284 |
operator ELObj *() const { return obj_; } |
| 285 |
private: |
| 286 |
void trace(Collector &) const; |
| 287 |
ELObj *obj_; |
| 288 |
}; |
| 289 |
|
| 290 |
struct CharPart { |
| 291 |
Char c; |
| 292 |
unsigned defPart; |
| 293 |
}; |
| 294 |
|
| 295 |
struct ELObjPart { |
| 296 |
ELObjPart(); |
| 297 |
ELObjPart(ELObj *x, unsigned y); |
| 298 |
void operator=(const ELObjPart &); |
| 299 |
bool operator==(const ELObjPart &) const; |
| 300 |
bool operator!=(const ELObjPart &) const; |
| 301 |
ELObj *obj; |
| 302 |
unsigned defPart; |
| 303 |
}; |
| 304 |
|
| 305 |
class CharPropValues { |
| 306 |
public: |
| 307 |
virtual bool setDefault(const StringC &, const Location &, |
| 308 |
ELObj *, Interpreter &)=0; |
| 309 |
virtual bool setValue(const StringC &,const StringC &,const Location &, |
| 310 |
ELObj *, Interpreter &)=0; |
| 311 |
virtual ELObj *value(Char, Interpreter &) const =0; |
| 312 |
virtual ELObj *defaultValue(Interpreter &) const =0; |
| 313 |
}; |
| 314 |
|
| 315 |
// These have to be in the header file, see Interpreter. |
| 316 |
|
| 317 |
class IntegerCharPropValues : public CharPropValues { |
| 318 |
public: |
| 319 |
IntegerCharPropValues(long def=0) |
| 320 |
: def_(def) {} |
| 321 |
long getValue(Char) const; |
| 322 |
void setRange(Char, Char, long); |
| 323 |
private: |
| 324 |
IntegerCharPropValues(const IntegerCharPropValues &); // Undefined. |
| 325 |
IntegerCharPropValues &operator=(const IntegerCharPropValues &); // Undefined |
| 326 |
long def_; |
| 327 |
struct ValT_ { |
| 328 |
long l_; |
| 329 |
bool hasValue_; |
| 330 |
ValT_() : hasValue_(false) {} |
| 331 |
ValT_(long l) : hasValue_(true), l_(l) {} |
| 332 |
bool operator==(const ValT_ &v) const |
| 333 |
{ return (hasValue_==v.hasValue_) && (!hasValue_ || l_==v.l_); } |
| 334 |
bool operator!=(const ValT_& v) const |
| 335 |
{ return !(*this == v); } |
| 336 |
}; |
| 337 |
CharMap<ValT_> map_; |
| 338 |
|
| 339 |
bool setDefault(const StringC &, const Location &, |
| 340 |
ELObj *, Interpreter &); |
| 341 |
bool setValue(const StringC &, const StringC &, const Location &, |
| 342 |
ELObj *,Interpreter &); |
| 343 |
ELObj *value(Char, Interpreter &) const; |
| 344 |
ELObj *defaultValue(Interpreter &) const; |
| 345 |
}; |
| 346 |
|
| 347 |
class MaybeIntegerCharPropValues : public CharPropValues { |
| 348 |
public: |
| 349 |
MaybeIntegerCharPropValues(bool defFalse=true, long def=0) |
| 350 |
: defFalse_(defFalse), def_(def) {} |
| 351 |
// Returns true and sets 2nd arg if not #f, otherwise returns false. |
| 352 |
bool getValue(Char, long &) const; |
| 353 |
void setRange(Char, Char, long); |
| 354 |
void setValue(Char, long); |
| 355 |
private: |
| 356 |
MaybeIntegerCharPropValues(const MaybeIntegerCharPropValues &); // Undefined. |
| 357 |
MaybeIntegerCharPropValues &operator=(const MaybeIntegerCharPropValues &); |
| 358 |
// Above undefined. |
| 359 |
long def_; |
| 360 |
bool defFalse_; |
| 361 |
struct ValT_ { |
| 362 |
long l_; |
| 363 |
bool hasValue_; |
| 364 |
bool isFalse_; |
| 365 |
ValT_() : hasValue_(false) {} |
| 366 |
ValT_(long l) : l_(l), hasValue_(true), isFalse_(false) {} |
| 367 |
bool operator==(const ValT_ &v) const |
| 368 |
{ return (hasValue_==v.hasValue_) |
| 369 |
&& (!hasValue_ || (isFalse_ && v.isFalse_) || l_==v.l_); } |
| 370 |
bool operator!=(const ValT_& v) const |
| 371 |
{ return !(*this == v); } |
| 372 |
}; |
| 373 |
CharMap<ValT_> map_; |
| 374 |
bool setDefault(const StringC &, const Location &, |
| 375 |
ELObj *, Interpreter &); |
| 376 |
bool setValue(const StringC &, const StringC &, const Location &, |
| 377 |
ELObj *,Interpreter &); |
| 378 |
ELObj *value(Char, Interpreter &) const; |
| 379 |
ELObj *defaultValue(Interpreter &) const; |
| 380 |
}; |
| 381 |
|
| 382 |
class BooleanCharPropValues : public CharPropValues { |
| 383 |
public: |
| 384 |
BooleanCharPropValues(bool def=false) |
| 385 |
: def_(def) {} |
| 386 |
bool getValue(Char) const; |
| 387 |
void setRange(Char, Char, bool); |
| 388 |
private: |
| 389 |
BooleanCharPropValues(const BooleanCharPropValues &); // Undefined. |
| 390 |
BooleanCharPropValues &operator=(const BooleanCharPropValues &); // Undefined. |
| 391 |
bool def_; |
| 392 |
struct ValT_ { |
| 393 |
bool b_:1; |
| 394 |
bool hasValue_:1; |
| 395 |
ValT_() : hasValue_(false) {} |
| 396 |
ValT_(bool b) : b_(b), hasValue_(true) {} |
| 397 |
bool operator==(const ValT_ &v) const |
| 398 |
{ return (hasValue_==v.hasValue_) && (!hasValue_ || b_==v.b_); } |
| 399 |
bool operator!=(const ValT_& v) const |
| 400 |
{ return !(*this == v); } |
| 401 |
}; |
| 402 |
CharMap<ValT_> map_; |
| 403 |
|
| 404 |
bool setDefault(const StringC &, const Location &, |
| 405 |
ELObj *, Interpreter &); |
| 406 |
bool setValue(const StringC &, const StringC &, const Location &, |
| 407 |
ELObj *,Interpreter &); |
| 408 |
ELObj *value(Char, Interpreter &) const; |
| 409 |
ELObj *defaultValue(Interpreter &) const; |
| 410 |
}; |
| 411 |
|
| 412 |
class PublicIdCharPropValues : public CharPropValues { |
| 413 |
public: |
| 414 |
PublicIdCharPropValues(FOTBuilder::PublicId def=0) |
| 415 |
: def_(def) {} |
| 416 |
FOTBuilder::PublicId getValue(Char) const; |
| 417 |
void setRange(Char, Char, const FOTBuilder::PublicId); |
| 418 |
private: |
| 419 |
PublicIdCharPropValues(const PublicIdCharPropValues &); // Undefined. |
| 420 |
PublicIdCharPropValues &operator=(const PublicIdCharPropValues &); // Undefined. |
| 421 |
FOTBuilder::PublicId def_; |
| 422 |
struct ValT_ { |
| 423 |
FOTBuilder::PublicId p_; |
| 424 |
bool hasValue_; |
| 425 |
ValT_() : hasValue_(false) {} |
| 426 |
ValT_(FOTBuilder::PublicId p) |
| 427 |
: hasValue_(true), p_(p) {} |
| 428 |
bool operator==(const ValT_ &v) const |
| 429 |
{ return (hasValue_==v.hasValue_) && (!hasValue_ || p_==v.p_); } |
| 430 |
bool operator!=(const ValT_& v) const |
| 431 |
{ return !(*this == v); } |
| 432 |
}; |
| 433 |
CharMap<ValT_> map_; |
| 434 |
bool setDefault(const StringC &, const Location &, |
| 435 |
ELObj *, Interpreter &); |
| 436 |
bool setValue(const StringC &, const StringC &, const Location &, |
| 437 |
ELObj *,Interpreter &); |
| 438 |
ELObj *value(Char, Interpreter &) const; |
| 439 |
ELObj *defaultValue(Interpreter &) const; |
| 440 |
}; |
| 441 |
|
| 442 |
class SymbolCharPropValues : public CharPropValues { |
| 443 |
public: |
| 444 |
SymbolCharPropValues(FOTBuilder::Symbol def=FOTBuilder::symbolFalse) |
| 445 |
: def_(def) {} |
| 446 |
FOTBuilder::Symbol getValue(Char) const; |
| 447 |
void setRange(Char, Char, FOTBuilder::Symbol); |
| 448 |
private: |
| 449 |
SymbolCharPropValues(const SymbolCharPropValues &); // Undefined. |
| 450 |
SymbolCharPropValues &operator=(const SymbolCharPropValues &); // Undefined. |
| 451 |
FOTBuilder::Symbol def_; |
| 452 |
struct ValT_ { |
| 453 |
FOTBuilder::Symbol s_; |
| 454 |
bool hasValue_; |
| 455 |
ValT_() : hasValue_(false) {} |
| 456 |
ValT_(FOTBuilder::Symbol s) |
| 457 |
: hasValue_(true), s_(s) {} |
| 458 |
bool operator==(const ValT_ &v) const |
| 459 |
{ return (hasValue_==v.hasValue_) && (!hasValue_ || s_==v.s_); } |
| 460 |
bool operator!=(const ValT_& v) const |
| 461 |
{ return !(*this == v); } |
| 462 |
}; |
| 463 |
CharMap<ValT_> map_; |
| 464 |
bool setDefault(const StringC &, const Location &, |
| 465 |
ELObj *, Interpreter &); |
| 466 |
bool setValue(const StringC &, const StringC &, const Location &, |
| 467 |
ELObj *,Interpreter &); |
| 468 |
ELObj *value(Char, Interpreter &) const; |
| 469 |
ELObj *defaultValue(Interpreter &) const; |
| 470 |
}; |
| 471 |
|
| 472 |
class CharProp : public Named { |
| 473 |
public: |
| 474 |
CharProp(const StringC& name); |
| 475 |
|
| 476 |
// def is used if char doesn't have property. If def==0, property default |
| 477 |
// value is used. |
| 478 |
ELObj *value(Char ch,ELObj *def, const Location &, Interpreter &); |
| 479 |
|
| 480 |
// Use only before compile is called. |
| 481 |
// Set value for characters in string. |
| 482 |
void setValue(StringC &,Owner<Expression> &,unsigned,const Location&); |
| 483 |
void declare(Owner<Expression> &, unsigned, const Location&, |
| 484 |
CharPropValues * =0); |
| 485 |
void declarePredefined(CharPropValues *); |
| 486 |
bool hasAddedValue(Char,unsigned&,Location&) const; |
| 487 |
bool declared(unsigned&,Location&) const; |
| 488 |
|
| 489 |
void compile(Interpreter &); |
| 490 |
protected: |
| 491 |
enum computedType_ { |
| 492 |
notComputed, |
| 493 |
beingComputed, |
| 494 |
computedError, |
| 495 |
computedOK |
| 496 |
}; |
| 497 |
|
| 498 |
// Default value. |
| 499 |
unsigned defPart_; |
| 500 |
Location defLoc_; |
| 501 |
Owner<Expression> defExpr_; |
| 502 |
computedType_ defComputed_; |
| 503 |
|
| 504 |
// Added properties. |
| 505 |
struct addedProp_ { |
| 506 |
StringC chars_; |
| 507 |
unsigned part_; |
| 508 |
Location loc_; |
| 509 |
Owner<Expression> expr_; |
| 510 |
computedType_ computed_; |
| 511 |
}; |
| 512 |
// Have to store in NCVector because of Owner non-copyable. |
| 513 |
NCVector<addedProp_> addedPropsVec_; |
| 514 |
// We have to store indices, since NCVector isn't really NC (ofcourse). |
| 515 |
Owner<CharMap<NCVector<addedProp_>::size_type> > addedProps_; |
| 516 |
enum { noAddedVal_ = NCVector<addedProp_>::size_type(-1) }; |
| 517 |
CharPropValues *values_; |
| 518 |
// True if errors when compiling any of the added values. |
| 519 |
bool hadError_; |
| 520 |
|
| 521 |
void compileDef_(Interpreter &); |
| 522 |
void compileAdded_(addedProp_ &,Interpreter &); |
| 523 |
const addedProp_ *added_(Char) const; |
| 524 |
private: |
| 525 |
CharProp(const CharProp &); // Undefined. |
| 526 |
CharProp &operator=(const CharProp &); // Undefined. |
| 527 |
}; |
| 528 |
|
| 529 |
class Interpreter : |
| 530 |
public Collector, |
| 531 |
public Pattern::MatchContext, |
| 532 |
public NumberCache, |
| 533 |
public Messenger { |
| 534 |
public: |
| 535 |
enum PortName { |
| 536 |
portNumerator, |
| 537 |
portDenominator, |
| 538 |
portPreSup, |
| 539 |
portPreSub, |
| 540 |
portPostSup, |
| 541 |
portPostSub, |
| 542 |
portMidSup, |
| 543 |
portMidSub, |
| 544 |
portOverMark, |
| 545 |
portUnderMark, |
| 546 |
portOpen, |
| 547 |
portClose, |
| 548 |
portDegree, |
| 549 |
portOperator, |
| 550 |
portLowerLimit, |
| 551 |
portUpperLimit, |
| 552 |
portHeader, |
| 553 |
portFooter |
| 554 |
}; |
| 555 |
enum { nPortNames = portFooter + 1 }; |
| 556 |
Interpreter(GroveManager *, Messenger *, int unitsPerInch, bool debugMode, |
| 557 |
bool dsssl2, bool style, bool strictMode, |
| 558 |
const FOTBuilder::Description &); |
| 559 |
void endPart(); |
| 560 |
void dEndPart(); |
| 561 |
FalseObj *makeFalse(); |
| 562 |
TrueObj *makeTrue(); |
| 563 |
NilObj *makeNil(); |
| 564 |
SymbolObj *makeSymbol(const StringC &); |
| 565 |
KeywordObj *makeKeyword(const StringC &); |
| 566 |
IntegerObj *makeInteger(long n); |
| 567 |
ErrorObj *makeError(); |
| 568 |
UnspecifiedObj *makeUnspecified(); |
| 569 |
PairObj *makePair(ELObj *, ELObj *); |
| 570 |
ELObj *convertGlyphId(const Char *, size_t, const Location &); |
| 571 |
bool isError(const ELObj *) const; |
| 572 |
bool isUnspecified(const ELObj *) const; |
| 573 |
CharObj *makeChar(Char); |
| 574 |
ELObj *makeLengthSpec(const FOTBuilder::LengthSpec &); |
| 575 |
AddressObj *makeAddressNone(); |
| 576 |
NodeListObj *makeEmptyNodeList(); |
| 577 |
void dispatchMessage(Message &); |
| 578 |
void dispatchMessage(const Message &); |
| 579 |
Identifier *lookup(const StringC &); |
| 580 |
Unit *lookupUnit(const StringC &); |
| 581 |
FunctionObj *lookupExternalProc(const StringC &); |
| 582 |
CharProp *lookupCharProperty(const StringC &); |
| 583 |
int unitsPerInch() const; |
| 584 |
unsigned currentPartIndex() const; |
| 585 |
const FOTBuilder::Description &fotbDescr() const; |
| 586 |
void compile(const NodePtr &); |
| 587 |
static StringC makeStringC(const char *); |
| 588 |
SymbolObj *portName(PortName); |
| 589 |
ELObj *cValueSymbol(FOTBuilder::Symbol); |
| 590 |
void compileCharProperties(); |
| 591 |
// Map of LexCategory |
| 592 |
XcharMap<char> lexCategory_; |
| 593 |
static void normalizeGeneralName(const NodePtr &, StringC &); |
| 594 |
GroveManager *groveManager() const; |
| 595 |
StyleObj *initialStyle() const; |
| 596 |
StyleObj *borderTrueStyle() const; |
| 597 |
StyleObj *borderFalseStyle() const; |
| 598 |
bool convertBooleanC(ELObj *, const Identifier *, const Location &, bool &); |
| 599 |
bool convertPublicIdC(ELObj *, const Identifier *, const Location &, |
| 600 |
FOTBuilder::PublicId &); |
| 601 |
bool convertStringC(ELObj *, const Identifier *, const Location &, StringC &); |
| 602 |
bool convertLengthC(ELObj *, const Identifier *, const Location &, FOTBuilder::Length &); |
| 603 |
bool convertLengthSpecC(ELObj *, const Identifier *, const Location &, FOTBuilder::LengthSpec &); |
| 604 |
bool convertLetter2C(ELObj *, const Identifier *, const Location &, FOTBuilder::Letter2 &); |
| 605 |
bool convertOptLengthSpecC(ELObj *, const Identifier *, const Location &, FOTBuilder::OptLengthSpec &); |
| 606 |
bool convertCharC(ELObj *, const Identifier *, const Location &, Char &); |
| 607 |
bool convertColorC(ELObj *, const Identifier *, const Location &, ColorObj *&); |
| 608 |
bool convertOptColorC(ELObj *, const Identifier *, const Location &, ColorObj *&); |
| 609 |
// FIXME allow inexact value |
| 610 |
bool convertIntegerC(ELObj *, const Identifier *, const Location &, long &); |
| 611 |
bool convertOptPositiveIntegerC(ELObj *, const Identifier *, const Location &, long &); |
| 612 |
bool convertRealC(ELObj *, const Identifier *, const Location &, double &); |
| 613 |
bool convertEnumC(const FOTBuilder::Symbol *, size_t, |
| 614 |
ELObj *, const Identifier *, const Location &, FOTBuilder::Symbol &); |
| 615 |
bool convertEnumC(ELObj *, const Identifier *, const Location &, FOTBuilder::Symbol &); |
| 616 |
void invalidCharacteristicValue(const Identifier *ident, const Location &loc); |
| 617 |
bool convertLengthSpec(ELObj *, FOTBuilder::LengthSpec &); |
| 618 |
bool convertToPattern(ELObj *, const Location &, Pattern &); |
| 619 |
const ConstPtr<InheritedC> &charMapC() const; |
| 620 |
const ConstPtr<InheritedC> &tableBorderC() const; |
| 621 |
const ConstPtr<InheritedC> &cellBeforeRowBorderC() const; |
| 622 |
const ConstPtr<InheritedC> &cellAfterRowBorderC() const; |
| 623 |
const ConstPtr<InheritedC> &cellBeforeColumnBorderC() const; |
| 624 |
const ConstPtr<InheritedC> &cellAfterColumnBorderC() const; |
| 625 |
const ConstPtr<InheritedC> &fractionBarC() const; |
| 626 |
const char *storePublicId(const Char *, size_t, const Location &); |
| 627 |
unsigned allocGlyphSubstTableUniqueId(); |
| 628 |
bool lookupNodeProperty(const StringC &, ComponentName::Id &); |
| 629 |
bool debugMode() const; |
| 630 |
bool dsssl2() const; |
| 631 |
bool style() const; |
| 632 |
bool strictMode() const; |
| 633 |
void setNodeLocation(const NodePtr &); |
| 634 |
void setDefaultLanguage(Owner<Expression> &,unsigned part,const Location &); |
| 635 |
ELObj *defaultLanguage() const; |
| 636 |
bool defaultLanguageSet(unsigned &,Location &) const; |
| 637 |
void compileDefaultLanguage(); |
| 638 |
void makeReadOnly(ELObj *); |
| 639 |
ProcessingMode *lookupProcessingMode(const StringC &); |
| 640 |
ProcessingMode *initialProcessingMode(); |
| 641 |
TransformationMode *transformationMode(); |
| 642 |
void addClassAttributeName(const StringC &name); |
| 643 |
void addIdAttributeName(const StringC &name); |
| 644 |
void installInitialValue(Identifier *, Owner<Expression> &); |
| 645 |
void installExtensionInheritedC(Identifier *, const StringC &, const Location &); |
| 646 |
CharPropValues *installExtensionCharNIC(Identifier *, const StringC &, |
| 647 |
const Location &); |
| 648 |
void installExtensionFlowObjectClass(Identifier *, const StringC &, const Location &); |
| 649 |
// Return 0 if an invalid number. |
| 650 |
ELObj *convertNumber(const StringC &, int radix = 10); |
| 651 |
bool convertCharName(const StringC &str, Char &c) const; |
| 652 |
enum LexCategory { |
| 653 |
lexLetter, // a - z A - Z |
| 654 |
lexOtherNameStart, // !$%&*/<=>?~_^: |
| 655 |
lexAddNameStart, |
| 656 |
lexDigit, // 0-9 |
| 657 |
lexOtherNumberStart, // -+. |
| 658 |
lexOther, |
| 659 |
lexDelimiter, // ;()" |
| 660 |
lexWhiteSpace, |
| 661 |
lexAddWhiteSpace |
| 662 |
}; |
| 663 |
LexCategory lexCategory(Xchar); |
| 664 |
void addStandardChar(const StringC &, const StringC &); |
| 665 |
void addSdataEntity(const StringC &, const StringC &, const StringC &); |
| 666 |
void addNameChar(const StringC &); |
| 667 |
void addSeparatorChar(const StringC &); |
| 668 |
void setCharRepertoire(const StringC &); |
| 669 |
enum Feature { |
| 670 |
noFeature, |
| 671 |
combineChar, |
| 672 |
keyword, |
| 673 |
multiSource, |
| 674 |
multiResult, |
| 675 |
regexp, |
| 676 |
word, |
| 677 |
hytime, |
| 678 |
charset, |
| 679 |
expression, |
| 680 |
multiProcess, |
| 681 |
query, |
| 682 |
sideBySide, |
| 683 |
sideline, |
| 684 |
alignedColumn, |
| 685 |
bidi, |
| 686 |
vertical, |
| 687 |
math, |
| 688 |
table, |
| 689 |
tableAutoWidth, |
| 690 |
simplePage, |
| 691 |
page, |
| 692 |
multiColumn, |
| 693 |
nestedColumnSet, |
| 694 |
generalIndirect, |
| 695 |
inlineNote, |
| 696 |
glyphAnnotation, |
| 697 |
emphasizingMark, |
| 698 |
includedContainer, |
| 699 |
actualCharacteristic, |
| 700 |
online, |
| 701 |
fontInfo, |
| 702 |
crossReference |
| 703 |
}; |
| 704 |
enum { nFeatures = crossReference + 1 }; |
| 705 |
enum Support { |
| 706 |
notSupported, |
| 707 |
partiallySupported, |
| 708 |
supported |
| 709 |
}; |
| 710 |
struct Status { |
| 711 |
bool declared; |
| 712 |
Support supported; |
| 713 |
StringC rcsname; |
| 714 |
StringC appname; |
| 715 |
}; |
| 716 |
bool convertFeature(const StringC &, Feature &); |
| 717 |
void explicitFeatures(); |
| 718 |
void declareFeature(const StringC &); |
| 719 |
void declareFeature(const Feature &); |
| 720 |
bool requireFeature(const Feature &, const Location &); |
| 721 |
enum Module { |
| 722 |
baseabs, |
| 723 |
prlgabs0, |
| 724 |
prlgabs1, |
| 725 |
instabs, |
| 726 |
basesds0, |
| 727 |
basesds1, |
| 728 |
instsds0, |
| 729 |
subdcabs, |
| 730 |
sdclabs, |
| 731 |
sdclsds, |
| 732 |
prlgsds, |
| 733 |
instsds1, |
| 734 |
dtgabs, |
| 735 |
rankabs, |
| 736 |
srabs, |
| 737 |
srsds, |
| 738 |
linkabs, |
| 739 |
linksds, |
| 740 |
subdcsds, |
| 741 |
fpiabs |
| 742 |
}; |
| 743 |
enum { nModules = fpiabs + 1 }; |
| 744 |
void explicitModules(); |
| 745 |
void addModule(const StringC &); |
| 746 |
private: |
| 747 |
Interpreter(const Interpreter &); // undefined |
| 748 |
void operator=(const Interpreter &); // undefined |
| 749 |
void installSyntacticKeys(); |
| 750 |
void installPortNames(); |
| 751 |
void installCValueSymbols(); |
| 752 |
void installPrimitives(); |
| 753 |
void installPrimitive(const char *, PrimitiveObj *, Feature f); |
| 754 |
void installXPrimitive(const char *, const char *, PrimitiveObj *); |
| 755 |
void installBuiltins(); |
| 756 |
void installUnits(); |
| 757 |
void installCharNames(); |
| 758 |
void installInheritedCs(); |
| 759 |
void installInheritedC(const char *, InheritedC *); |
| 760 |
void installInheritedCProc(const Identifier *); |
| 761 |
void installFlowObjs(); |
| 762 |
void installSdata(); |
| 763 |
void installNodeProperties(); |
| 764 |
void installCharProperties(); |
| 765 |
void installFeatures(const FOTBuilder::Feature *); |
| 766 |
void installModules(); |
| 767 |
void checkGrovePlan(); |
| 768 |
void compileInitialValues(); |
| 769 |
bool sdataMap(GroveString, GroveString, GroveChar &) const; |
| 770 |
static bool convertUnicodeCharName(const StringC &str, Char &c); |
| 771 |
bool convertToPattern(ELObj *obj, const Location &loc, |
| 772 |
bool isChild, IList<Pattern::Element> &list); |
| 773 |
bool patternAddAttributeQualifiers(ELObj *obj, |
| 774 |
const Location &loc, |
| 775 |
Pattern::Element &elem); |
| 776 |
enum { |
| 777 |
convertAllowBoolean = 01, |
| 778 |
convertAllowSymbol = 02, |
| 779 |
convertAllowNumber = 04 |
| 780 |
}; |
| 781 |
ELObj *convertFromString(ELObj *, unsigned hints, const Location &); |
| 782 |
ELObj *convertNumberFloat(const StringC &); |
| 783 |
bool scanSignDigits(const StringC &str, size_t &i, int &n); |
| 784 |
Unit *scanUnit(const StringC &str, size_t i, int &unitExp); |
| 785 |
|
| 786 |
NilObj *theNilObj_; |
| 787 |
TrueObj *theTrueObj_; |
| 788 |
FalseObj *theFalseObj_; |
| 789 |
ErrorObj *theErrorObj_; |
| 790 |
UnspecifiedObj *theUnspecifiedObj_; |
| 791 |
typedef PointerTable<SymbolObj *, StringC, Hash, SymbolObj> |
| 792 |
SymbolTable; |
| 793 |
SymbolTable symbolTable_; |
| 794 |
NamedTable<Identifier> identTable_; |
| 795 |
NamedTable<Unit> unitTable_; |
| 796 |
HashTable<StringC,FunctionObj *> externalProcTable_; |
| 797 |
Messenger *messenger_; |
| 798 |
const FOTBuilder::Description &fotbDescr_; |
| 799 |
unsigned partIndex_; |
| 800 |
unsigned dPartIndex_; |
| 801 |
int unitsPerInch_; |
| 802 |
unsigned nInheritedC_; |
| 803 |
GroveManager *groveManager_; |
| 804 |
ProcessingMode initialProcessingMode_; |
| 805 |
NamedTable<ProcessingMode> processingModeTable_; |
| 806 |
SymbolObj *portNames_[nPortNames]; |
| 807 |
ELObj *cValueSymbols_[FOTBuilder::nSymbols]; |
| 808 |
HashTable<StringC, CharPart> namedCharTable_; |
| 809 |
HashTable<StringC, CharPart> sdataEntityNameTable_; |
| 810 |
HashTable<StringC, CharPart> sdataEntityTextTable_; |
| 811 |
Vector<const Identifier *> initialValueNames_; |
| 812 |
NCVector<Owner<Expression> > initialValueValues_; |
| 813 |
size_t currentPartFirstInitialValue_; |
| 814 |
StyleObj *initialStyle_; |
| 815 |
StyleObj *borderTrueStyle_; |
| 816 |
StyleObj *borderFalseStyle_; |
| 817 |
ConstPtr<InheritedC> charMapC_; |
| 818 |
ConstPtr<InheritedC> tableBorderC_; |
| 819 |
ConstPtr<InheritedC> cellBeforeRowBorderC_; |
| 820 |
ConstPtr<InheritedC> cellAfterRowBorderC_; |
| 821 |
ConstPtr<InheritedC> cellBeforeColumnBorderC_; |
| 822 |
ConstPtr<InheritedC> cellAfterColumnBorderC_; |
| 823 |
ConstPtr<InheritedC> fractionBarC_; |
| 824 |
class StringSet { |
| 825 |
public: |
| 826 |
StringSet(); |
| 827 |
const char *store(String<char> &); |
| 828 |
static unsigned long hash(const String<char> &); |
| 829 |
static inline const String<char> &key(const String<char> &str) { return str; } |
| 830 |
private: |
| 831 |
OwnerTable<String<char>, String<char>, StringSet, StringSet> table_; |
| 832 |
}; |
| 833 |
StringSet publicIds_; |
| 834 |
unsigned nextGlyphSubstTableUniqueId_; |
| 835 |
AddressObj *addressNoneObj_; |
| 836 |
NodeListObj *emptyNodeListObj_; |
| 837 |
HashTable<StringC,int> nodePropertyTable_; |
| 838 |
bool debugMode_; |
| 839 |
bool dsssl2_; |
| 840 |
bool style_; |
| 841 |
bool strictMode_; |
| 842 |
ELObj *defaultLanguage_; |
| 843 |
Owner<Expression> defaultLanguageDef_; |
| 844 |
unsigned defaultLanguageDefPart_; |
| 845 |
Location defaultLanguageDefLoc_; |
| 846 |
friend class Identifier; |
| 847 |
NamedTable<CharProp> charPropTable_; |
| 848 |
|
| 849 |
// No access function, since this is not a character NIC. |
| 850 |
MaybeIntegerCharPropValues numericEquivCPV_; |
| 851 |
#define CP(t, n) \ |
| 852 |
private: t ## CharPropValues n ## CPV_; \ |
| 853 |
public: const t ## CharPropValues &n () const \ |
| 854 |
{ return n ## CPV_; } |
| 855 |
CP(Boolean, isSpace); |
| 856 |
CP(Boolean, isRecordEnd); |
| 857 |
CP(Boolean, isBlank); |
| 858 |
CP(Boolean, isInputTab); |
| 859 |
CP(Boolean, isInputWhitespace); |
| 860 |
CP(Boolean, isPunct); |
| 861 |
CP(PublicId, script); |
| 862 |
// FIXME! Shall not be PUblicId, but GlyphId. |
| 863 |
CP(PublicId, glyphId); |
| 864 |
CP(Boolean, isDropAfterLineBreak); |
| 865 |
CP(Boolean, isDropUnlessBeforeLineBreak); |
| 866 |
CP(Integer, breakBeforePriority); |
| 867 |
CP(Integer, breakAfterPriority); |
| 868 |
CP(Symbol, mathClass); |
| 869 |
CP(Symbol, mathFontPosture); |
| 870 |
|
| 871 |
Status feature_[nFeatures]; |
| 872 |
bool explicitFeatures_; |
| 873 |
Status module_[nModules]; |
| 874 |
bool explicitModules_; |
| 875 |
TransformationMode transformationMode_; |
| 876 |
}; |
| 877 |
|
| 878 |
inline |
| 879 |
ErrorObj *Interpreter::makeError() |
| 880 |
{ |
| 881 |
return theErrorObj_; |
| 882 |
} |
| 883 |
|
| 884 |
inline |
| 885 |
bool Interpreter::isError(const ELObj *obj) const |
| 886 |
{ |
| 887 |
return obj == theErrorObj_; |
| 888 |
} |
| 889 |
|
| 890 |
inline |
| 891 |
bool Interpreter::isUnspecified(const ELObj *obj) const |
| 892 |
{ |
| 893 |
return obj == theUnspecifiedObj_; |
| 894 |
} |
| 895 |
|
| 896 |
inline |
| 897 |
FalseObj *Interpreter::makeFalse() |
| 898 |
{ |
| 899 |
return theFalseObj_; |
| 900 |
} |
| 901 |
|
| 902 |
inline |
| 903 |
TrueObj *Interpreter::makeTrue() |
| 904 |
{ |
| 905 |
return theTrueObj_; |
| 906 |
} |
| 907 |
|
| 908 |
inline |
| 909 |
NilObj *Interpreter::makeNil() |
| 910 |
{ |
| 911 |
return theNilObj_; |
| 912 |
} |
| 913 |
|
| 914 |
inline |
| 915 |
UnspecifiedObj *Interpreter::makeUnspecified() |
| 916 |
{ |
| 917 |
return theUnspecifiedObj_; |
| 918 |
} |
| 919 |
|
| 920 |
inline |
| 921 |
IntegerObj *Interpreter::makeInteger(long n) |
| 922 |
{ |
| 923 |
return new (*this) IntegerObj(n); |
| 924 |
} |
| 925 |
|
| 926 |
inline |
| 927 |
PairObj *Interpreter::makePair(ELObj *car, ELObj *cdr) |
| 928 |
{ |
| 929 |
return new (*this) PairObj(car, cdr); |
| 930 |
} |
| 931 |
|
| 932 |
inline |
| 933 |
CharObj *Interpreter::makeChar(Char c) |
| 934 |
{ |
| 935 |
return new (*this) CharObj(c); |
| 936 |
} |
| 937 |
|
| 938 |
inline |
| 939 |
AddressObj *Interpreter::makeAddressNone() |
| 940 |
{ |
| 941 |
return addressNoneObj_; |
| 942 |
} |
| 943 |
|
| 944 |
inline |
| 945 |
NodeListObj *Interpreter::makeEmptyNodeList() |
| 946 |
{ |
| 947 |
return emptyNodeListObj_; |
| 948 |
} |
| 949 |
|
| 950 |
inline |
| 951 |
ELObj *Interpreter::cValueSymbol(FOTBuilder::Symbol sym) |
| 952 |
{ |
| 953 |
return cValueSymbols_[sym]; |
| 954 |
} |
| 955 |
|
| 956 |
inline |
| 957 |
SymbolObj *Interpreter::portName(PortName i) |
| 958 |
{ |
| 959 |
return portNames_[i]; |
| 960 |
} |
| 961 |
|
| 962 |
inline |
| 963 |
ProcessingMode *Interpreter::initialProcessingMode() |
| 964 |
{ |
| 965 |
return &initialProcessingMode_; |
| 966 |
} |
| 967 |
|
| 968 |
inline |
| 969 |
int Interpreter::unitsPerInch() const |
| 970 |
{ |
| 971 |
return unitsPerInch_; |
| 972 |
} |
| 973 |
|
| 974 |
inline |
| 975 |
unsigned Interpreter::currentPartIndex() const |
| 976 |
{ |
| 977 |
return partIndex_; |
| 978 |
} |
| 979 |
|
| 980 |
inline |
| 981 |
const FOTBuilder::Description &Interpreter::fotbDescr() const |
| 982 |
{ |
| 983 |
return fotbDescr_; |
| 984 |
} |
| 985 |
|
| 986 |
inline |
| 987 |
KeywordObj *Interpreter::makeKeyword(const StringC &str) |
| 988 |
{ |
| 989 |
return new (*this) KeywordObj(lookup(str)); |
| 990 |
} |
| 991 |
|
| 992 |
inline |
| 993 |
StyleObj *Interpreter::initialStyle() const |
| 994 |
{ |
| 995 |
return initialStyle_; |
| 996 |
} |
| 997 |
|
| 998 |
inline |
| 999 |
StyleObj *Interpreter::borderTrueStyle() const |
| 1000 |
{ |
| 1001 |
return borderTrueStyle_; |
| 1002 |
} |
| 1003 |
|
| 1004 |
inline |
| 1005 |
StyleObj *Interpreter::borderFalseStyle() const |
| 1006 |
{ |
| 1007 |
return borderFalseStyle_; |
| 1008 |
} |
| 1009 |
|
| 1010 |
inline |
| 1011 |
GroveManager *Interpreter::groveManager() const |
| 1012 |
{ |
| 1013 |
return groveManager_; |
| 1014 |
} |
| 1015 |
|
| 1016 |
inline |
| 1017 |
const ConstPtr<InheritedC> &Interpreter::charMapC() const |
| 1018 |
{ |
| 1019 |
return charMapC_; |
| 1020 |
} |
| 1021 |
|
| 1022 |
inline |
| 1023 |
const ConstPtr<InheritedC> &Interpreter::tableBorderC() const |
| 1024 |
{ |
| 1025 |
return tableBorderC_; |
| 1026 |
} |
| 1027 |
|
| 1028 |
inline |
| 1029 |
const ConstPtr<InheritedC> &Interpreter::cellBeforeRowBorderC() const |
| 1030 |
{ |
| 1031 |
return cellBeforeRowBorderC_; |
| 1032 |
} |
| 1033 |
|
| 1034 |
inline |
| 1035 |
const ConstPtr<InheritedC> &Interpreter::cellAfterRowBorderC() const |
| 1036 |
{ |
| 1037 |
return cellAfterRowBorderC_; |
| 1038 |
} |
| 1039 |
|
| 1040 |
inline |
| 1041 |
const ConstPtr<InheritedC> &Interpreter::cellBeforeColumnBorderC() const |
| 1042 |
{ |
| 1043 |
return cellBeforeColumnBorderC_; |
| 1044 |
} |
| 1045 |
|
| 1046 |
inline |
| 1047 |
const ConstPtr<InheritedC> &Interpreter::cellAfterColumnBorderC() const |
| 1048 |
{ |
| 1049 |
return cellAfterColumnBorderC_; |
| 1050 |
} |
| 1051 |
|
| 1052 |
inline |
| 1053 |
const ConstPtr<InheritedC> &Interpreter::fractionBarC() const |
| 1054 |
{ |
| 1055 |
return fractionBarC_; |
| 1056 |
} |
| 1057 |
|
| 1058 |
inline |
| 1059 |
FunctionObj *Interpreter::lookupExternalProc(const StringC &pubid) |
| 1060 |
{ |
| 1061 |
FunctionObj *const *func = externalProcTable_.lookup(pubid); |
| 1062 |
return func ? *func : 0; |
| 1063 |
} |
| 1064 |
|
| 1065 |
inline |
| 1066 |
unsigned Interpreter::allocGlyphSubstTableUniqueId() |
| 1067 |
{ |
| 1068 |
return nextGlyphSubstTableUniqueId_++; |
| 1069 |
} |
| 1070 |
|
| 1071 |
inline |
| 1072 |
bool Interpreter::debugMode() const |
| 1073 |
{ |
| 1074 |
return debugMode_; |
| 1075 |
} |
| 1076 |
|
| 1077 |
inline |
| 1078 |
bool Interpreter::dsssl2() const |
| 1079 |
{ |
| 1080 |
return dsssl2_; |
| 1081 |
} |
| 1082 |
|
| 1083 |
inline |
| 1084 |
bool Interpreter::style() const |
| 1085 |
{ |
| 1086 |
return style_; |
| 1087 |
} |
| 1088 |
|
| 1089 |
inline |
| 1090 |
bool Interpreter::strictMode() const |
| 1091 |
{ |
| 1092 |
return strictMode_; |
| 1093 |
} |
| 1094 |
|
| 1095 |
inline |
| 1096 |
void Interpreter::makeReadOnly(ELObj *obj) |
| 1097 |
{ |
| 1098 |
if (dsssl2()) |
| 1099 |
Collector::makeReadOnly(obj); |
| 1100 |
} |
| 1101 |
|
| 1102 |
inline |
| 1103 |
void Interpreter::addClassAttributeName(const StringC &name) |
| 1104 |
{ |
| 1105 |
classAttributeNames_.push_back(name); |
| 1106 |
} |
| 1107 |
|
| 1108 |
inline |
| 1109 |
void Interpreter::addIdAttributeName(const StringC &name) |
| 1110 |
{ |
| 1111 |
idAttributeNames_.push_back(name); |
| 1112 |
} |
| 1113 |
|
| 1114 |
inline |
| 1115 |
Interpreter::LexCategory Interpreter::lexCategory(Xchar c) |
| 1116 |
{ |
| 1117 |
return LexCategory(lexCategory_[c]); |
| 1118 |
} |
| 1119 |
|
| 1120 |
inline |
| 1121 |
bool Identifier::syntacticKey(SyntacticKey &key) const |
| 1122 |
{ |
| 1123 |
if (syntacticKey_ == notKey) |
| 1124 |
return 0; |
| 1125 |
key = syntacticKey_; |
| 1126 |
return 1; |
| 1127 |
} |
| 1128 |
|
| 1129 |
inline |
| 1130 |
void Identifier::setSyntacticKey(SyntacticKey key) |
| 1131 |
{ |
| 1132 |
syntacticKey_ = key; |
| 1133 |
} |
| 1134 |
|
| 1135 |
inline |
| 1136 |
bool Identifier::evaluated() const |
| 1137 |
{ |
| 1138 |
return value_ != 0; |
| 1139 |
} |
| 1140 |
|
| 1141 |
inline |
| 1142 |
const ConstPtr<InheritedC> &Identifier::inheritedC() const |
| 1143 |
{ |
| 1144 |
return inheritedC_; |
| 1145 |
} |
| 1146 |
|
| 1147 |
inline |
| 1148 |
bool Identifier::inheritedCDefined(unsigned &part, Location &loc) const |
| 1149 |
{ |
| 1150 |
if (inheritedC_.isNull()) |
| 1151 |
return 0; |
| 1152 |
part = inheritedCPart_; |
| 1153 |
loc = inheritedCLoc_; |
| 1154 |
return 1; |
| 1155 |
} |
| 1156 |
|
| 1157 |
inline |
| 1158 |
bool Identifier::charNICDefined(unsigned &part, Location &loc) const |
| 1159 |
{ |
| 1160 |
if (!charNIC_) |
| 1161 |
return 0; |
| 1162 |
part = inheritedCPart_; |
| 1163 |
loc = inheritedCLoc_; |
| 1164 |
return 1; |
| 1165 |
} |
| 1166 |
|
| 1167 |
inline |
| 1168 |
void Identifier::setCharNIC(unsigned part, |
| 1169 |
const Location &loc) |
| 1170 |
{ |
| 1171 |
charNIC_ = 1; |
| 1172 |
inheritedC_ = ConstPtr<InheritedC>(0); |
| 1173 |
inheritedCPart_ = part; |
| 1174 |
inheritedCLoc_ = loc; |
| 1175 |
} |
| 1176 |
|
| 1177 |
inline |
| 1178 |
void Identifier::setInheritedC(const ConstPtr<InheritedC> &ic, unsigned part, |
| 1179 |
const Location &loc) |
| 1180 |
{ |
| 1181 |
inheritedC_ = ic; |
| 1182 |
inheritedCPart_ = part; |
| 1183 |
inheritedCLoc_ = loc; |
| 1184 |
} |
| 1185 |
|
| 1186 |
inline |
| 1187 |
void Identifier::setInheritedC(const ConstPtr<InheritedC> &ic) |
| 1188 |
{ |
| 1189 |
inheritedC_ = ic; |
| 1190 |
inheritedCPart_ = unsigned(-1); |
| 1191 |
inheritedCLoc_ = Location(); |
| 1192 |
} |
| 1193 |
|
| 1194 |
inline |
| 1195 |
FlowObj *Identifier::flowObj() const |
| 1196 |
{ |
| 1197 |
return flowObj_; |
| 1198 |
} |
| 1199 |
|
| 1200 |
inline |
| 1201 |
bool Identifier::flowObjDefined(unsigned &part, Location &loc) const |
| 1202 |
{ |
| 1203 |
if (!flowObj_) |
| 1204 |
return 0; |
| 1205 |
part = flowObjPart_; |
| 1206 |
loc = flowObjLoc_; |
| 1207 |
return 1; |
| 1208 |
} |
| 1209 |
|
| 1210 |
inline |
| 1211 |
void Identifier::setFlowObj(FlowObj *fo) |
| 1212 |
{ |
| 1213 |
flowObj_ = fo; |
| 1214 |
flowObjPart_ = unsigned(-1); |
| 1215 |
} |
| 1216 |
|
| 1217 |
inline |
| 1218 |
void Identifier::setFlowObj(FlowObj *fo, unsigned part, const Location &loc) |
| 1219 |
{ |
| 1220 |
flowObj_ = fo; |
| 1221 |
flowObjPart_ = part; |
| 1222 |
flowObjLoc_ = loc; |
| 1223 |
} |
| 1224 |
|
| 1225 |
inline |
| 1226 |
ELObjPart::ELObjPart() |
| 1227 |
: obj(0), defPart(0) |
| 1228 |
{ |
| 1229 |
} |
| 1230 |
|
| 1231 |
inline |
| 1232 |
ELObjPart::ELObjPart(ELObj *o, unsigned p) |
| 1233 |
: obj(o), defPart(p) |
| 1234 |
{ |
| 1235 |
} |
| 1236 |
|
| 1237 |
inline |
| 1238 |
void ELObjPart::operator=(const ELObjPart &x) |
| 1239 |
{ |
| 1240 |
obj = x.obj; |
| 1241 |
defPart = x.defPart; |
| 1242 |
} |
| 1243 |
|
| 1244 |
inline |
| 1245 |
bool ELObjPart::operator==(const ELObjPart &x) const |
| 1246 |
{ |
| 1247 |
return defPart == x.defPart && obj && x.obj && ELObj::eqv(*obj, *x.obj); |
| 1248 |
} |
| 1249 |
|
| 1250 |
inline |
| 1251 |
bool ELObjPart::operator!=(const ELObjPart &x) const |
| 1252 |
{ |
| 1253 |
return !(*this == x); |
| 1254 |
} |
| 1255 |
|
| 1256 |
inline |
| 1257 |
long IntegerCharPropValues::getValue(Char ch) const |
| 1258 |
{ |
| 1259 |
ValT_ v(map_[ch]); |
| 1260 |
if (v.hasValue_) |
| 1261 |
return v.l_; |
| 1262 |
else |
| 1263 |
return def_; |
| 1264 |
} |
| 1265 |
|
| 1266 |
inline |
| 1267 |
void IntegerCharPropValues::setRange(Char from, Char to, long l) |
| 1268 |
{ |
| 1269 |
map_.setRange(from, to, l); |
| 1270 |
} |
| 1271 |
|
| 1272 |
inline |
| 1273 |
bool MaybeIntegerCharPropValues::getValue(Char ch, long &l) const |
| 1274 |
{ |
| 1275 |
ValT_ v(map_[ch]); |
| 1276 |
if (v.hasValue_) { |
| 1277 |
if (!v.isFalse_) |
| 1278 |
l = v.l_; |
| 1279 |
return !v.isFalse_; |
| 1280 |
} |
| 1281 |
l = def_; |
| 1282 |
return true; |
| 1283 |
} |
| 1284 |
|
| 1285 |
inline |
| 1286 |
void MaybeIntegerCharPropValues::setRange(Char from, Char to, long l) |
| 1287 |
{ |
| 1288 |
map_.setRange(from, to, l); |
| 1289 |
} |
| 1290 |
|
| 1291 |
inline |
| 1292 |
void MaybeIntegerCharPropValues::setValue(Char ch, long l) |
| 1293 |
{ |
| 1294 |
map_.setChar(ch, l); |
| 1295 |
} |
| 1296 |
|
| 1297 |
inline |
| 1298 |
bool BooleanCharPropValues::getValue(Char ch) const |
| 1299 |
{ |
| 1300 |
ValT_ v(map_[ch]); |
| 1301 |
if (v.hasValue_) |
| 1302 |
return v.b_; |
| 1303 |
return def_; |
| 1304 |
} |
| 1305 |
|
| 1306 |
inline |
| 1307 |
void BooleanCharPropValues::setRange(Char from, Char to, bool b) |
| 1308 |
{ |
| 1309 |
map_.setRange(from, to, b); |
| 1310 |
} |
| 1311 |
|
| 1312 |
inline |
| 1313 |
FOTBuilder::PublicId PublicIdCharPropValues::getValue(Char ch) const |
| 1314 |
{ |
| 1315 |
ValT_ v(map_[ch]); |
| 1316 |
if (v.hasValue_) |
| 1317 |
return v.p_; |
| 1318 |
return def_; |
| 1319 |
} |
| 1320 |
|
| 1321 |
inline |
| 1322 |
void PublicIdCharPropValues::setRange(Char from, Char to, |
| 1323 |
FOTBuilder::PublicId p) |
| 1324 |
{ |
| 1325 |
map_.setRange(from, to, p); |
| 1326 |
} |
| 1327 |
|
| 1328 |
inline |
| 1329 |
FOTBuilder::Symbol SymbolCharPropValues::getValue(Char ch) const |
| 1330 |
{ |
| 1331 |
ValT_ v(map_[ch]); |
| 1332 |
if (v.hasValue_) |
| 1333 |
return v.s_; |
| 1334 |
return def_; |
| 1335 |
} |
| 1336 |
|
| 1337 |
inline |
| 1338 |
void SymbolCharPropValues::setRange(Char from, Char to, |
| 1339 |
FOTBuilder::Symbol s) |
| 1340 |
{ |
| 1341 |
map_.setRange(from, to, s); |
| 1342 |
} |
| 1343 |
|
| 1344 |
inline |
| 1345 |
CharProp::CharProp(const StringC &name) |
| 1346 |
: Named(name), defComputed_(notComputed), values_(0), |
| 1347 |
hadError_(false) |
| 1348 |
{ |
| 1349 |
} |
| 1350 |
|
| 1351 |
#ifdef DSSSL_NAMESPACE |
| 1352 |
} |
| 1353 |
#endif |
| 1354 |
|
| 1355 |
#endif /* not Interpreter_INCLUDED */ |