bool clEditorConfig::LoadForFile(const wxFileName& filename, wxFileName& editorConfigFile) { editorConfigFile = wxFileName(filename.GetPath(), ".editorconfig"); bool foundFile = false; while(editorConfigFile.GetDirCount()) { if(editorConfigFile.FileExists()) { foundFile = true; break; } editorConfigFile.RemoveLastDir(); } if(!foundFile) return false; wxString content; if(!FileUtils::ReadFileContent(editorConfigFile, content)) { clDEBUG() << "Failed to read file:" << editorConfigFile << clEndl; return false; } clEditorConfigSection section; m_sections.push_back(section); clEditorConfigSection* cursection = &(m_sections.back()); wxUnusedVar(cursection); // for debug purposes wxArrayString lines = ::wxStringTokenize(content, "\n", wxTOKEN_STRTOK); for(size_t i = 0; i < lines.size(); ++i) { // Remove comments wxString strLine = lines.Item(i); strLine = strLine.BeforeFirst('#'); strLine = strLine.BeforeFirst(';'); strLine.Trim().Trim(false); if(strLine.IsEmpty()) continue; // Process the line if(strLine.StartsWith("[") && strLine.EndsWith("]")) { strLine.RemoveLast().Remove(0, 1); // remove the [] clEditorConfigSection section; section.patterns = ProcessSection(strLine); m_sections.push_back(section); cursection = &(m_sections.back()); } else { ProcessDirective(strLine); } } clDEBUG() << "Using .editorconfig file:" << editorConfigFile << clEndl; return true; }
bool CHexeMarkupEvaluator::ParseUntilRPC (SHTTPRequestCtx &Ctx) // ParseUntilRPC // // Parses the input until we need to process and RPC request. Returns FALSE if // we need RPC; TRUE otherwise. { while (true) { CString sKey; CString sValue; CHexeMarkupParser::Tokens iToken = m_Parser.ParseToken(&sKey, &sValue); // If error, emit token and return if (iToken == CHexeMarkupParser::tkError) { m_Output.Write(sValue); return ComposeResponse(Ctx); } // Are we done? Then compose the response. else if (iToken == CHexeMarkupParser::tkEoS) return ComposeResponse(Ctx); // If we're excluding content then continue else if (m_iIfLevelEnd > 0) { if (iToken == CHexeMarkupParser::tkPI) { if (strEquals(sKey, PI_ELSE)) { if (m_iIfLevel == m_iIfLevelEnd) m_iIfLevelEnd = 0; } else if (strEquals(sKey, PI_ENDIF)) { if (m_iIfLevel == m_iIfLevelEnd) m_iIfLevelEnd = 0; m_iIfLevel--; } else if (strEquals(sKey, PI_IF)) m_iIfLevel++; } // Otherwise, continue parsing and ignoring. } // If this is a processing instruction, then handle it. else if (iToken == CHexeMarkupParser::tkPI) { // Interpret the instruction if (!ProcessDirective(Ctx, sKey, sValue)) return false; // Continue parsing } // Otherwise we just emit the token to the output else m_Output.Write(sValue); } }
int main() { SStreamStdin s_in; IntelibReader reader; headerlist = (L| "sexpress/sexpress.hpp", "sexpress/iexcept.hpp", "scheme/scheme.hpp", "scheme/schsymb.hpp", "scheme/schfun.hpp", "scheme/schpack.hpp"); funclist = *PTheEmptyList; do { SReference r; try { r = reader.Read(s_in); } catch(const IntelibX_reader_error &err) { fprintf(stderr, "reader: %s %s line %d\n", err.Description(), err.Parameter()->TextRepresentation().c_str(), err.Line() ); return 1; } if(r==IntelibReader::EofMarker) { break; } SExpressionCons *c = r.SimpleCastGetPtr<SExpressionCons>(); if(!c) continue; if(c->Car().IsEql(directives)) { for(SReference i=r.Cdr(); !i.IsEmptyList(); i=i.Cdr()) { ProcessDirective(i.Car()); } } else { ProcessDirective(r); } } while(true); try { Preamble(headerlist); Funclist(funclist); Listbegin(); List(funclist); Epilogue(); } catch(const IntelibX& ex) { fprintf(stderr, "Exception [%s] (%s) caught " "during execution of the file\n", ex.Description(), ex.Parameter().GetPtr() ? ex.Parameter()->TextRepresentation().c_str() : ""); #if 0 if(ex.Stack().GetPtr()) { fprintf(stderr, "%s", stack_representation(ex.Stack()).c_str()); } #endif return 1; } return 0; }