예제 #1
0
void CamlDevWindow::readCaml()
{
   
   QString stdOut = camlProcess->readAllStandardOutput();
   stdOut = removeUnusedLineBreaks(stdOut,false);
   if(drawTrees)
   {
      while(stdOut.indexOf("--LemonCamlCommand--") != -1)
      {
         int j = stdOut.indexOf("--LemonCamlCommand--"); //20
         int p = stdOut.indexOf("--EndLemonCamlCommand--"); //23
         if(p == -1)
         {
            appendOutput(tr("---LemonCaml error--- Unterminated command: not interpreted\n"), Qt::red);
            stdOut = stdOut.mid(j + 20);
         }
         else
         {
            appendOutput(stdOut.left(j),this->palette().color(QPalette::WindowText));
            QString cmd = stdOut.mid(j + 20, (p - j - 20));
            QStringList cmdlist = parseBlockCommand(cmd);

            processCommandList(&cmdlist);
            stdOut = stdOut.mid(p + 23);
         }
      }
      while(stdOut.indexOf("--LemonTree--") != -1) //TODO: change this!!!! never leave such an absolute type name here; ask the user, instead.
      {
         int j = stdOut.indexOf("--LemonTree--"); // 17
         int p = stdOut.indexOf("--EndLemonTree--"); //20
         if(p == -1)
         {
            appendOutput(tr("---LemonCaml error--- Unterminated tree: not drawn\n"), Qt::red);
            stdOut = stdOut.mid(j + 17);  
         }
         else
         {
            appendOutput(stdOut.left(j),this->palette().color(QPalette::WindowText));
            QString arb = stdOut.mid(j + 13, (p - j - 13));
            int k = arb.indexOf('(');
            if(k != -1)
            {
               QString arbString = arb.mid(k);
               treeParser* tp = new treeParser();
               QImage* img = tp->parseTree(arbString);
               QTextCursor cursor = outputZone->textCursor();
               cursor.insertImage((*img), QString(this->graphCount));
               outputZone->insertPlainText("\n");
               this->graphCount++;
            }
            stdOut = stdOut.mid(p + 16);
         }
         
      }
   }
   if(stdOut != "") appendOutput(stdOut,this->palette().color(QPalette::WindowText));
   
}
예제 #2
0
BlockContentComment *Parser::parseParagraphOrBlockCommand() {
  SmallVector<InlineContentComment *, 8> Content;

  while (true) {
    switch (Tok.getKind()) {
    case tok::verbatim_block_begin:
    case tok::verbatim_line_name:
    case tok::eof:
      assert(Content.size() != 0);
      break; // Block content or EOF ahead, finish this parapgaph.

    case tok::command:
      if (S.isBlockCommand(Tok.getCommandName())) {
        if (Content.size() == 0)
          return parseBlockCommand();
        break; // Block command ahead, finish this parapgaph.
      }
      if (S.isInlineCommand(Tok.getCommandName())) {
        Content.push_back(parseInlineCommand());
        continue;
      }

      // Not a block command, not an inline command ==> an unknown command.
      Content.push_back(S.actOnUnknownCommand(Tok.getLocation(),
                                              Tok.getEndLocation(),
                                              Tok.getCommandName()));
      consumeToken();
      continue;

    case tok::newline: {
      consumeToken();
      if (Tok.is(tok::newline) || Tok.is(tok::eof)) {
        consumeToken();
        break; // Two newlines -- end of paragraph.
      }
      if (Content.size() > 0)
        Content.back()->addTrailingNewline();
      continue;
    }

    // Don't deal with HTML tag soup now.
    case tok::html_start_tag:
      Content.push_back(parseHTMLStartTag());
      continue;

    case tok::html_end_tag:
      Content.push_back(parseHTMLEndTag());
      continue;

    case tok::text:
      Content.push_back(S.actOnText(Tok.getLocation(),
                                    Tok.getEndLocation(),
                                    Tok.getText()));
      consumeToken();
      continue;

    case tok::verbatim_block_line:
    case tok::verbatim_block_end:
    case tok::verbatim_line_text:
    case tok::html_ident:
    case tok::html_equals:
    case tok::html_quoted_string:
    case tok::html_greater:
    case tok::html_slash_greater:
      llvm_unreachable("should not see this token");
    }
    break;
  }

  return S.actOnParagraphComment(copyArray(llvm::makeArrayRef(Content)));
}