void TypeSet( void ) /******************/ { type_display *parent; type_display *field; ScanLeftBrace(); while( !ScanRightBrace() ) { if( ScanCmd( &TypeSettings ) != TY_STRUCT ) oops(); parent = VarDisplayAddStruct( ScanName() ); ScanLeftBrace(); while( !ScanRightBrace() ) { if( ScanAttribute( parent, ScanCmd( &TypeSettings ) ) == TY_FIELD ) { field = VarDisplayAddField( parent, ScanName() ); ScanLeftBrace(); while( !ScanRightBrace() ) { if( ScanAttribute( field, ScanCmd( &TypeSettings ) ) == TY_FIELD ) { oops(); } } } } } ReqEOC(); }
void sXSILoader::ScanChunk(sInt indent,sChar *chunk,sChar *name) { #if DUMPCHUNK sInt i; #endif sScanSpace(Scan); Error |= !sScanName(Scan,chunk,XSISIZE); sScanSpace(Scan); if(*Scan=='{') name[0]=0; else ScanName(name,XSISIZE); if(!Error) { #if DUMPCHUNK sDPrintF("\n"); for(i=0;i<indent;i++) sDPrintF(" "); sDPrintF("%s \"%s\"",chunk,name); #endif } sScanSpace(Scan); if(*Scan!='{') Error = sTRUE; else Scan++; }
//----------------------------------------------------------------- static HRESULT ScanAttribute( const CH * pchStart, const CH * pchEnd, HATT * pAtt) { if(pchStart == NULL) return E_INVALIDARG; const CH * pch; int cch; const CH * pchScan = pchStart; HRESULT hr; if (pAtt) memset(pAtt, 0, sizeof(HATT)); SKIPWHITE_FAIL switch (*pchScan) { case _CH('>'): return S_FALSE; // end of tag -- no attribute case _CH('/'): // End of empty element (e.g. "<foo ... />"). No more attributes. return S_FALSE; case _CH('-'): // comment if (pAtt) return ScanComment(pchScan, pchEnd, &pAtt->pchValue, &pAtt->cchValue); else return ScanComment(pchScan, pchEnd, 0, 0); break; } // scan Name hr = ScanName(pchScan, pchEnd, &pch, &cch); if (FAILED(hr)) return hr; if (pAtt) { pAtt->pchName = pch; pAtt->cchName = cch; } pchScan = pch + cch; SKIPWHITE_FAIL if (*pchScan != _CH('=')) return hr; pchScan++; SKIPWHITE_FAIL hr = ScanValue(pchScan, pchEnd, &pch, &cch); if (SUCCEEDED(hr) && pAtt) { pAtt->pchValue = pch; pAtt->cchValue = cch; } return hr; }
void Lexer::ScanQualifiedRef() { const char* endLastWord = tp; *tp++ = m_cc; ScanName(); if (m_tokenType != NameConst) { m_tokenType = NameConst; } else { if (m_cc == '.' && isLetter(PeekAtChar())) ScanQualifiedRef(); else PushBack(m_cc); } }
void Lexer::ScanIdentifierOrKeyword() { m_tokenType = NameConst; ScanName(); if (m_tokenType == NameConst && m_cc == '.' && isLetter(PeekAtChar())) ScanQualifiedRef(); else { // It might be a Keyword terminated with a ':' (but not :=) // in which case we need to include it. if (m_cc == ':' && PeekAtChar() != '=') { *tp++ = m_cc; m_tokenType = NameColon; } else { PushBack(m_cc); } } }
//----------------------------------------------------------------- static void ScanItem (const CH * pchStart, const CH * pchEnd, HTOK * pk) { if(pchStart == NULL || pk == NULL) { VSASSERT(false,""); return; } HRESULT hr; pk->id = hi_Unknown; pk->pch = (CH*)pchStart; pk->cch = 0; pk->bEnd = false; if (pchStart >= pchEnd) { pk->id = hi_Eof; return; } const CH * pchScan = pchStart; switch (*pchScan) { // case _CH(0): // pk->id = hi_Eof; // break; // // case _CH('\n'): // case _CH('\r'): // pchScan = AdvanceLineBreak((CH*)pchScan); // pk->id = hi_Eol; // break; case _CH('<'): { const CH * pchName; int cch; pchScan++; pk->id = hi_Error; switch (*pchScan) { case _CH('!'): pk->id = hi_Error; pchScan++; while (_CH('>') != *pchScan) { const CH * pch; int cch; SKIPWHITE_RET if (IsAAlpha(*pchScan)) hr = ScanName(pchScan, pchEnd, &pch, &cch); else { switch(*pchScan) { case CH('\''): case CH('"'): hr = ScanValue(pchScan, pchEnd, &pch, &cch); break; case CH('-'): hr = ScanComment(pchScan, pchEnd, &pch, &cch); break; default: hr = S_OK; pch = pchScan; cch = 1; break; } } pchScan = pch + cch; if (FAILED(hr) || (pchScan >= pchEnd)) return; } pk->id = hi_TagSpecial; break; case _CH('%'): // ASP 'tag' pk->id = hi_TagSpecial; do { do { pchScan++; } while ((pchScan < pchEnd) && (_CH('>') != *pchScan)); } while ((pchScan < pchEnd) && (*(pchScan-1) != _CH('%'))); break; case _CH('/'): pk->bEnd = true; pchScan++; break; case _CH('?'): // pk->id = hi_TagSpecial; pchScan++; while ((pchScan < pchEnd) && (_CH('>') != *pchScan)) pchScan++; break; } if (pk->id != hi_TagSpecial) { pk->id = hi_Error; SKIPWHITE_RET if (!IsAAlpha(*pchScan)) return; pchName = pchScan; while ((pchScan < pchEnd) && IsAAlNum(*pchScan)) pchScan++; if (pchScan >= pchEnd) return; cch = (int)(pchScan - pchName); if (cch <= cchMaxTag && cch > 0) { CH * pszName = (CH*)_alloca((cch+1)*CBCH ); strcchcopy(pszName, cch+1, pchName); pk->id = LookupElement(pszName); } else return; if (!pk->bEnd) { // scan attributes and comments for(;;) { HATT hatt; HRESULT hr = ScanAttribute(pchScan, pchEnd, &hatt); if (FAILED(hr)) { pk->id = hi_Error; return; } if (S_FALSE == hr) break; pchScan = hatt.pchValue ? hatt.pchValue + hatt.cchValue : hatt.pchName + hatt.cchName; } } } // Skip over whitespace and, if this is an empty element, the closing '/' (e.g. "<foo ... />") while ((pchScan < pchEnd) && ((*pchScan <= 32) || (*pchScan == _CH('/')))) pchScan++; if ((pchScan >= pchEnd) || (_CH('>') != *pchScan)) pk->id = hi_Error; pchScan++; } break; // case _CH('&'): // pk->id = hi_Entity; // if (!ScanEntity(pchScan, &pk->ch, &pchScan)) // goto L_Text; // break; default: //L_Text: pk->id = hi_Text; for (bool f = true; f && (pchScan < pchEnd); ) { switch (*pchScan) { // case _CH(0): // case _CH('\n'): // case _CH('\r'): // case _CH('&'): case _CH('<'): f = false; break; default: pchScan++; break; } } break; }
//----------------------------------------------------------------- // FindAttribute - Find a specific attribute // // Returns: // S_OK Found Attribute // S_FALSE Attribute not found // E_FAIL Syntax error // static HRESULT FindAttribute (const CH * pchTag, const CH *pchEnd, const CH * pszAName, const CH **ppchVal, int * pcchVal) { if(pchTag == NULL || pszAName == NULL || *pszAName == NULL) { VSASSERT(false,""); return E_INVALIDARG; } HRESULT hr; const CH * pch; int cch; int cchAttIn = slen(pszAName); const CH * pchScan = pchTag; const CH * pchVal = 0; *ppchVal = 0; *pcchVal = 0; if (*pchScan == _CH('<')) pchScan++; // don't look in ! tags or end tags if (*pchScan == _CH('!') || *pchScan == _CH('/') || *pchScan == _CH('?')) return S_FALSE; SKIPWHITE_FAIL hr = ScanName(pchScan, pchEnd, &pch, &cch); if (FAILED(hr)) return E_FAIL; pchScan = pch + cch; if (pchScan >= pchEnd) return S_FALSE; // no attributes for(;;) { HATT hatt; HRESULT hr = ScanAttribute(pchScan, pchEnd, &hatt); if (FAILED(hr)) return E_FAIL; if (S_FALSE == hr) break; pchScan = hatt.pchValue ? hatt.pchValue + hatt.cchValue : hatt.pchName + hatt.cchName; if (!hatt.pchName || !hatt.cchName) continue; // comment if ((cchAttIn == hatt.cchName) && (0 == icmpn(hatt.pchName, pszAName, cchAttIn))) { /// strip quotes, if any CH ch = *hatt.pchValue; if (ch == _CH('"') || ch == _CH('\'')) { VSASSERT(ch == hatt.pchValue[hatt.cchValue-1],""); hatt.pchValue++; hatt.cchValue -= 2; } // done! *ppchVal = hatt.pchValue; *pcchVal = hatt.cchValue; return S_OK; } } return S_FALSE; }
static int ScanAttribute( type_display *type, int token ) { bool dirty = TRUE; switch( token ) { case TY_FIELD: dirty = FALSE; break; case TY_ONTOP: type->on_top = TRUE; break; case TY_HASTOP: type->has_top = TRUE; dirty = FALSE; break; case TY_AUTOEXPAND: type->autoexpand = TRUE; break; case TY_ISSTRUCT: VarDisplayAlias( type, VarDisplayAddStruct( ScanName() ) ); dirty = FALSE; case TY_HEX: type->display |= VARDISP_HEX; break; case TY_DECIMAL: type->display |= VARDISP_DECIMAL; break; case TY_CHARACTER: type->display |= VARDISP_CHARACTER; break; case TY_STRING: type->display |= VARDISP_STRING; break; case TY_POINTER: type->display |= VARDISP_POINTER; break; case TY_HIDE: #ifdef I_EVER_SOLVE_THIS_THORNY_HIDE_PROBLEM type->display |= VARDISP_HIDE; #endif break; case TY_NOCODE: type->hide |= VARNODE_CODE; break; case TY_NOINHERIT: type->hide |= VARNODE_INHERIT; break; case TY_NOCOMPILER: type->hide |= VARNODE_COMPILER; break; case TY_NOPRIVATE: type->hide |= VARNODE_PRIVATE; break; case TY_NOPROTECTED: type->hide |= VARNODE_PROTECTED; break; case TY_NOSTATIC: type->hide |= VARNODE_STATIC; break; case TY_CODE: type->hide &= ~VARNODE_CODE; break; case TY_INHERIT: type->hide &= ~VARNODE_INHERIT; break; case TY_COMPILER: type->hide &= ~VARNODE_COMPILER; break; case TY_PRIVATE: type->hide &= ~VARNODE_PRIVATE; break; case TY_PROTECTED: type->hide &= ~VARNODE_PROTECTED; break; case TY_STATIC: type->hide &= ~VARNODE_STATIC; break; default: oops(); } if( dirty ) VarDisplayDirty( type ); return( token ); }