00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "ParseText.h"
00028 #include "ParseNode.h"
00029 #include "BaseClasses.h"
00030 #include "ASN1Codes.h"
00031 #include "Root.h"
00032 #include "Groups.h"
00033 #include <ctype.h>
00034 #include "Ingredients.h"
00035 #include "Text.h"
00036 #include "Engine.h"
00037 #include "Logging.h"
00038
00039
00040 #ifndef WIN32
00041 #define stricmp strcasecmp
00042 #endif
00043
00044
00045 MHParseText::MHParseText(QByteArray &program)
00046 {
00047 m_data = program;
00048 m_lineCount = 1;
00049 m_String = (unsigned char*)malloc(100);
00050 m_p = 0;
00051 }
00052
00053 MHParseText::~MHParseText()
00054 {
00055 free(m_String);
00056 }
00057
00058
00059 void MHParseText::GetNextChar()
00060 {
00061 if (m_p >= m_data.size())
00062 m_ch = EOF;
00063 else m_ch = m_data[m_p++];
00064 }
00065
00066
00067 #define MAX_TAG_LENGTH 30
00068
00069 const char *rchTagNames[] =
00070 {
00071 ":Application",
00072 ":Scene",
00073 ":StdID",
00074 ":StdVersion",
00075 ":ObjectInfo",
00076 ":OnStartUp",
00077 ":OnCloseDown",
00078 ":OrigGCPriority",
00079 ":Items",
00080 ":ResidentPrg",
00081 ":RemotePrg",
00082 ":InterchgPrg",
00083 ":Palette",
00084 ":Font",
00085 ":CursorShape",
00086 ":BooleanVar",
00087 ":IntegerVar",
00088 ":OStringVar",
00089 ":ObjectRefVar",
00090 ":ContentRefVar",
00091 ":Link",
00092 ":Stream",
00093 ":Bitmap",
00094 ":LineArt",
00095 ":DynamicLineArt",
00096 ":Rectangle",
00097 ":Hotspot",
00098 ":SwitchButton",
00099 ":PushButton",
00100 ":Text",
00101 ":EntryField",
00102 ":HyperText",
00103 ":Slider",
00104 ":TokenGroup",
00105 ":ListGroup",
00106 ":OnSpawnCloseDown",
00107 ":OnRestart",
00108 "",
00109 ":CharacterSet",
00110 ":BackgroundColour",
00111 ":TextCHook",
00112 ":TextColour",
00113 ":Font",
00114 ":FontAttributes",
00115 ":InterchgPrgCHook",
00116 ":StreamCHook",
00117 ":BitmapCHook",
00118 ":LineArtCHook",
00119 ":ButtonRefColour",
00120 ":HighlightRefColour",
00121 ":SliderRefColour",
00122 ":InputEventReg",
00123 ":SceneCS",
00124 ":AspectRatio",
00125 ":MovingCursor",
00126 ":NextScenes",
00127 ":InitiallyActive",
00128 ":CHook",
00129 ":OrigContent",
00130 ":Shared",
00131 ":ContentSize",
00132 ":CCPriority",
00133 "" ,
00134 ":LinkEffect",
00135 ":Name",
00136 ":InitiallyAvailable",
00137 ":ProgramConnectionTag",
00138 ":OrigValue",
00139 ":ObjectRef",
00140 ":ContentRef",
00141 ":MovementTable",
00142 ":TokenGroupItems",
00143 ":NoTokenActionSlots",
00144 ":Positions",
00145 ":WrapAround",
00146 ":MultipleSelection",
00147 ":OrigBoxSize",
00148 ":OrigPosition",
00149 ":OrigPaletteRef",
00150 ":Tiling",
00151 ":OrigTransparency",
00152 ":BBBox",
00153 ":OrigLineWidth",
00154 ":OrigLineStyle",
00155 ":OrigRefLineColour",
00156 ":OrigRefFillColour",
00157 ":OrigFont",
00158 ":HJustification",
00159 ":VJustification",
00160 ":LineOrientation",
00161 ":StartCorner",
00162 ":TextWrapping",
00163 ":Multiplex",
00164 ":Storage",
00165 ":Looping",
00166 ":Audio",
00167 ":Video",
00168 ":RTGraphics",
00169 ":ComponentTag",
00170 ":OrigVolume",
00171 ":Termination",
00172 ":EngineResp",
00173 ":Orientation",
00174 ":MaxValue",
00175 ":MinValue",
00176 ":InitialValue",
00177 ":InitialPortion",
00178 ":StepSize",
00179 ":SliderStyle",
00180 ":InputType",
00181 ":CharList",
00182 ":ObscuredInput",
00183 ":MaxLength",
00184 ":OrigLabel",
00185 ":ButtonStyle",
00186 ":Activate",
00187 ":Add",
00188 ":AddItem",
00189 ":Append",
00190 ":BringToFront",
00191 ":Call",
00192 ":CallActionSlot",
00193 ":Clear",
00194 ":Clone",
00195 ":CloseConnection",
00196 ":Deactivate",
00197 ":DelItem",
00198 ":Deselect",
00199 ":DeselectItem",
00200 ":Divide",
00201 ":DrawArc",
00202 ":DrawLine",
00203 ":DrawOval",
00204 ":DrawPolygon",
00205 ":DrawPolyline",
00206 ":DrawRectangle",
00207 ":DrawSector",
00208 ":Fork",
00209 ":GetAvailabilityStatus",
00210 ":GetBoxSize",
00211 ":GetCellItem",
00212 ":GetCursorPosition",
00213 ":GetEngineSupport",
00214 ":GetEntryPoint",
00215 ":GetFillColour",
00216 ":GetFirstItem",
00217 ":GetHighlightStatus",
00218 ":GetInteractionStatus",
00219 ":GetItemStatus",
00220 ":GetLabel",
00221 ":GetLastAnchorFired",
00222 ":GetLineColour",
00223 ":GetLineStyle",
00224 ":GetLineWidth",
00225 ":GetListItem",
00226 ":GetListSize",
00227 ":GetOverwriteMode",
00228 ":GetPortion",
00229 ":GetPosition",
00230 ":GetRunningStatus",
00231 ":GetSelectionStatus",
00232 ":GetSliderValue",
00233 ":GetTextContent",
00234 ":GetTextData",
00235 ":GetTokenPosition",
00236 ":GetVolume",
00237 ":Launch",
00238 ":LockScreen",
00239 ":Modulo",
00240 ":Move",
00241 ":MoveTo",
00242 ":Multiply",
00243 ":OpenConnection",
00244 ":Preload",
00245 ":PutBefore",
00246 ":PutBehind",
00247 ":Quit",
00248 ":ReadPersistent",
00249 ":Run",
00250 ":ScaleBitmap",
00251 ":ScaleVideo",
00252 ":ScrollItems",
00253 ":Select",
00254 ":SelectItem",
00255 ":SendEvent",
00256 ":SendToBack",
00257 ":SetBoxSize",
00258 ":SetCachePriority",
00259 ":SetCounterEndPosition",
00260 ":SetCounterPosition",
00261 ":SetCounterTrigger",
00262 ":SetCursorPosition",
00263 ":SetCursorShape",
00264 ":SetData",
00265 ":SetEntryPoint",
00266 ":SetFillColour",
00267 ":SetFirstItem",
00268 ":SetFontRef",
00269 ":SetHighlightStatus",
00270 ":SetInteractionStatus",
00271 ":SetLabel",
00272 ":SetLineColour",
00273 ":SetLineStyle",
00274 ":SetLineWidth",
00275 ":SetOverwriteMode",
00276 ":SetPaletteRef",
00277 ":SetPortion",
00278 ":SetPosition",
00279 ":SetSliderValue",
00280 ":SetSpeed",
00281 ":SetTimer",
00282 ":SetTransparency",
00283 ":SetVariable",
00284 ":SetVolume",
00285 ":Spawn",
00286 ":Step",
00287 ":Stop",
00288 ":StorePersistent",
00289 ":Subtract",
00290 ":TestVariable",
00291 ":Toggle",
00292 ":ToggleItem",
00293 ":TransitionTo",
00294 ":Unload",
00295 ":UnlockScreen",
00296 ":GBoolean",
00297 ":GInteger",
00298 ":GOctetString",
00299 ":GObjectRef",
00300 ":GContentRef",
00301 ":NewColourIndex",
00302 ":NewAbsoluteColour",
00303 ":NewFontName",
00304 ":NewFontRef",
00305 ":NewContentSize",
00306 ":NewCCPriority",
00307 ":IndirectRef",
00308
00309 ":SetBackgroundColour",
00310 ":SetCellPosition",
00311 ":SetInputRegister",
00312 ":SetTextColour",
00313 ":SetFontAttributes",
00314 ":SetVideoDecodeOffset",
00315 ":GetVideoDecodeOffset",
00316 ":GetFocusPosition",
00317 ":SetFocusPosition",
00318 ":SetBitmapDecodeOffset",
00319 ":GetBitmapDecodeOffset",
00320 ":SetSliderParameters",
00321
00322 ":EventSource",
00323 ":EventType",
00324 ":EventData",
00325 ":ActionSlots"
00326 };
00327
00328
00329 static struct { const char *name; unsigned char r, g, b, t; } colourTable[] =
00330 {
00331 { "black", 0, 0, 0, 0 },
00332 { "transparent", 0, 0, 0, 255 },
00333 { "gray", 128,128,128,0 },
00334 { "darkgray",192,192,192,0 },
00335 { "red", 255,0, 0, 0 },
00336 { "darkred", 128,0, 0, 0 },
00337 { "blue", 0, 0, 255,0 },
00338 { "darkblue", 0, 0, 128,0 },
00339 { "green", 0, 255,0, 0 },
00340 { "darkgreen", 0, 128,0, 0 },
00341 { "yellow", 255,255,0, 0 },
00342 { "cyan", 0, 255,255,0 },
00343 { "magenta", 255,0, 255,0 }
00344 };
00345
00346
00347
00348 int FindTag(const char *p)
00349 {
00350 for (int i = 0; i < (int)(sizeof(rchTagNames)/sizeof(rchTagNames[0])); i++) {
00351 if (stricmp(p, rchTagNames[i]) == 0) return i;
00352 }
00353 return -1;
00354 }
00355
00356
00357
00358 #define MAX_ENUM 30
00359
00360 void MHParseText::Error(const char *str)
00361 {
00362 MHERROR(QString("%1- at line %2\n").arg(str).arg(m_lineCount));
00363 }
00364
00365
00366 void MHParseText::NextSym()
00367 {
00368 while (1) {
00369
00370 switch (m_ch) {
00371 case '\n': m_lineCount++;
00372 case ' ': case '\r': case '\t': case '\f':
00373
00374 GetNextChar();
00375 continue;
00376
00377 case '/':
00378 {
00379 GetNextChar();
00380 if (m_ch != '/') Error("Malformed comment");
00381 do { GetNextChar(); } while (m_ch != '\n' && m_ch != '\f' && m_ch != '\r');
00382 continue;
00383 }
00384
00385 case ':':
00386 {
00387 m_nType = PTTag;
00388 char buff[MAX_TAG_LENGTH+1];
00389 char *p = buff;
00390 do {
00391 *p++ = m_ch;
00392 GetNextChar();
00393 if (p == buff + MAX_TAG_LENGTH) break;
00394 } while ((m_ch >= 'a' && m_ch <= 'z') || (m_ch >= 'A' && m_ch <= 'Z'));
00395 *p = 0;
00396
00397
00398 m_nTag = FindTag(buff);
00399 if (m_nTag >= 0) return;
00400
00401 Error("Unrecognised tag");
00402 }
00403
00404 case '"':
00405 {
00406 m_nType = PTString;
00407
00408
00409 m_nStringLength = 0;
00410 while (1) {
00411 GetNextChar();
00412 if (m_ch == '"') break;
00413 if (m_ch == '\\') GetNextChar();
00414 if (m_ch == '\n' || m_ch == '\r') Error("Unterminated string");
00415
00416 unsigned char *str = (unsigned char*)realloc(m_String, m_nStringLength+2);
00417 if (str == NULL) Error("Insufficient memory");
00418 m_String = str;
00419 m_String[m_nStringLength++] = m_ch;
00420 }
00421 GetNextChar();
00422 m_String[m_nStringLength] = 0;
00423 return;
00424 }
00425
00426 case '\'':
00427 {
00428 m_nType = PTString;
00429 m_nStringLength = 0;
00430
00431
00432
00433 while (1) {
00434 GetNextChar();
00435 if (m_ch == '\'') break;
00436 if (m_ch == '\n') Error("Unterminated string");
00437 if (m_ch == '=') {
00438
00439 GetNextChar();
00440 if (m_ch == ' ' || m_ch == '\t' || m_ch == '\r' || m_ch == '\n') {
00441
00442 while (m_ch != '\n') {
00443 if (! (m_ch == ' ' || m_ch == '\t' || m_ch == '\r')) {
00444 Error("Malformed quoted printable string");
00445 }
00446 GetNextChar();
00447 }
00448 continue;
00449 }
00450 else {
00451 int byte = 0;
00452 if (m_ch >= '0' && m_ch <= '9') byte = m_ch - '0';
00453 else if (m_ch >= 'A' && m_ch <= 'F') byte = m_ch - 'A' + 10;
00454 else if (m_ch >= 'a' && m_ch <= 'f') byte = m_ch - 'a' + 10;
00455 else Error("Malformed quoted printable string");
00456 byte *= 16;
00457 GetNextChar();
00458 if (m_ch >= '0' && m_ch <= '9') byte += m_ch - '0';
00459 else if (m_ch >= 'A' && m_ch <= 'F') byte += m_ch - 'A' + 10;
00460 else if (m_ch >= 'a' && m_ch <= 'f') byte += m_ch - 'a' + 10;
00461 else Error("Malformed quoted printable string");
00462 m_ch = byte;
00463 }
00464 }
00465
00466 unsigned char *str = (unsigned char*)realloc(m_String, m_nStringLength+2);
00467 if (str == NULL) Error("Insufficient memory");
00468 m_String = str;
00469 m_String[m_nStringLength++] = m_ch;
00470 }
00471 GetNextChar();
00472 m_String[m_nStringLength] = 0;
00473 return;
00474 }
00475
00476 case '`':
00477
00478 MHERROR("Base 64 string is not implemented");
00479 break;
00480
00481 case '#':
00482 MHERROR("3-byte hex constant is not implemented");
00483 break;
00484
00485 case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
00486 {
00487 m_nType = PTInt;
00488 bool negative = m_ch == '-';
00489 if (negative) {
00490 GetNextChar();
00491 if (m_ch < '0' || m_ch > '9') Error("Expected digit after '-'");
00492 }
00493
00494
00495 m_nInt = m_ch - '0';
00496 GetNextChar();
00497 if (m_nInt == 0 && (m_ch == 'x' || m_ch == 'X')) {
00498 MHERROR("Hex constant is not implemented");
00499 }
00500 while (m_ch >= '0' && m_ch <= '9') {
00501 m_nInt = m_nInt * 10 + m_ch - '0';
00502
00503 GetNextChar();
00504 }
00505 if (negative) m_nInt = -m_nInt;
00506 return;
00507 }
00508
00509 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j':
00510 case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't':
00511 case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
00512 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J':
00513 case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T':
00514 case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
00515 {
00516 m_nType = PTEnum;
00517 char buff[MAX_ENUM+1];
00518 char *p = buff;
00519 do {
00520 *p++ = m_ch;
00521 GetNextChar();
00522 if (p == buff+MAX_ENUM) break;
00523 }
00524 while ((m_ch >= 'a' && m_ch <= 'z') || (m_ch >= 'A' && m_ch <= 'Z') || m_ch == '-');
00525 *p = '\0';
00526 if (stricmp(buff, "NULL") == 0) { m_nType = PTNull; return; }
00527 if (stricmp(buff, "true") == 0) { m_nType = PTBool; m_fBool = true; return; }
00528 if (stricmp(buff, "false") == 0) { m_nType = PTBool; m_fBool = false; return; }
00529
00530
00531 m_nInt = MHLink::GetEventType(buff);
00532 if (m_nInt > 0) return;
00533 m_nInt = MHText::GetJustification(buff);
00534 if (m_nInt > 0) return;
00535 m_nInt = MHText::GetLineOrientation(buff);
00536 if (m_nInt > 0) return;
00537 m_nInt = MHText::GetStartCorner(buff);
00538 if (m_nInt > 0) return;
00539 m_nInt = MHSlider::GetOrientation(buff);
00540 if (m_nInt > 0) return;
00541 m_nInt = MHSlider::GetStyle(buff);
00542 if (m_nInt > 0) return;
00543
00544
00545 for (int i = 0; i < (int)(sizeof(colourTable)/sizeof(colourTable[0])); i++) {
00546 if (stricmp(buff, colourTable[i].name) == 0) {
00547 m_nType = PTString;
00548 unsigned char *str = (unsigned char*)realloc(m_String, 4+1);
00549 if (str == NULL) Error("Insufficient memory");
00550 m_String[0] = colourTable[i].r;
00551 m_String[1] = colourTable[i].g;
00552 m_String[2] = colourTable[i].b;
00553 m_String[3] = colourTable[i].t;
00554 m_String = str;
00555 m_nStringLength = 4;
00556 return;
00557 }
00558 }
00559
00560 Error("Unrecognised enumeration");
00561 break;
00562 }
00563
00564 case '{':
00565
00566
00567 m_nType = PTStartSection;
00568 GetNextChar();
00569 return;
00570
00571 case '}':
00572 m_nType = PTEndSection;
00573 GetNextChar();
00574 return;
00575
00576 case '(':
00577 m_nType = PTStartSeq;
00578 GetNextChar();
00579 return;
00580
00581 case ')':
00582 m_nType = PTEndSeq;
00583 GetNextChar();
00584 return;
00585
00586 case EOF:
00587 m_nType = PTEOF;
00588 return;
00589
00590 default:
00591 Error("Unknown character");
00592 GetNextChar();
00593 }
00594 }
00595 }
00596
00597 MHParseNode *MHParseText::DoParse()
00598 {
00599 MHParseNode *pRes = NULL;
00600 try {
00601 switch (m_nType) {
00602 case PTStartSection:
00603 {
00604 NextSym();
00605
00606 if (m_nType != PTTag) Error("Expected ':' after '{'");
00607 MHPTagged *pTag = new MHPTagged(m_nTag);
00608 pRes = pTag;
00609 NextSym();
00610 while (m_nType != PTEndSection) {
00611 pTag->AddArg(DoParse());
00612 }
00613 NextSym();
00614 break;
00615 }
00616
00617 case PTTag:
00618 {
00619 int nTag = m_nTag;
00620 MHPTagged *pTag = new MHPTagged(nTag);
00621 pRes = pTag;
00622 NextSym();
00623 switch (nTag) {
00624 case C_ITEMS:
00625 case C_LINK_EFFECT:
00626 case C_ACTIVATE:
00627 case C_ADD:
00628 case C_ADD_ITEM:
00629 case C_APPEND:
00630 case C_BRING_TO_FRONT:
00631 case C_CALL:
00632 case C_CALL_ACTION_SLOT:
00633 case C_CLEAR:
00634 case C_CLONE:
00635 case C_CLOSE_CONNECTION:
00636 case C_DEACTIVATE:
00637 case C_DEL_ITEM:
00638 case C_DESELECT:
00639 case C_DESELECT_ITEM:
00640 case C_DIVIDE:
00641 case C_DRAW_ARC:
00642 case C_DRAW_LINE:
00643 case C_DRAW_OVAL:
00644 case C_DRAW_POLYGON:
00645 case C_DRAW_POLYLINE:
00646 case C_DRAW_RECTANGLE:
00647 case C_DRAW_SECTOR:
00648 case C_FORK:
00649 case C_GET_AVAILABILITY_STATUS:
00650 case C_GET_BOX_SIZE:
00651 case C_GET_CELL_ITEM:
00652 case C_GET_CURSOR_POSITION:
00653 case C_GET_ENGINE_SUPPORT:
00654 case C_GET_ENTRY_POINT:
00655 case C_GET_FILL_COLOUR:
00656 case C_GET_FIRST_ITEM:
00657 case C_GET_HIGHLIGHT_STATUS:
00658 case C_GET_INTERACTION_STATUS:
00659 case C_GET_ITEM_STATUS:
00660 case C_GET_LABEL:
00661 case C_GET_LAST_ANCHOR_FIRED:
00662 case C_GET_LINE_COLOUR:
00663 case C_GET_LINE_STYLE:
00664 case C_GET_LINE_WIDTH:
00665 case C_GET_LIST_ITEM:
00666 case C_GET_LIST_SIZE:
00667 case C_GET_OVERWRITE_MODE:
00668 case C_GET_PORTION:
00669 case C_GET_POSITION:
00670 case C_GET_RUNNING_STATUS:
00671 case C_GET_SELECTION_STATUS:
00672 case C_GET_SLIDER_VALUE:
00673 case C_GET_TEXT_CONTENT:
00674 case C_GET_TEXT_DATA:
00675 case C_GET_TOKEN_POSITION:
00676 case C_GET_VOLUME:
00677 case C_LAUNCH:
00678 case C_LOCK_SCREEN:
00679 case C_MODULO:
00680 case C_MOVE:
00681 case C_MOVE_TO:
00682 case C_MULTIPLY:
00683 case C_OPEN_CONNECTION:
00684 case C_PRELOAD:
00685 case C_PUT_BEFORE:
00686 case C_PUT_BEHIND:
00687 case C_QUIT:
00688 case C_READ_PERSISTENT:
00689 case C_RUN:
00690 case C_SCALE_BITMAP:
00691 case C_SCALE_VIDEO:
00692 case C_SCROLL_ITEMS:
00693 case C_SELECT:
00694 case C_SELECT_ITEM:
00695 case C_SEND_EVENT:
00696 case C_SEND_TO_BACK:
00697 case C_SET_BOX_SIZE:
00698 case C_SET_CACHE_PRIORITY:
00699 case C_SET_COUNTER_END_POSITION:
00700 case C_SET_COUNTER_POSITION:
00701 case C_SET_COUNTER_TRIGGER:
00702 case C_SET_CURSOR_POSITION:
00703 case C_SET_CURSOR_SHAPE:
00704 case C_SET_DATA:
00705 case C_SET_ENTRY_POINT:
00706 case C_SET_FILL_COLOUR:
00707 case C_SET_FIRST_ITEM:
00708 case C_SET_FONT_REF:
00709 case C_SET_HIGHLIGHT_STATUS:
00710 case C_SET_INTERACTION_STATUS:
00711 case C_SET_LABEL:
00712 case C_SET_LINE_COLOUR:
00713 case C_SET_LINE_STYLE:
00714 case C_SET_LINE_WIDTH:
00715 case C_SET_OVERWRITE_MODE:
00716 case C_SET_PALETTE_REF:
00717 case C_SET_PORTION:
00718 case C_SET_POSITION:
00719 case C_SET_SLIDER_VALUE:
00720 case C_SET_SPEED:
00721 case C_SET_TIMER:
00722 case C_SET_TRANSPARENCY:
00723 case C_SET_VARIABLE:
00724 case C_SET_VOLUME:
00725 case C_SPAWN:
00726 case C_STEP:
00727 case C_STOP:
00728 case C_STORE_PERSISTENT:
00729 case C_SUBTRACT:
00730 case C_TEST_VARIABLE:
00731 case C_TOGGLE:
00732 case C_TOGGLE_ITEM:
00733 case C_TRANSITION_TO:
00734 case C_UNLOAD:
00735 case C_UNLOCK_SCREEN:
00736 case C_CONTENT_REFERENCE:
00737 case C_TOKEN_GROUP_ITEMS:
00738 case C_POSITIONS:
00739 case C_MULTIPLEX:
00740 {
00741
00742
00743 if (m_nType != PTStartSeq) Error("Expected '('");
00744 NextSym();
00745 while (m_nType != PTEndSeq) pTag->AddArg(DoParse());
00746 NextSym();
00747 break;
00748 }
00749 case C_ORIGINAL_CONTENT:
00750 case C_NEW_GENERIC_BOOLEAN:
00751 case C_NEW_GENERIC_INTEGER:
00752 case C_NEW_GENERIC_OCTETSTRING:
00753 case C_NEW_GENERIC_OBJECT_REF:
00754 case C_NEW_GENERIC_CONTENT_REF:
00755 case C_ORIGINAL_VALUE:
00756
00757 {
00758
00759
00760 pTag->AddArg(DoParse());
00761 break;
00762 }
00763 default:
00764
00765 while (m_nType == PTBool ||m_nType == PTInt || m_nType == PTString || m_nType == PTEnum || m_nType == PTStartSeq) {
00766 pTag->AddArg(DoParse());
00767 }
00768
00769 }
00770 break;
00771 }
00772
00773 case PTInt:
00774 {
00775 pRes = new MHPInt(m_nInt);
00776 NextSym();
00777 break;
00778 }
00779
00780 case PTBool:
00781 {
00782 pRes = new MHPBool(m_fBool);
00783 NextSym();
00784 break;
00785 }
00786
00787 case PTString:
00788 {
00789 MHOctetString str;
00790 str.Copy(MHOctetString((const char *)m_String, m_nStringLength));
00791 pRes = new MHPString(str);
00792 NextSym();
00793 break;
00794 }
00795
00796 case PTEnum:
00797 {
00798 pRes = new MHPEnum(m_nInt);
00799 NextSym();
00800 break;
00801 }
00802
00803 case PTNull:
00804 {
00805 pRes = new MHPNull;
00806 NextSym();
00807 break;
00808 }
00809
00810 case PTStartSeq:
00811 {
00812 MHParseSequence *pSeq = new MHParseSequence;
00813 pRes = pSeq;
00814 NextSym();
00815 while (m_nType != PTEndSeq) pSeq->Append(DoParse());
00816 NextSym();
00817 break;
00818 }
00819
00820 default:
00821 Error("Unexpected symbol");
00822 }
00823 return pRes;
00824 }
00825 catch (...) {
00826 delete(pRes);
00827 throw;
00828 }
00829 }
00830
00831
00832
00833 MHParseNode *MHParseText::Parse()
00834 {
00835 GetNextChar();
00836 NextSym();
00837 return DoParse();
00838 }
00839