static OBJECT ReadMacro(OBJECT *token, OBJECT curr_encl, OBJECT encl) { OBJECT t, res; /* find macro name and insert into symbol table */ SuppressScope(); Dispose(*token); t = LexGetToken(); if( !is_word(type(t)) ) { Error(5, 24, "%s ignored (name is missing)", WARN, &fpos(t), KW_MACRO); debug1(ANY, D, "offending type is %s", Image(type(t))); UnSuppressScope(); *token = t; return nilobj; } res = InsertSym(string(t), MACRO, &fpos(t), 0, FALSE,TRUE,0,curr_encl,nilobj); if( curr_encl != encl ) visible(res) = TRUE; UnSuppressScope(); /* find alternative names for this symbol */ Dispose(t); t = LexGetToken(); while( is_word(type(t)) ) { InsertAlternativeName(string(t), res, &fpos(t)); Dispose(t); t = LexGetToken(); } /* find opening left brace */ if( type(t) != LBR ) { Error(5, 25, "%s ignored (opening %s is missing)", WARN, &fpos(t), KW_MACRO, KW_LBR); *token = t; return nilobj; } /* read macro body */ ReadTokenList(t, res); Dispose(t); /* clean up (kill final RBR, dispose macro name) and exit */ t = pred(sym_body(res), PARENT); sym_body(res) = Delete(t, PARENT); Dispose(t); recursive(res) = FALSE; *token = nilobj; return res; } /* end ReadMacro */
static void ReadTokenList(OBJECT token, OBJECT res) { OBJECT t, xsym, new_par, imps, link, y; int scope_count, i; NextToken(t, res); for(;;) switch(type(t)) { case WORD: if( string(t)[0] == CH_SYMSTART ) Error(5, 11, "symbol %s unknown or misspelt", WARN, &fpos(t), string(t)); NextToken(t, res); break; case QWORD: NextToken(t, res); break; case VCAT: case HCAT: case ACAT: case CROSS: case FORCE_CROSS: case NULL_CLOS: case PAGE_LABEL: case BEGIN_HEADER: case END_HEADER: case SET_HEADER: case CLEAR_HEADER: case ONE_COL: case ONE_ROW: case WIDE: case HIGH: case HSHIFT: case VSHIFT: case HMIRROR: case VMIRROR: case HSCALE: case VSCALE: case HCOVER: case VCOVER: case SCALE: case KERN_SHRINK: case HCONTRACT: case VCONTRACT: case HLIMITED: case VLIMITED: case HEXPAND: case VEXPAND: case START_HVSPAN: case START_HSPAN: case START_VSPAN: case HSPAN: case VSPAN: case PADJUST: case HADJUST: case VADJUST: case ROTATE: case BACKGROUND: case RAW_VERBATIM: case VERBATIM: case CASE: case YIELD: case BACKEND: case XCHAR: case FONT: case SPACE: case YUNIT: case ZUNIT: case SET_CONTEXT: case GET_CONTEXT: case BREAK: case UNDERLINE: case UNDERLINE_COLOUR: case COLOUR: case TEXTURE: case OUTLINE: case LANGUAGE: case CURR_LANG: case CURR_FAMILY: case CURR_FACE: case CURR_YUNIT: case CURR_ZUNIT: case COMMON: case RUMP: case MELD: case INSERT: case ONE_OF: case NEXT: case PLUS: case MINUS: case TAGGED: case INCGRAPHIC: case SINCGRAPHIC: case PLAIN_GRAPHIC: case GRAPHIC: case LINK_SOURCE: case LINK_DEST: case LINK_DEST_NULL: case LINK_URL: case NOT_REVEALED: NextToken(t, res); break; case LUSE: case LVIS: case ENV: case USE: case DATABASE: case SYS_DATABASE: case PREPEND: case SYS_PREPEND: case INCG_REPEATED: case SINCG_REPEATED: case OPEN: Error(5, 12, "symbol %s not allowed in macro", WARN, &fpos(t), SymName(actual(t))); NextToken(t, res); break; case LBR: ReadTokenList(t, res); NextToken(t, res); break; case UNEXPECTED_EOF: Error(5, 13, "unexpected end of input", FATAL, &fpos(t)); break; case BEGIN: Error(5, 14, "%s not expected here", WARN, &fpos(t), SymName(actual(t))); NextToken(t, res); break; case RBR: if( type(token) != LBR ) Error(5, 15, "unmatched %s in macro", WARN, &fpos(t), KW_RBR); return; case END: if( type(token) != BEGIN ) Error(5, 16, "unmatched %s in macro", WARN, &fpos(t), KW_END); else { NextToken(t, res); if( type(t) != CLOSURE ) { if( type(t) == WORD && string(t)[0] == CH_SYMSTART ) Error(5, 17, "symbol %s unknown or misspelt", WARN, &fpos(t), string(t)); else Error(5, 18, "symbol name expected after %s", WARN,&fpos(t),KW_END); } else if( actual(token) != actual(t) ) Error(5, 19, "%s %s does not match %s %s", WARN, &fpos(t), SymName(actual(token)), KW_BEGIN, SymName(actual(t)), KW_END); } return; case CLOSURE: xsym = actual(t); PushScope(xsym, TRUE, FALSE); NextToken(t, res); PopScope(); if( type(t) == CROSS || type(t) == FORCE_CROSS ) { NextToken(t, res); break; } /* read named parameters */ while( type(t) == CLOSURE && enclosing(actual(t)) == xsym && type(actual(t)) == NPAR ) { new_par = t; NextToken(t, res); if( type(t) != LBR ) { if( type(t) == RBR ) { if( type(token) != LBR ) Error(5, 20, "unmatched %s in macro", WARN, &fpos(t), KW_RBR); return; } Error(5, 21, "%s must follow named parameter %s", WARN, &fpos(new_par), KW_LBR, SymName(actual(new_par))); break; } /* add import list of the named parameter to current scope */ scope_count = 0; imps = imports(actual(new_par)); if( imps != nilobj ) { for( link = Down(imps); link != imps; link = NextDown(link) ) { Child(y, link); PushScope(actual(y), FALSE, TRUE); scope_count++; } } /* read the body of the named parameter */ PushScope(actual(new_par), FALSE, FALSE); ReadTokenList(t, res); PopScope(); /* pop the scopes pushed for the import list */ for( i = 0; i < scope_count; i++ ) PopScope(); /* get next token, possibly another named parameter */ PushScope(xsym, TRUE, FALSE); NextToken(t, res); PopScope(); } /* read body parameter, if any */ if( has_body(xsym) ) { if( type(t) == LBR || type(t) == BEGIN ) { PushScope(xsym, FALSE, TRUE); PushScope(ChildSym(xsym, RPAR), FALSE, FALSE); if( type(t) == BEGIN ) actual(t) = xsym; ReadTokenList(t, res); PopScope(); PopScope(); NextToken(t, res); } else if( type(t) != RBR && type(t) != END ) Error(5, 22, "right parameter of %s must begin with %s", WARN, &fpos(t), SymName(xsym), KW_LBR); } break; default: Error(5, 23, "ReadTokenList: %s", INTERN, &fpos(t), Image(type(t))); break; } } /* end ReadTokenList */
WWhizReg* WWhizRegCreate(IApplication* pApplication, WWhizInterface* wwhizInterface) { g_pApplication = pApplication; #endif WWHIZ_VC6 #ifdef WWHIZ_VSNET WWhizReg* WWhizRegCreate(void* pDTE, WWhizInterface* wwhizInterface) { g_pDTE = (EnvDTE::_DTE*)pDTE; #endif WWHIZ_VSNET g_wwhizInterface = wwhizInterface; //InitReg(); WWhizReg* reg = WNEW WWhizReg; #ifdef WWHIZ_VC6 // Find the Developer Studio window. (borrowed from Oz Solomonovich) HWND hDesktopWnd = ::GetDesktopWindow(); pApplication->put_Active(VARIANT_FALSE); pApplication->put_Active(VARIANT_TRUE); HWND hWnd = ::GetActiveWindow(); while (hWnd && hWnd != hDesktopWnd) { g_devStudioWnd = hWnd; hWnd = ::GetParent(hWnd); } // Find the MDI client window g_mdiWnd = ::FindWindowEx(g_devStudioWnd, NULL, "MDIClient", NULL); #endif WWHIZ_VC6 #ifdef WWHIZ_VSNET HWND g_devStudioWnd; CComPtr<EnvDTE::Window> pMainWindow; g_pDTE->get_MainWindow(&pMainWindow); if (!pMainWindow) { ::MessageBeep(MB_ICONEXCLAMATION); //???? return NULL; } pMainWindow->get_HWnd((long*)&g_devStudioWnd); // Find the MDI client window HWND g_mdiWnd = ::FindWindowEx(g_devStudioWnd, NULL, "MDIClient", NULL); #endif WWHIZ_VSNET s_regHelperWnd.Create(NULL, "", 0, CRect(0, 0, 0, 0), CWnd::FromHandle(g_devStudioWnd), 0, NULL); s_regHelperWnd.SendMessage(WM_DOREG, 0x1235, (LPARAM)reg); s_regHelperWnd.PostMessage(WM_DOREG, 0x1234, (LPARAM)reg); ReadTokenList(m_filenameEditStringArray, "FilenameEditList"); ReadTokenList(m_tagParentEditStringArray, "TagParentEditList"); ReadTokenList(m_tagEditStringArray, "TagEditList"); // BuildWWhizReg(reg); return reg; }