void compile(){ fileSave(); SendMessage(hNotifs, WM_SETTEXT, 0, (LPARAM) ""); FILE *fp; // file input FILE *fo; // file output TokenList * tokenList; fp = fopen(openedFileName, "r"); fo = fopen("SYMBOL TABLE.txt", "w"); tokenList = createTokenList(); initLexer(fp, fo); initToken(tokenList); readToken(); generateCode(tokenList); fclose(fp); fclose(fo); if(strcmp(errorList[0], "") == 0){ SendMessage(hNotifs, WM_SETTEXT, 0, (LPARAM) "No error"); hasError = 0; } else { hasError = 1; int i; for(i = 0; i < sizeof(errorList) / sizeof(errorList[0]); i++){ int index = GetWindowTextLength(hNotifs); SetFocus(hNotifs); SendMessageA(hNotifs, EM_SETSEL, (WPARAM)index, (LPARAM)index); // set selection - end of text SendMessageA(hNotifs, EM_REPLACESEL, 0, (LPARAM) errorList[i]); // append! } } memset(errorList, 0, sizeof(errorList) / sizeof(errorList[0])); }
CodeEditor::CodeEditor(QWidget *parent) : QsciScintilla(parent), m_isUntitled(true) { initLexer(); this->setLexer(m_lexerMaxscript); this->setUtf8(true); this->setMarginLineNumbers(1, true); this->setMarginWidth(1, 35); this->setTabIndents(true); this->setIndentationGuides(true); this->setIndentationsUseTabs(true); this->setAutoIndent(true); this->setTabWidth(4); this->setFolding(QsciScintilla::BoxedTreeFoldStyle); this->setBraceMatching(QsciScintilla::StrictBraceMatch); this->setWrapMode(QsciScintilla::WrapWord); this->setAutoCompletionSource(QsciScintilla::AcsAll); this->setAutoCompletionCaseSensitivity(false); this->setAutoCompletionFillupsEnabled(true); this->setAutoCompletionThreshold(1); this->setAutoCompletionShowSingle(true); this->setAutoCompletionReplaceWord(true); }
void initPassOne() { aboutToFreeRuntime(); //dump_pool_histo(pyr_pool_runtime); pyr_pool_runtime->FreeAllInternal(); //dump_pool_histo(pyr_pool_runtime); //gPermanentObjPool.Init(pyr_pool_runtime, PERMOBJCHUNK); sClassExtFiles = 0; void *ptr = pyr_pool_runtime->Alloc(sizeof(SymbolTable)); gMainVMGlobals->symbolTable = new (ptr) SymbolTable(pyr_pool_runtime, 8192); //gFileSymbolTable = newSymbolTable(512); pyrmath_init_globs(); initSymbols(); // initialize symbol globals //init_graph_compile(); initSpecialSelectors(); initSpecialClasses(); initClasses(); initParserPool(); initParseNodes(); initPrimitives(); //tellPlugInsAboutToCompile(); initLexer(); compileErrors = 0; numClassDeps = 0; compiledOK = false; compiledDirectories.clear(); sc_InitCompileDirectory(); }
LuaEditor::LuaEditor() { initLexer(); QSettings settings(ORGNAME, APPNAME); settings.beginGroup("QtLuaPad"); int tabWidth = settings.value("tabwidth", 4).toInt(); bool folding = settings.value("folding", true).toBool(); bool wrap = settings.value("wrap", false).toBool(); bool braceMatch = settings.value("bracematch", true).toBool(); settings.endGroup(); this->setLexer(lexer); this->setUtf8(true); this->setMarginLineNumbers(1, true); this->setMarginWidth(1, 35); this->setTabIndents(true); this->setIndentationGuides(true); this->setIndentationsUseTabs(true); this->setAutoIndent(true); this->setTabWidth(tabWidth); (folding)? this->setFolding(QsciScintilla::BoxedTreeFoldStyle) : this->setFolding(QsciScintilla::NoFoldStyle); (braceMatch)? this->setBraceMatching(QsciScintilla::StrictBraceMatch) : this->setBraceMatching(QsciScintilla::NoBraceMatch); (wrap)? this->setWrapMode(QsciScintilla::WrapWord) : this->setWrapMode(QsciScintilla::WrapNone); }
static void findRustTags (void) { lexerState lexer; vString* scope = vStringNew(); initLexer(&lexer); parseBlock(&lexer, FALSE, K_NONE, scope); vStringDelete(scope); deInitLexer(&lexer); }
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent) { scintillaLayout = new QVBoxLayout(this); qsci = new QsciScintilla(this); // // Remapping some scintilla key binding which conflict with OpenSCAD global // key bindings, as well as some minor scintilla bugs // QsciCommand *c; #ifdef Q_OS_MAC // Alt-Backspace should delete left word (Alt-Delete already deletes right word) c= qsci->standardCommands()->find(QsciCommand::DeleteWordLeft); c->setKey(Qt::Key_Backspace | Qt::ALT); #endif // Cmd/Ctrl-T is handled by the menu c = qsci->standardCommands()->boundTo(Qt::Key_T | Qt::CTRL); c->setKey(0); // Cmd/Ctrl-D is handled by the menu c = qsci->standardCommands()->boundTo(Qt::Key_D | Qt::CTRL); c->setKey(0); // Ctrl-Shift-Z should redo on all platforms c= qsci->standardCommands()->find(QsciCommand::Redo); c->setKey(Qt::Key_Z | Qt::CTRL | Qt::SHIFT); scintillaLayout->setContentsMargins(0, 0, 0, 0); scintillaLayout->addWidget(qsci); qsci->setBraceMatching (QsciScintilla::SloppyBraceMatch); qsci->setWrapMode(QsciScintilla::WrapCharacter); qsci->setWrapVisualFlags(QsciScintilla::WrapFlagByBorder, QsciScintilla::WrapFlagNone, 0); qsci->setAutoIndent(true); qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator, indicatorNumber); qsci->markerDefine(QsciScintilla::Circle, markerNumber); qsci->setUtf8(true); qsci->setTabIndents(true); qsci->setTabWidth(8); qsci->setIndentationWidth(4); qsci->setIndentationsUseTabs(false); lexer = new ScadLexer(this); initLexer(); initMargin(); qsci->setFolding(QsciScintilla::BoxedTreeFoldStyle, 4); qsci->setCaretLineVisible(true); this->setHighlightScheme(Preferences::inst()->getValue("editor/syntaxhighlight").toString()); connect(qsci, SIGNAL(textChanged()), this, SIGNAL(contentsChanged())); connect(qsci, SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool))); }
void initParser() { pSt.type = PT_STDIN; cl(); waitLex(); pSt.srcStr = NULL; /*pSt.fileStr = NULL;*/ if (pSt.list == NULL) pSt.list = newLexList(); else clearLexList(pSt.list); initLexer(); }
int main() { initLexer(0); testTokenStream("1 + 1", tokens0, N_ELEM(tokens0)); testTokenStream("{a comment line} $1 + 1", tokens0, N_ELEM(tokens0)); testTokenStream("{{a nested comment}} $1 + 1", tokens0, N_ELEM(tokens0)); testTokenStream("{{{a nested doc comment}} $1 + 1", tokens0, N_ELEM(tokens0)); testTokenStream("x-1+y", tokens1, N_ELEM(tokens1)); testTokenStream("_x0{some comment 1} - 1 + y_99", tokens1, N_ELEM(tokens1)); testTokenStream("con CON con99 Con 99", tokens2, N_ELEM(tokens2)); testTokenStream("< =< => > == = +<", tokens3, N_ELEM(tokens3)); testTokenStream(token4test, tokens4, N_ELEM(tokens4)); testTokenStream(token5test, tokens5, N_ELEM(tokens5)); testTokenStream(token6test, tokens6, N_ELEM(tokens6)); testTokenStream(token7test, tokens7, N_ELEM(tokens7)); testNumber("0", 0); testNumber("00", 0); testNumber("007", 7); testNumber("008", 8); testNumber("\t \t 123", 123); testNumber("65535", 65535); testNumber(" $41", 65); testNumber("$01_ff", 511); testNumber("$A5", 165); testNumber("%101", 5); testNumber("%11", 3); testNumber("%%31", 13); testNumber("80_000_000", 80000000); testFloat("1.0", 1.0f); testFloat("2.0", 2.0f); testFloat("0.01", 0.01f); testFloat("1.0e-2", 0.01f); testFloat("1.e-2", 0.01f); testFloat("3.14e5", 314000.0f); testIdentifier("x99+8", "X99"); testIdentifier("_a_b", "_A_b"); printf("all tests passed\n"); return 0; }
void tokenize(SourcePtr source, size_t offset, size_t length, vector<Token> &tokens) { initLexer(source, offset, length); tokens.push_back(Token()); while (nextToken(tokens.back())) { switch (tokens.back().tokenKind) { case T_SPACE : case T_LINE_COMMENT : case T_BLOCK_COMMENT : break; case T_DOC_START: while (nextDocToken(tokens.back())) { if (tokens.back().tokenKind == T_DOC_END) break; tokens.push_back(Token()); } break; default : tokens.push_back(Token()); } } tokens.pop_back(); cleanupLexer(); }
int main(int argv, char* argc[]) { bool good = wxInitialize(); if(!good) { printf("wx could not be initialized, aborting.\n"); exit(-1); } else { printf("wx initialized succesfully!\n"); wxFFileOutputStream MYoutput( stderr ); wxTextOutputStream MYcout( MYoutput ); wxString string = wxT(" a test yo "); MYcout << wxT("Before: '") << string << wxT("'\n"); string = string.Trim(true); MYcout << wxT("AfterT: '") << string << wxT("'\n"); string = string.Trim(false); MYcout << wxT("AfterF: '") << string << wxT("'\n"); } #if 1 if(argv>1) { initLexer(argc[1]); } else { initLexer("input"); } yyparse(); printf("============= RESULT =============\n"); for(int i = 0; i < TheOutput.size(); i++) { printf("%s\n", TheOutput[i].c_str()); } printf("============ UNMATCHED ===========\n"); for(int i = 0; i < TheUnmatched.size(); i++) { printf("%s\n", TheUnmatched[i].c_str()); } printf("============== ERROR =============\n"); for(int i = 0; i < TheError.size(); i++) { printf("%s\n", TheError[i].c_str()); } printf("============= TOKENS =============\n"); for(Itokens it = TheTokens.begin(); it != TheTokens.end(); it++) { printf("'%s'='%s'\n", it->first.c_str(), it->second.c_str()); } printf("=============== DONE =============\n"); wxUninitialize(); return 0; #endif }