bool parse_Until(EToken endToken) { while (lex_Current.token) { if (xasm_Configuration->parseInstruction()) continue; if (parse_SymbolDefinition()) continue; if (parse_Directive()) continue; if (handleMacroInvocation()) continue; if (handleLineBreak()) continue; if (lex_Current.token == endToken) return true; return err_Error(ERROR_SYNTAX); } return true; }
CamlDevWindow::CamlDevWindow(QString wd, QWidget *parent) : QMainWindow(parent) { this->camlProcess = new QProcess(this); this->camlStarted = false; this->currentFile = ""; this->cwd = wd; this->unsavedChanges = false; this->programTitle = "LemonCaml"; /* The window title and icon */ this->setWindowTitle(this->programTitle + " - " + "untitled"); this->setWindowIcon(QIcon(":/progicon.png")); this->settings = new QSettings("Cocodidou", "LemonCaml"); this->globalSettings = new QSettings(QSettings::SystemScope, "Cocodidou", "LemonCaml"); /* The main window elements : two text-areas and a splitter */ this->centralBox = new QVBoxLayout(); this->split = new QSplitter(Qt::Horizontal,this); this->inputZone = new InputZone(); this->inputZone->setTabStopWidth(20); this->inputZone->setAcceptRichText(false); this->resize(settings->value("Size/y",800).toInt(), settings->value("Size/x",600).toInt()); this->move(settings->value("Pos/x",0).toInt(), settings->value("Pos/y",0).toInt()); this->setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint)); #ifndef WIN32 QString defaultFont = "Andale Mono,10,-1,5,50,0,0,0,0,0"; #else QString defaultFont = "Courier New,10,-1,5,50,0,0,0,0,0"; #endif QString iFont = settings->value("Input/Font", defaultFont).toString(); QFont inputFont; inputFont.fromString(iFont); this->inputZone->setFont(inputFont); this->outputZone = new QTextEdit(this); this->outputZone->setReadOnly(true); this->outputZone->setTabStopWidth(20); QString kwfileloc = settings->value("General/keywordspath", (globalSettings->value("General/keywordspath", "./keywords").toString())).toString(); QFile kwfile(kwfileloc); QStringList kwds; if(kwfile.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream kstream(&kwfile); QString st = kstream.readLine(256); while(st != "") { kwds << st; st = kstream.readLine(256); } kwfile.close(); } else { QMessageBox::warning(this, tr("Warning"), tr("Unable to open the keywords file. There will likely be no syntax highlighting.")); } this->hilit = new highlighter(inputZone->document(), &kwds, this->settings); bool isHighlighting = (settings->value("Input/syntaxHighlight",1).toInt() == 1); if(!isHighlighting) { this->hilit->setDocument(NULL); } QString oFont = settings->value("Output/Font", defaultFont).toString(); QFont outputFont; outputFont.fromString(oFont); this->outputZone->setFont(outputFont); /* Find/Replace */ this->find = new findReplace(inputZone, hilit); split->addWidget(this->inputZone); split->addWidget(this->outputZone); split->showMaximized(); centralBox->addWidget(split); centralBox->addWidget(find); if(!centralBox->setStretchFactor(split, 100)) qDebug() << "There will be a problem with Find/replace!"; centralBox->setContentsMargins(0,0,0,0); /* a wrapper widget */ QWidget *window = new QWidget(); window->setLayout(centralBox); window->setContentsMargins(0,0,0,0); this->setCentralWidget(window); find->setVisible(false); if(settings->value("Input/indentOnFly",0).toInt() == 1) inputZone->setHandleEnter(true); /* the printer*/ this->printer = new QPrinter(QPrinter::HighResolution); /* The actions */ this->actionNew = new QAction(tr("New"),this); this->actionNew->setIcon(QIcon(":/new.png")); this->actionNew->setShortcut(QKeySequence(QKeySequence::New)); this->actionOpen = new QAction(tr("Open"),this); this->actionOpen->setIcon(QIcon(":/open.png")); this->actionOpen->setShortcut(QKeySequence(QKeySequence::Open)); this->actionSaveAs = new QAction(tr("Save As"),this); this->actionSaveAs->setIcon(QIcon(":/saveas.png")); this->actionSaveAs->setShortcut(QKeySequence(QKeySequence::SaveAs)); this->actionSave = new QAction(tr("Save"),this); this->actionSave->setIcon(QIcon(":/save.png")); this->actionSave->setShortcut(QKeySequence(QKeySequence::Save)); this->actionAutoIndent = new QAction(tr("Indent code"),this); this->actionAutoIndent->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); this->actionFollowCursor = new QAction(tr("Indent code while typing"),this); this->actionFollowCursor->setCheckable(true); this->actionFollowCursor->setChecked(inputZone->getHandleEnter()); this->actionFollowCursor->setIcon(QIcon(":/autoindent.png")); this->actionPrint = new QAction(tr("Print"),this); this->actionPrint->setIcon(QIcon(":/print.png")); this->actionPrint->setShortcut(QKeySequence(QKeySequence::Print)); this->actionClearOutput = new QAction(tr("Clear output"),this); this->actionQuit = new QAction(tr("Quit"),this); this->actionQuit->setIcon(QIcon(":/exit.png")); this->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit)); this->actionUndo = new QAction(tr("Undo"),this); this->actionUndo->setIcon(QIcon(":/undo.png")); this->actionUndo->setShortcut(QKeySequence(QKeySequence::Undo)); this->actionRedo = new QAction(tr("Redo"),this); this->actionRedo->setIcon(QIcon(":/redo.png")); this->actionRedo->setShortcut(QKeySequence(QKeySequence::Redo)); this->actionDelete = new QAction(tr("Delete"),this); this->actionChangeInputFont = new QAction(tr("Change Input Font"),this); this->actionChangeOutputFont = new QAction(tr("Change Output Font"),this); this->actionSendCaml = new QAction(tr("Send Code to Caml"),this); this->actionSendCaml->setIcon(QIcon(":/sendcaml.png")); this->actionSendCaml->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return)); this->actionInterruptCaml = new QAction(tr("Interrupt Caml"),this); this->actionInterruptCaml->setIcon(QIcon(":/interrupt.png")); this->actionStopCaml = new QAction(tr("Stop Caml"),this); this->actionStopCaml->setIcon(QIcon(":/stopcaml.png")); this->actionShowSettings = new QAction(tr("Settings"),this); this->actionShowSettings->setShortcut(QKeySequence(QKeySequence::Preferences)); this->actionAbout = new QAction(tr("About LemonCaml..."),this); this->actionAboutQt = new QAction(tr("About Qt..."),this); this->actionHighlightEnable = new QAction(tr("Enable syntax highlighting"), this); this->actionHighlightEnable->setIcon(QIcon(":/highlight.png")); this->actionHighlightEnable->setCheckable(true); this->actionHighlightEnable->setChecked(isHighlighting); this->actionZoomIn = new QAction(tr("Zoom in"), this); this->actionZoomIn->setShortcut(QKeySequence(QKeySequence::ZoomIn)); this->actionZoomOut = new QAction(tr("Zoom out"), this); this->actionZoomOut->setShortcut(QKeySequence(QKeySequence::ZoomOut)); this->actionFind = new QAction(tr("Find/Replace..."), this); this->actionFind->setShortcut(QKeySequence(QKeySequence::Find)); this->actionFind->setIcon(QIcon(":/find.png")); this->actionFind->setCheckable(true); this->actionFind->setChecked(false); /* The toolbar */ this->toolbar = new QToolBar(tr("Tools"),this); this->toolbar->addAction(actionNew); this->toolbar->addAction(actionOpen); this->toolbar->addAction(actionSave); this->toolbar->addAction(actionSaveAs); this->toolbar->addAction(actionPrint); this->toolbar->addSeparator(); this->toolbar->addAction(actionUndo); this->toolbar->addAction(actionRedo); this->toolbar->addSeparator(); this->toolbar->addAction(actionSendCaml); this->toolbar->addAction(actionInterruptCaml); this->toolbar->addAction(actionStopCaml); this->toolbar->addAction(actionHighlightEnable); this->toolbar->addAction(actionFollowCursor); this->addToolBar(this->toolbar); /* The menubar */ this->menuFile = this->menuBar()->addMenu(tr("File")); this->menuFile->addAction(actionNew); this->menuFile->addAction(actionOpen); this->menuRecent = this->menuFile->addMenu(tr("Recent files")); this->menuFile->addAction(actionSave); this->menuFile->addAction(actionSaveAs); this->menuFile->addAction(actionPrint); this->menuFile->addAction(actionQuit); this->menuEdit = this->menuBar()->addMenu(tr("Edit")); this->menuEdit->addAction(actionUndo); this->menuEdit->addAction(actionRedo); this->menuEdit->addAction(actionDelete); this->menuEdit->addSeparator(); this->menuEdit->addAction(actionAutoIndent); this->menuEdit->addAction(actionFollowCursor); this->menuEdit->addSeparator(); this->menuEdit->addAction(actionFind); this->menuEdit->addAction(actionClearOutput); this->menuEdit->addAction(actionHighlightEnable); this->menuEdit->addAction(actionChangeInputFont); this->menuEdit->addAction(actionChangeOutputFont); this->menuEdit->addAction(actionZoomIn); this->menuEdit->addAction(actionZoomOut); this->menuCaml = this->menuBar()->addMenu(tr("Caml")); this->menuCaml->addAction(actionSendCaml); this->menuCaml->addAction(actionInterruptCaml); this->menuCaml->addAction(actionStopCaml); this->menuCaml->addAction(actionShowSettings); this->menuHelp = this->menuBar()->addMenu(tr("Help")); this->menuHelp->addAction(actionAbout); this->menuHelp->addAction(actionAboutQt); /* Connections */ connect(inputZone,SIGNAL(returnPressed()),this,SLOT(handleLineBreak())); connect(actionSendCaml,SIGNAL(triggered()),this,SLOT(sendCaml())); connect(camlProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readCaml())); connect(camlProcess,SIGNAL(readyReadStandardError()),this,SLOT(readCamlErrors())); connect(camlProcess,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(updateCamlStatus(QProcess::ProcessState))); connect(actionStopCaml,SIGNAL(triggered()),this,SLOT(stopCaml())); connect(camlProcess,SIGNAL(started()),this,SLOT(camlOK())); connect(actionInterruptCaml,SIGNAL(triggered()),this,SLOT(interruptCaml())); connect(actionSave,SIGNAL(triggered()),this,SLOT(save())); connect(actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs())); connect(actionOpen,SIGNAL(triggered()),this,SLOT(open())); connect(inputZone,SIGNAL(textChanged()),this,SLOT(textChanged())); connect(actionNew,SIGNAL(triggered()),this,SLOT(newFile())); connect(actionClearOutput,SIGNAL(triggered()),this->outputZone,SLOT(clear())); connect(actionChangeInputFont,SIGNAL(triggered()),this,SLOT(changeInputFont())); connect(actionChangeOutputFont,SIGNAL(triggered()),this,SLOT(changeOutputFont())); connect(actionQuit,SIGNAL(triggered()),this,SLOT(close())); connect(actionPrint,SIGNAL(triggered()),this,SLOT(print())); connect(actionUndo,SIGNAL(triggered()),this->inputZone,SLOT(undo())); connect(actionRedo,SIGNAL(triggered()),this->inputZone,SLOT(redo())); connect(actionDelete,SIGNAL(triggered()),this->inputZone,SLOT(paste())); connect(actionShowSettings,SIGNAL(triggered()),this,SLOT(showSettings())); connect(actionHighlightEnable,SIGNAL(toggled(bool)),this,SLOT(toggleHighlightOn(bool))); connect(actionAutoIndent,SIGNAL(triggered()),this,SLOT(autoIndentCode())); connect(actionFollowCursor,SIGNAL(triggered(bool)),this,SLOT(toggleAutoIndentOn(bool))); connect(actionZoomIn,SIGNAL(triggered()),this,SLOT(zoomIn())); connect(actionZoomOut,SIGNAL(triggered()),this,SLOT(zoomOut())); connect(actionFind,SIGNAL(triggered(bool)),this,SLOT(triggerFindReplace(bool))); connect(find,SIGNAL(hideRequest(bool)),this,SLOT(triggerFindReplace(bool))); connect(inputZone, SIGNAL(unindentKeyStrokePressed()), this, SLOT(unindent())); connect(actionAbout,SIGNAL(triggered()),this,SLOT(about())); connect(actionAboutQt,SIGNAL(triggered()),this,SLOT(aboutQt())); this->generateRecentMenu(); this->populateRecent(); this->highlightTriggered = false; fillIndentWords(&indentWords); //Draw trees? this->drawTrees = (settings->value("General/drawTrees",0).toInt() == 1)?true:false; this->graphCount = 0; this->startCamlProcess(); }