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 : m_lineCount(1), m_nType(PTNull),
00047 m_ch(0), m_nTag(0),
00048 m_nInt(0), m_fBool(false),
00049 m_String((unsigned char *)malloc(100)),
00050 m_nStringLength(0), m_p(0)
00051
00052 {
00053 }
00054
00055 MHParseText::~MHParseText()
00056 {
00057 free(m_String);
00058 }
00059
00060
00061 void MHParseText::GetNextChar()
00062 {
00063 if ((int)m_p >= m_data.size())
00064 {
00065 m_ch = EOF;
00066 }
00067 else
00068 {
00069 m_ch = m_data[m_p++];
00070 }
00071 }
00072
00073
00074 #define MAX_TAG_LENGTH 30
00075
00076 const char *rchTagNames[] =
00077 {
00078 ":Application",
00079 ":Scene",
00080 ":StdID",
00081 ":StdVersion",
00082 ":ObjectInfo",
00083 ":OnStartUp",
00084 ":OnCloseDown",
00085 ":OrigGCPriority",
00086 ":Items",
00087 ":ResidentPrg",
00088 ":RemotePrg",
00089 ":InterchgPrg",
00090 ":Palette",
00091 ":Font",
00092 ":CursorShape",
00093 ":BooleanVar",
00094 ":IntegerVar",
00095 ":OStringVar",
00096 ":ObjectRefVar",
00097 ":ContentRefVar",
00098 ":Link",
00099 ":Stream",
00100 ":Bitmap",
00101 ":LineArt",
00102 ":DynamicLineArt",
00103 ":Rectangle",
00104 ":Hotspot",
00105 ":SwitchButton",
00106 ":PushButton",
00107 ":Text",
00108 ":EntryField",
00109 ":HyperText",
00110 ":Slider",
00111 ":TokenGroup",
00112 ":ListGroup",
00113 ":OnSpawnCloseDown",
00114 ":OnRestart",
00115 "",
00116 ":CharacterSet",
00117 ":BackgroundColour",
00118 ":TextCHook",
00119 ":TextColour",
00120 ":Font",
00121 ":FontAttributes",
00122 ":InterchgPrgCHook",
00123 ":StreamCHook",
00124 ":BitmapCHook",
00125 ":LineArtCHook",
00126 ":ButtonRefColour",
00127 ":HighlightRefColour",
00128 ":SliderRefColour",
00129 ":InputEventReg",
00130 ":SceneCS",
00131 ":AspectRatio",
00132 ":MovingCursor",
00133 ":NextScenes",
00134 ":InitiallyActive",
00135 ":CHook",
00136 ":OrigContent",
00137 ":Shared",
00138 ":ContentSize",
00139 ":CCPriority",
00140 "" ,
00141 ":LinkEffect",
00142 ":Name",
00143 ":InitiallyAvailable",
00144 ":ProgramConnectionTag",
00145 ":OrigValue",
00146 ":ObjectRef",
00147 ":ContentRef",
00148 ":MovementTable",
00149 ":TokenGroupItems",
00150 ":NoTokenActionSlots",
00151 ":Positions",
00152 ":WrapAround",
00153 ":MultipleSelection",
00154 ":OrigBoxSize",
00155 ":OrigPosition",
00156 ":OrigPaletteRef",
00157 ":Tiling",
00158 ":OrigTransparency",
00159 ":BBBox",
00160 ":OrigLineWidth",
00161 ":OrigLineStyle",
00162 ":OrigRefLineColour",
00163 ":OrigRefFillColour",
00164 ":OrigFont",
00165 ":HJustification",
00166 ":VJustification",
00167 ":LineOrientation",
00168 ":StartCorner",
00169 ":TextWrapping",
00170 ":Multiplex",
00171 ":Storage",
00172 ":Looping",
00173 ":Audio",
00174 ":Video",
00175 ":RTGraphics",
00176 ":ComponentTag",
00177 ":OrigVolume",
00178 ":Termination",
00179 ":EngineResp",
00180 ":Orientation",
00181 ":MaxValue",
00182 ":MinValue",
00183 ":InitialValue",
00184 ":InitialPortion",
00185 ":StepSize",
00186 ":SliderStyle",
00187 ":InputType",
00188 ":CharList",
00189 ":ObscuredInput",
00190 ":MaxLength",
00191 ":OrigLabel",
00192 ":ButtonStyle",
00193 ":Activate",
00194 ":Add",
00195 ":AddItem",
00196 ":Append",
00197 ":BringToFront",
00198 ":Call",
00199 ":CallActionSlot",
00200 ":Clear",
00201 ":Clone",
00202 ":CloseConnection",
00203 ":Deactivate",
00204 ":DelItem",
00205 ":Deselect",
00206 ":DeselectItem",
00207 ":Divide",
00208 ":DrawArc",
00209 ":DrawLine",
00210 ":DrawOval",
00211 ":DrawPolygon",
00212 ":DrawPolyline",
00213 ":DrawRectangle",
00214 ":DrawSector",
00215 ":Fork",
00216 ":GetAvailabilityStatus",
00217 ":GetBoxSize",
00218 ":GetCellItem",
00219 ":GetCursorPosition",
00220 ":GetEngineSupport",
00221 ":GetEntryPoint",
00222 ":GetFillColour",
00223 ":GetFirstItem",
00224 ":GetHighlightStatus",
00225 ":GetInteractionStatus",
00226 ":GetItemStatus",
00227 ":GetLabel",
00228 ":GetLastAnchorFired",
00229 ":GetLineColour",
00230 ":GetLineStyle",
00231 ":GetLineWidth",
00232 ":GetListItem",
00233 ":GetListSize",
00234 ":GetOverwriteMode",
00235 ":GetPortion",
00236 ":GetPosition",
00237 ":GetRunningStatus",
00238 ":GetSelectionStatus",
00239 ":GetSliderValue",
00240 ":GetTextContent",
00241 ":GetTextData",
00242 ":GetTokenPosition",
00243 ":GetVolume",
00244 ":Launch",
00245 ":LockScreen",
00246 ":Modulo",
00247 ":Move",
00248 ":MoveTo",
00249 ":Multiply",
00250 ":OpenConnection",
00251 ":Preload",
00252 ":PutBefore",
00253 ":PutBehind",
00254 ":Quit",
00255 ":ReadPersistent",
00256 ":Run",
00257 ":ScaleBitmap",
00258 ":ScaleVideo",
00259 ":ScrollItems",
00260 ":Select",
00261 ":SelectItem",
00262 ":SendEvent",
00263 ":SendToBack",
00264 ":SetBoxSize",
00265 ":SetCachePriority",
00266 ":SetCounterEndPosition",
00267 ":SetCounterPosition",
00268 ":SetCounterTrigger",
00269 ":SetCursorPosition",
00270 ":SetCursorShape",
00271 ":SetData",
00272 ":SetEntryPoint",
00273 ":SetFillColour",
00274 ":SetFirstItem",
00275 ":SetFontRef",
00276 ":SetHighlightStatus",
00277 ":SetInteractionStatus",
00278 ":SetLabel",
00279 ":SetLineColour",
00280 ":SetLineStyle",
00281 ":SetLineWidth",
00282 ":SetOverwriteMode",
00283 ":SetPaletteRef",
00284 ":SetPortion",
00285 ":SetPosition",
00286 ":SetSliderValue",
00287 ":SetSpeed",
00288 ":SetTimer",
00289 ":SetTransparency",
00290 ":SetVariable",
00291 ":SetVolume",
00292 ":Spawn",
00293 ":Step",
00294 ":Stop",
00295 ":StorePersistent",
00296 ":Subtract",
00297 ":TestVariable",
00298 ":Toggle",
00299 ":ToggleItem",
00300 ":TransitionTo",
00301 ":Unload",
00302 ":UnlockScreen",
00303 ":GBoolean",
00304 ":GInteger",
00305 ":GOctetString",
00306 ":GObjectRef",
00307 ":GContentRef",
00308 ":NewColourIndex",
00309 ":NewAbsoluteColour",
00310 ":NewFontName",
00311 ":NewFontRef",
00312 ":NewContentSize",
00313 ":NewCCPriority",
00314 ":IndirectRef",
00315
00316 ":SetBackgroundColour",
00317 ":SetCellPosition",
00318 ":SetInputRegister",
00319 ":SetTextColour",
00320 ":SetFontAttributes",
00321 ":SetVideoDecodeOffset",
00322 ":GetVideoDecodeOffset",
00323 ":GetFocusPosition",
00324 ":SetFocusPosition",
00325 ":SetBitmapDecodeOffset",
00326 ":GetBitmapDecodeOffset",
00327 ":SetSliderParameters",
00328
00329 ":EventSource",
00330 ":EventType",
00331 ":EventData",
00332 ":ActionSlots"
00333 };
00334
00335
00336 static struct
00337 {
00338 const char *name;
00339 unsigned char r, g, b, t;
00340 } colourTable[] =
00341 {
00342 { "black", 0, 0, 0, 0 },
00343 { "transparent", 0, 0, 0, 255 },
00344 { "gray", 128, 128, 128, 0 },
00345 { "darkgray", 192, 192, 192, 0 },
00346 { "red", 255, 0, 0, 0 },
00347 { "darkred", 128, 0, 0, 0 },
00348 { "blue", 0, 0, 255, 0 },
00349 { "darkblue", 0, 0, 128, 0 },
00350 { "green", 0, 255, 0, 0 },
00351 { "darkgreen", 0, 128, 0, 0 },
00352 { "yellow", 255, 255, 0, 0 },
00353 { "cyan", 0, 255, 255, 0 },
00354 { "magenta", 255, 0, 255, 0 }
00355 };
00356
00357
00358
00359 static int FindTag(const char *p)
00360 {
00361 for (int i = 0; i < (int)(sizeof(rchTagNames) / sizeof(rchTagNames[0])); i++)
00362 {
00363 if (stricmp(p, rchTagNames[i]) == 0)
00364 {
00365 return i;
00366 }
00367 }
00368
00369 return -1;
00370 }
00371
00372
00373
00374 #define MAX_ENUM 30
00375
00376 void MHParseText::Error(const char *str)
00377 {
00378 MHERROR(QString("%1- at line %2\n").arg(str).arg(m_lineCount));
00379 }
00380
00381
00382 void MHParseText::NextSym()
00383 {
00384 while (1)
00385 {
00386
00387 switch (m_ch)
00388 {
00389 case '\n':
00390 m_lineCount++;
00391 case ' ':
00392 case '\r':
00393 case '\t':
00394 case '\f':
00395
00396 GetNextChar();
00397 continue;
00398
00399 case '/':
00400 {
00401
00402 GetNextChar();
00403
00404 if (m_ch != '/')
00405 {
00406 Error("Malformed comment");
00407 }
00408
00409 do
00410 {
00411 GetNextChar();
00412 }
00413 while (m_ch != '\n' && m_ch != '\f' && m_ch != '\r');
00414
00415 continue;
00416 }
00417
00418 case ':':
00419 {
00420 m_nType = PTTag;
00421 char buff[MAX_TAG_LENGTH+1];
00422 char *p = buff;
00423
00424 do
00425 {
00426 *p++ = m_ch;
00427 GetNextChar();
00428
00429 if (p == buff + MAX_TAG_LENGTH)
00430 {
00431 break;
00432 }
00433 }
00434 while ((m_ch >= 'a' && m_ch <= 'z') || (m_ch >= 'A' && m_ch <= 'Z'));
00435
00436 *p = 0;
00437
00438
00439 m_nTag = FindTag(buff);
00440
00441 if (m_nTag >= 0)
00442 {
00443 return;
00444 }
00445
00446
00447 Error("Unrecognised tag");
00448 }
00449
00450 case '"':
00451 {
00452 m_nType = PTString;
00453
00454
00455 m_nStringLength = 0;
00456
00457 while (1)
00458 {
00459 GetNextChar();
00460
00461 if (m_ch == '"')
00462 {
00463 break;
00464 }
00465
00466 if (m_ch == '\\')
00467 {
00468 GetNextChar();
00469 }
00470
00471 if (m_ch == '\n' || m_ch == '\r')
00472 {
00473 Error("Unterminated string");
00474 }
00475
00476
00477 unsigned char *str = (unsigned char *)realloc(m_String, m_nStringLength + 2);
00478
00479 if (str == NULL)
00480 {
00481 Error("Insufficient memory");
00482 }
00483
00484 m_String = str;
00485 m_String[m_nStringLength++] = m_ch;
00486 }
00487
00488 GetNextChar();
00489 m_String[m_nStringLength] = 0;
00490 return;
00491 }
00492
00493 case '\'':
00494 {
00495 m_nType = PTString;
00496 m_nStringLength = 0;
00497
00498
00499
00500
00501 while (1)
00502 {
00503 GetNextChar();
00504
00505 if (m_ch == '\'')
00506 {
00507 break;
00508 }
00509
00510 if (m_ch == '\n')
00511 {
00512 Error("Unterminated string");
00513 }
00514
00515 if (m_ch == '=')
00516 {
00517
00518 GetNextChar();
00519
00520 if (m_ch == ' ' || m_ch == '\t' || m_ch == '\r' || m_ch == '\n')
00521 {
00522
00523 while (m_ch != '\n')
00524 {
00525 if (!(m_ch == ' ' || m_ch == '\t' || m_ch == '\r'))
00526 {
00527 Error("Malformed quoted printable string");
00528 }
00529
00530 GetNextChar();
00531 }
00532
00533 continue;
00534 }
00535 else
00536 {
00537 int byte = 0;
00538
00539 if (m_ch >= '0' && m_ch <= '9')
00540 {
00541 byte = m_ch - '0';
00542 }
00543 else if (m_ch >= 'A' && m_ch <= 'F')
00544 {
00545 byte = m_ch - 'A' + 10;
00546 }
00547 else if (m_ch >= 'a' && m_ch <= 'f')
00548 {
00549 byte = m_ch - 'a' + 10;
00550 }
00551 else
00552 {
00553 Error("Malformed quoted printable string");
00554 }
00555
00556 byte *= 16;
00557 GetNextChar();
00558
00559 if (m_ch >= '0' && m_ch <= '9')
00560 {
00561 byte += m_ch - '0';
00562 }
00563 else if (m_ch >= 'A' && m_ch <= 'F')
00564 {
00565 byte += m_ch - 'A' + 10;
00566 }
00567 else if (m_ch >= 'a' && m_ch <= 'f')
00568 {
00569 byte += m_ch - 'a' + 10;
00570 }
00571 else
00572 {
00573 Error("Malformed quoted printable string");
00574 }
00575
00576 m_ch = byte;
00577 }
00578 }
00579
00580
00581 unsigned char *str = (unsigned char *)realloc(m_String, m_nStringLength + 2);
00582
00583 if (str == NULL)
00584 {
00585 Error("Insufficient memory");
00586 }
00587
00588 m_String = str;
00589 m_String[m_nStringLength++] = m_ch;
00590 }
00591
00592 GetNextChar();
00593 m_String[m_nStringLength] = 0;
00594 return;
00595 }
00596
00597 case '`':
00598
00599 MHERROR("Base 64 string is not implemented");
00600 break;
00601
00602 case '#':
00603 MHERROR("3-byte hex constant is not implemented");
00604 break;
00605
00606 case '-':
00607 case '0':
00608 case '1':
00609 case '2':
00610 case '3':
00611 case '4':
00612 case '5':
00613 case '6':
00614 case '7':
00615 case '8':
00616 case '9':
00617 {
00618 m_nType = PTInt;
00619 bool negative = m_ch == '-';
00620
00621 if (negative)
00622 {
00623 GetNextChar();
00624
00625 if (m_ch < '0' || m_ch > '9')
00626 {
00627 Error("Expected digit after '-'");
00628 }
00629 }
00630
00631
00632
00633 m_nInt = m_ch - '0';
00634 GetNextChar();
00635
00636 if (m_nInt == 0 && (m_ch == 'x' || m_ch == 'X'))
00637 {
00638 MHERROR("Hex constant is not implemented");
00639 }
00640
00641 while (m_ch >= '0' && m_ch <= '9')
00642 {
00643 m_nInt = m_nInt * 10 + m_ch - '0';
00644
00645 GetNextChar();
00646 }
00647
00648 if (negative)
00649 {
00650 m_nInt = -m_nInt;
00651 }
00652
00653 return;
00654 }
00655
00656 case 'a':
00657 case 'b':
00658 case 'c':
00659 case 'd':
00660 case 'e':
00661 case 'f':
00662 case 'g':
00663 case 'h':
00664 case 'i':
00665 case 'j':
00666 case 'k':
00667 case 'l':
00668 case 'm':
00669 case 'n':
00670 case 'o':
00671 case 'p':
00672 case 'q':
00673 case 'r':
00674 case 's':
00675 case 't':
00676 case 'u':
00677 case 'v':
00678 case 'w':
00679 case 'x':
00680 case 'y':
00681 case 'z':
00682 case 'A':
00683 case 'B':
00684 case 'C':
00685 case 'D':
00686 case 'E':
00687 case 'F':
00688 case 'G':
00689 case 'H':
00690 case 'I':
00691 case 'J':
00692 case 'K':
00693 case 'L':
00694 case 'M':
00695 case 'N':
00696 case 'O':
00697 case 'P':
00698 case 'Q':
00699 case 'R':
00700 case 'S':
00701 case 'T':
00702 case 'U':
00703 case 'V':
00704 case 'W':
00705 case 'X':
00706 case 'Y':
00707 case 'Z':
00708 {
00709
00710 m_nType = PTEnum;
00711 char buff[MAX_ENUM+1];
00712 char *p = buff;
00713
00714 do
00715 {
00716 *p++ = m_ch;
00717 GetNextChar();
00718
00719 if (p == buff + MAX_ENUM)
00720 {
00721 break;
00722 }
00723 }
00724 while ((m_ch >= 'a' && m_ch <= 'z') || (m_ch >= 'A' && m_ch <= 'Z') || m_ch == '-');
00725
00726 *p = '\0';
00727
00728 if (stricmp(buff, "NULL") == 0)
00729 {
00730 m_nType = PTNull;
00731 return;
00732 }
00733
00734 if (stricmp(buff, "true") == 0)
00735 {
00736 m_nType = PTBool;
00737 m_fBool = true;
00738 return;
00739 }
00740
00741 if (stricmp(buff, "false") == 0)
00742 {
00743 m_nType = PTBool;
00744 m_fBool = false;
00745 return;
00746 }
00747
00748
00749
00750 m_nInt = MHLink::GetEventType(buff);
00751
00752 if (m_nInt > 0)
00753 {
00754 return;
00755 }
00756
00757 m_nInt = MHText::GetJustification(buff);
00758
00759 if (m_nInt > 0)
00760 {
00761 return;
00762 }
00763
00764 m_nInt = MHText::GetLineOrientation(buff);
00765
00766 if (m_nInt > 0)
00767 {
00768 return;
00769 }
00770
00771 m_nInt = MHText::GetStartCorner(buff);
00772
00773 if (m_nInt > 0)
00774 {
00775 return;
00776 }
00777
00778 m_nInt = MHSlider::GetOrientation(buff);
00779
00780 if (m_nInt > 0)
00781 {
00782 return;
00783 }
00784
00785 m_nInt = MHSlider::GetStyle(buff);
00786
00787 if (m_nInt > 0)
00788 {
00789 return;
00790 }
00791
00792
00793 for (int i = 0; i < (int)(sizeof(colourTable) / sizeof(colourTable[0])); i++)
00794 {
00795 if (stricmp(buff, colourTable[i].name) == 0)
00796 {
00797 m_nType = PTString;
00798 unsigned char *str = (unsigned char *)realloc(m_String, 4 + 1);
00799
00800 if (str == NULL)
00801 {
00802 Error("Insufficient memory");
00803 }
00804
00805 m_String = str;
00806 m_String[0] = colourTable[i].r;
00807 m_String[1] = colourTable[i].g;
00808 m_String[2] = colourTable[i].b;
00809 m_String[3] = colourTable[i].t;
00810 m_nStringLength = 4;
00811 m_String[m_nStringLength] = 0;
00812 return;
00813 }
00814 }
00815
00816 Error("Unrecognised enumeration");
00817 break;
00818 }
00819
00820 case '{':
00821
00822
00823 m_nType = PTStartSection;
00824 GetNextChar();
00825 return;
00826
00827 case '}':
00828 m_nType = PTEndSection;
00829 GetNextChar();
00830 return;
00831
00832 case '(':
00833 m_nType = PTStartSeq;
00834 GetNextChar();
00835 return;
00836
00837 case ')':
00838 m_nType = PTEndSeq;
00839 GetNextChar();
00840 return;
00841
00842 case EOF:
00843 m_nType = PTEOF;
00844 return;
00845
00846 default:
00847 Error("Unknown character");
00848 GetNextChar();
00849 }
00850 }
00851 }
00852
00853 MHParseNode *MHParseText::DoParse()
00854 {
00855 MHParseNode *pRes = NULL;
00856
00857 try
00858 {
00859 switch (m_nType)
00860 {
00861 case PTStartSection:
00862 {
00863 NextSym();
00864
00865
00866 if (m_nType != PTTag)
00867 {
00868 Error("Expected ':' after '{'");
00869 }
00870
00871 MHPTagged *pTag = new MHPTagged(m_nTag);
00872 pRes = pTag;
00873 NextSym();
00874
00875 while (m_nType != PTEndSection)
00876 {
00877 pTag->AddArg(DoParse());
00878 }
00879
00880 NextSym();
00881 break;
00882 }
00883
00884 case PTTag:
00885 {
00886 int nTag = m_nTag;
00887 MHPTagged *pTag = new MHPTagged(nTag);
00888 pRes = pTag;
00889 NextSym();
00890
00891 switch (nTag)
00892 {
00893 case C_ITEMS:
00894 case C_LINK_EFFECT:
00895 case C_ACTIVATE:
00896 case C_ADD:
00897 case C_ADD_ITEM:
00898 case C_APPEND:
00899 case C_BRING_TO_FRONT:
00900 case C_CALL:
00901 case C_CALL_ACTION_SLOT:
00902 case C_CLEAR:
00903 case C_CLONE:
00904 case C_CLOSE_CONNECTION:
00905 case C_DEACTIVATE:
00906 case C_DEL_ITEM:
00907 case C_DESELECT:
00908 case C_DESELECT_ITEM:
00909 case C_DIVIDE:
00910 case C_DRAW_ARC:
00911 case C_DRAW_LINE:
00912 case C_DRAW_OVAL:
00913 case C_DRAW_POLYGON:
00914 case C_DRAW_POLYLINE:
00915 case C_DRAW_RECTANGLE:
00916 case C_DRAW_SECTOR:
00917 case C_FORK:
00918 case C_GET_AVAILABILITY_STATUS:
00919 case C_GET_BOX_SIZE:
00920 case C_GET_CELL_ITEM:
00921 case C_GET_CURSOR_POSITION:
00922 case C_GET_ENGINE_SUPPORT:
00923 case C_GET_ENTRY_POINT:
00924 case C_GET_FILL_COLOUR:
00925 case C_GET_FIRST_ITEM:
00926 case C_GET_HIGHLIGHT_STATUS:
00927 case C_GET_INTERACTION_STATUS:
00928 case C_GET_ITEM_STATUS:
00929 case C_GET_LABEL:
00930 case C_GET_LAST_ANCHOR_FIRED:
00931 case C_GET_LINE_COLOUR:
00932 case C_GET_LINE_STYLE:
00933 case C_GET_LINE_WIDTH:
00934 case C_GET_LIST_ITEM:
00935 case C_GET_LIST_SIZE:
00936 case C_GET_OVERWRITE_MODE:
00937 case C_GET_PORTION:
00938 case C_GET_POSITION:
00939 case C_GET_RUNNING_STATUS:
00940 case C_GET_SELECTION_STATUS:
00941 case C_GET_SLIDER_VALUE:
00942 case C_GET_TEXT_CONTENT:
00943 case C_GET_TEXT_DATA:
00944 case C_GET_TOKEN_POSITION:
00945 case C_GET_VOLUME:
00946 case C_LAUNCH:
00947 case C_LOCK_SCREEN:
00948 case C_MODULO:
00949 case C_MOVE:
00950 case C_MOVE_TO:
00951 case C_MULTIPLY:
00952 case C_OPEN_CONNECTION:
00953 case C_PRELOAD:
00954 case C_PUT_BEFORE:
00955 case C_PUT_BEHIND:
00956 case C_QUIT:
00957 case C_READ_PERSISTENT:
00958 case C_RUN:
00959 case C_SCALE_BITMAP:
00960 case C_SCALE_VIDEO:
00961 case C_SCROLL_ITEMS:
00962 case C_SELECT:
00963 case C_SELECT_ITEM:
00964 case C_SEND_EVENT:
00965 case C_SEND_TO_BACK:
00966 case C_SET_BOX_SIZE:
00967 case C_SET_CACHE_PRIORITY:
00968 case C_SET_COUNTER_END_POSITION:
00969 case C_SET_COUNTER_POSITION:
00970 case C_SET_COUNTER_TRIGGER:
00971 case C_SET_CURSOR_POSITION:
00972 case C_SET_CURSOR_SHAPE:
00973 case C_SET_DATA:
00974 case C_SET_ENTRY_POINT:
00975 case C_SET_FILL_COLOUR:
00976 case C_SET_FIRST_ITEM:
00977 case C_SET_FONT_REF:
00978 case C_SET_HIGHLIGHT_STATUS:
00979 case C_SET_INTERACTION_STATUS:
00980 case C_SET_LABEL:
00981 case C_SET_LINE_COLOUR:
00982 case C_SET_LINE_STYLE:
00983 case C_SET_LINE_WIDTH:
00984 case C_SET_OVERWRITE_MODE:
00985 case C_SET_PALETTE_REF:
00986 case C_SET_PORTION:
00987 case C_SET_POSITION:
00988 case C_SET_SLIDER_VALUE:
00989 case C_SET_SPEED:
00990 case C_SET_TIMER:
00991 case C_SET_TRANSPARENCY:
00992 case C_SET_VARIABLE:
00993 case C_SET_VOLUME:
00994 case C_SPAWN:
00995 case C_STEP:
00996 case C_STOP:
00997 case C_STORE_PERSISTENT:
00998 case C_SUBTRACT:
00999 case C_TEST_VARIABLE:
01000 case C_TOGGLE:
01001 case C_TOGGLE_ITEM:
01002 case C_TRANSITION_TO:
01003 case C_UNLOAD:
01004 case C_UNLOCK_SCREEN:
01005 case C_CONTENT_REFERENCE:
01006 case C_TOKEN_GROUP_ITEMS:
01007 case C_POSITIONS:
01008 case C_MULTIPLEX:
01009 {
01010
01011
01012
01013 if (m_nType != PTStartSeq)
01014 {
01015 Error("Expected '('");
01016 }
01017
01018 NextSym();
01019
01020 while (m_nType != PTEndSeq)
01021 {
01022 pTag->AddArg(DoParse());
01023 }
01024
01025 NextSym();
01026 break;
01027 }
01028 case C_ORIGINAL_CONTENT:
01029 case C_NEW_GENERIC_BOOLEAN:
01030 case C_NEW_GENERIC_INTEGER:
01031 case C_NEW_GENERIC_OCTETSTRING:
01032 case C_NEW_GENERIC_OBJECT_REF:
01033 case C_NEW_GENERIC_CONTENT_REF:
01034 case C_ORIGINAL_VALUE:
01035
01036 {
01037
01038
01039 pTag->AddArg(DoParse());
01040 break;
01041 }
01042 default:
01043
01044
01045 while (m_nType == PTBool || m_nType == PTInt || m_nType == PTString || m_nType == PTEnum || m_nType == PTStartSeq)
01046 {
01047 pTag->AddArg(DoParse());
01048 }
01049
01050 }
01051
01052 break;
01053 }
01054
01055 case PTInt:
01056 {
01057 pRes = new MHPInt(m_nInt);
01058 NextSym();
01059 break;
01060 }
01061
01062 case PTBool:
01063 {
01064 pRes = new MHPBool(m_fBool);
01065 NextSym();
01066 break;
01067 }
01068
01069 case PTString:
01070 {
01071 MHOctetString str;
01072 str.Copy(MHOctetString((const char *)m_String, m_nStringLength));
01073 pRes = new MHPString(str);
01074 NextSym();
01075 break;
01076 }
01077
01078 case PTEnum:
01079 {
01080 pRes = new MHPEnum(m_nInt);
01081 NextSym();
01082 break;
01083 }
01084
01085 case PTNull:
01086 {
01087 pRes = new MHPNull;
01088 NextSym();
01089 break;
01090 }
01091
01092 case PTStartSeq:
01093 {
01094 MHParseSequence *pSeq = new MHParseSequence;
01095 pRes = pSeq;
01096 NextSym();
01097
01098 while (m_nType != PTEndSeq)
01099 {
01100 pSeq->Append(DoParse());
01101 }
01102
01103 NextSym();
01104 break;
01105 }
01106
01107 default:
01108 Error("Unexpected symbol");
01109 }
01110
01111 return pRes;
01112 }
01113 catch (...)
01114 {
01115 delete(pRes);
01116 throw;
01117 }
01118 }
01119
01120
01121
01122 MHParseNode *MHParseText::Parse()
01123 {
01124 GetNextChar();
01125 NextSym();
01126 return DoParse();
01127 }
01128