Exemple #1
0
void LatexDocVisitor::visit(DocInclude *inc)
{
  if (m_hide) return;
  switch(inc->type())
  {
    case DocInclude::IncWithLines:
      { 
         m_t << "\n\n\\footnotesize\\begin{verbatim}"; 
         QFileInfo cfi( inc->file() );
         FileDef fd( cfi.dirPath(), cfi.fileName() );
         parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile(), &fd);
         m_t << "\\end{verbatim}\n\\normalsize" << endl; 
      }
      break;    
    case DocInclude::Include: 
      m_t << "\n\n\\footnotesize\\begin{verbatim}"; 
      parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile());
      m_t << "\\end{verbatim}\n\\normalsize" << endl; 
      break;
    case DocInclude::DontInclude: 
      break;
    case DocInclude::HtmlInclude: 
      break;
    case DocInclude::VerbInclude: 
      m_t << "\n\n\\footnotesize\\begin{verbatim}"; 
      m_t << inc->text();
      m_t << "\\end{verbatim}\n\\normalsize" << endl; 
      break;
  }
}
void ConnectionParser::dataReceived() {
    while (mSocket->canReadLine()) {
        QString line = mSocket->readLine();
        QStringList parsedArray = splitRawLine(line, true);
        QString coreCommand = parsedArray.at(0);

        qDebug() << parsedArray;
        if (coreCommand == "PING") {
            mInternalSender->sendPong(parsedArray.at(1));
        } else if (coreCommand == "ERROR") {
            return;
        } else {
            QString command = parsedArray.at(1);

            bool numeric;
            int code = command.toInt(&numeric);
            if (numeric) {
                if (parseCode(parsedArray, code)) {
                    QObject::disconnect(mSocket, &QTcpSocket::readyRead,
                                        this, &ConnectionParser::dataReceived);
                    return;
                }
            } else {
                parseCommand(parsedArray, command);
            }
        }
    }
}
Exemple #3
0
void LatexDocVisitor::visit(DocIncOperator *op)
{
  //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
  //    op->type(),op->isFirst(),op->isLast(),op->text().data());
  if (op->isFirst()) 
  {
    if (!m_hide) m_t << "\n\n\\footnotesize\\begin{verbatim}"; 
    pushEnabled();
    m_hide = TRUE;
  }
  if (op->type()!=DocIncOperator::Skip) 
  {
    popEnabled();
    if (!m_hide) parseCode(m_ci,op->context(),op->text().latin1(),op->isExample(),op->exampleFile());
    pushEnabled();
    m_hide=TRUE;
  }
  if (op->isLast())  
  {
    popEnabled();
    if (!m_hide) m_t << "\\end{verbatim}\n\\normalsize" << endl; 
  }
  else
  {
    if (!m_hide) m_t << endl;
  }
}
Exemple #4
0
void __fastcall TForm1::Edit1KeyPress(TObject *Sender,
char &Key){
    if(Key==13){
        Memo1->Lines->Add(">>> "+Edit1->Text);
    switch(state){
        case loop:
            try{
                str last="",now="";
                now =preprocess(Edit1->Text);
                while(now!=last){
                    last=now;
                    now= preprocess(last);}
                compile(parseCode(last));}
            catch(str msg){
                Memo1->Lines->Add(msg);
                while(bytecode.size()!=bytecodeptr)
                    bytecode.pop_back();}
            execute( bytecodeptr);
            bytecodeptr=bytecode.size();
            Edit1->Text="";
        break;
        case input:
            state=loop;
        break;}
    ListBox1->Clear();
    ListBox2->Clear();
    ListBox3->Clear();
    for(unsigned long long int i=0;i<stack.size();i++){
        ListBox1->Items->Insert(0,FloatToStr(stack[i]));}
    for(unsigned long long int i=0;i<hand1.size();i++){
        ListBox2->Items->Insert(0,FloatToStr(hand1[i]));}
    for(unsigned long long int i=0;i<hand2.size();i++){
        ListBox3->Items->Insert(0,FloatToStr(hand2[i]));}}}
Exemple #5
0
/**
 * 从字符串中初始化
 */
bool tixmlCode::initFromString(const char *content)
{
    TiXmlDocument doc;
    doc.Parse(content);
    static std::string CODE="code";
    static std::string READ="read";
    TiXmlHandle hDoc(&doc);
    TiXmlElement* pElem = NULL;
    pElem=hDoc.FirstChildElement().Element();
    for(; pElem; pElem=pElem->NextSiblingElement())
    {
        const char *pKey=pElem->Value();
        tixmlCodeNode *node = new tixmlCodeNode();
        node->init(pElem);
        if (node->nodeName == CODE)
        {
            parseCode(node);
        }
        else if (node->nodeName == READ)
        {
            std::string fileName = node->getAttr("file");
            init(fileName.c_str()); // 加载其他文本进入当前执行环境
        }
        else
        {
            takeNode(node); // 调用使用者的方法
        }
    }
    return  true;
}
Exemple #6
0
void ManDocVisitor::visit(DocInclude *inc)
{
  if (m_hide) return;
  switch(inc->type())
  {
    case DocInclude::IncWithLines:
      { 
         if (!m_firstCol) m_t << endl;
         m_t << ".PP" << endl;
         m_t << ".nf" << endl;
         QFileInfo cfi( inc->file() );
         FileDef fd( cfi.dirPath(), cfi.fileName() );
         parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile(), &fd);
         if (!m_firstCol) m_t << endl;
         m_t << ".fi" << endl;
         m_t << ".PP" << endl;
         m_firstCol=TRUE;
      }
      break;
    case DocInclude::Include: 
      if (!m_firstCol) m_t << endl;
      m_t << ".PP" << endl;
      m_t << ".nf" << endl;
      parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile());
      if (!m_firstCol) m_t << endl;
      m_t << ".fi" << endl;
      m_t << ".PP" << endl;
      m_firstCol=TRUE;
      break;
    case DocInclude::DontInclude: 
      break;
    case DocInclude::HtmlInclude: 
      break;
    case DocInclude::VerbInclude: 
      if (!m_firstCol) m_t << endl;
      m_t << ".PP" << endl;
      m_t << ".nf" << endl;
      m_t << inc->text();
      if (!m_firstCol) m_t << endl;
      m_t << ".fi" << endl;
      m_t << ".PP" << endl;
      m_firstCol=TRUE;
      break;
  }
}
Exemple #7
0
void LatexDocVisitor::visit(DocVerbatim *s)
{
  if (m_hide) return;
  switch(s->type())
  {
    case DocVerbatim::Code: 
      m_t << "\n\n\\footnotesize\\begin{verbatim}"; 
      parseCode(m_ci,s->context(),s->text().latin1(),s->isExample(),s->exampleFile());
      m_t << "\\end{verbatim}\n\\normalsize" << endl; 
      break;
    case DocVerbatim::Verbatim: 
      m_t << "\n\n\\footnotesize\\begin{verbatim}"; 
      m_t << s->text();
      m_t << "\\end{verbatim}\n\\normalsize" << endl; 
      break;
    case DocVerbatim::HtmlOnly: 
    case DocVerbatim::XmlOnly: 
    case DocVerbatim::ManOnly: 
      /* nothing */ 
      break;
    case DocVerbatim::LatexOnly: 
      m_t << s->text(); 
      break;
    case DocVerbatim::Dot: 
      {
        static int dotindex = 1;
        QCString fileName(4096);

        fileName.sprintf("%s%d", 
            (Config_getString("LATEX_OUTPUT")+"/inline_dotgraph_").data(), 
            dotindex++
           );
        QFile file(fileName);
        if (!file.open(IO_WriteOnly))
        {
          err("Could not open file %s for writing\n",fileName.data());
        }
        file.writeBlock( s->text(), s->text().length() );
        file.close();

        m_t << "\\begin{center}\n";
        startDotFile(fileName,"","",FALSE);
        endDotFile(FALSE);
        m_t << "\\end{center}\n";

        file.remove();
      }
      break;
  }
}
Exemple #8
0
DisassembledFiles disassemble(const QByteArray &elf, const QString &a43, QString &error) {
	DisassembledFiles df;

	bool hasELF = true;
	QByteArray code = elf;
	if (code.isEmpty()) {
		hasELF = false;
		code = a43.toAscii();
	}

	QString f_in = QDir::tempPath() + "/test.dump";
	QFile file(f_in);
	if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
		error = QString("Cannot open '%1' for writing.").arg(f_in);
		return df;
	}

	file.write(code);
	file.close();

	QProcess objdump;
	QSettings settings("QSimKit", "MSP430");
	if (hasELF) {
#ifdef Q_OS_LINUX
		objdump.start(settings.value("objdump", "msp430-objdump").toString(), QStringList() << "-dSl" << "--prefix=+<FILE" << f_in);
#else
		objdump.start(settings.value("objdump", "msp430-objdump").toString(), QStringList() << "-dSl" << f_in);
#endif
	}
	else {
		objdump.start(settings.value("objdump", "msp430-objdump").toString(), QStringList() << "-D" << "-m" << "msp430:430" << f_in);
	}
	
	if (!objdump.waitForStarted()) {
		error = QString("'msp430-objdump' cannot be started. Is msp430-gcc installed and is msp430-objdump in PATH?");
		return df;
	}

	if (!objdump.waitForFinished()) {
		error = QString("'msp430-objdump' did not finish properly.");
		return df;
	}

	QString result = QString(objdump.readAll());
	parseCode(df, result, error);

	return df;
}
Exemple #9
0
void ClintWindow::reparseCode() {
  if (!m_program)
    return;
  ClintScop *vscop = (*m_program)[0];
  if (!vscop)
    return;

  QString plainText = m_codeEditor->toPlainText();
  char *code = strdup(plainText.toStdString().c_str());
  osl_scop_p scop = parseCode(code);
  if (scop == nullptr) {
    QMessageBox::critical(this, "Could not parse code", "Could not extract polyhedral representation from the code",
                          QMessageBox::Ok, QMessageBox::Ok);
  } else {
    regenerateScop(scop);
  }
  free(code);
}
void SPDImplementation::parseElement(TiXmlElement *elem)
{
    parseID (elem);
    parsePRFRef (elem);
    parseCode (elem);
    parseCompiler (elem);
    parsePrgLanguage (elem);
    parseHumanLanguage (elem);
    parseRuntime (elem);
    parseOperatingSystems (elem);
    parseProcessors (elem);
    parseDependencies (elem);
#if 0
    parsePropertyDependencies (elem);
#endif
    parseUsesDevices (elem);

}
Exemple #11
0
void interpretChar(char c) {
	switch (engInfo.mode) {
		case PRINTING_MODE:
			switch (c) {
				case ASCII_ESC:
					engInfo.mode = INTERPRETING_MODE;
					break;
				case ASCII_CR:
					SetCursorPosition(ROW(TermInfo), 0);
					break;
				case ASCII_LF:
					NewLine();
					break;
				case ASCII_BS:
					BackSpace();
					break;
				case ASCII_BELL:
					Beep(750, 300);
					break;
				case 0x0F:
					// do nothing!
					break;

				default:
					PrintChar(c);
					break;
			}
			break;
		case INTERPRETING_MODE:
			engInfo.code[engInfo.codeLen] = c;
			switch (parseCode()) {
				case PARTIAL:
					engInfo.codeLen++;
					break;
				case VALID:
					resetCode();
					break;
				case INVALID:
					resetCode();
					break;
			}
	}
}
Exemple #12
0
void ManDocVisitor::visit(DocIncOperator *op)
{
  //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
  //    op->type(),op->isFirst(),op->isLast(),op->text().data());
  if (op->isFirst()) 
  {
    if (!m_hide)
    {
      if (!m_firstCol) m_t << endl;
      m_t << ".PP" << endl;
      m_t << ".nf" << endl;
    }
    pushEnabled();
    m_hide = TRUE;
  }
  if (op->type()!=DocIncOperator::Skip) 
  {
    popEnabled();
    if (!m_hide) parseCode(m_ci,op->context(),op->text().latin1(),op->isExample(),op->exampleFile());
    pushEnabled();
    m_hide=TRUE;
  }
  if (op->isLast())  
  {
    popEnabled();
    if (!m_hide)
    {
      if (!m_firstCol) m_t << endl;
      m_t << ".fi" << endl;
      m_t << ".PP" << endl;
      m_firstCol=TRUE;
    }
  }
  else
  {
    if (!m_hide) m_t << endl;
  }
}
Exemple #13
0
void ManDocVisitor::visit(DocVerbatim *s)
{
  if (m_hide) return;
  switch(s->type())
  {
    case DocVerbatim::Code: // fall though
      if (!m_firstCol) m_t << endl;
      m_t << ".PP" << endl;
      m_t << ".nf" << endl;
      parseCode(m_ci,s->context(),s->text().latin1(),s->isExample(),s->exampleFile());
      if (!m_firstCol) m_t << endl;
      m_t << ".fi" << endl;
      m_t << ".PP" << endl;
      m_firstCol=TRUE;
      break;
    case DocVerbatim::Verbatim: 
      if (!m_firstCol) m_t << endl;
      m_t << ".PP" << endl;
      m_t << ".nf" << endl;
      m_t << s->text();
      if (!m_firstCol) m_t << endl;
      m_t << ".fi" << endl;
      m_t << ".PP" << endl;
      m_firstCol=TRUE;
      break;
    case DocVerbatim::ManOnly: 
      m_t << s->text(); 
      break;
    case DocVerbatim::HtmlOnly: 
    case DocVerbatim::XmlOnly: 
    case DocVerbatim::LatexOnly: 
    case DocVerbatim::Dot: 
      /* nothing */ 
      break;
  }
}
Exemple #14
0
JSObject* JSLazyEventListener::jsFunction(ScriptExecutionContext* executionContext) const
{
    parseCode(executionContext);
    return m_jsFunction;
}
Exemple #15
0
bool parseValue(File& file, Value& out_value)
{
	skipWhitespaces(file);

	char c = *file.str;

	uint32_t line_num = file.current_line_num;

	if(c == '{')
	{
		Object obj;

		if(!parseObject(file, obj))
			return false;

		out_value = Value(std::move(obj), line_num);
	}
	else if(c == '[')
	{
		Array arr;

		if(!parseArray(file, arr))
			return false;

		out_value = Value(std::move(arr), line_num);
	}
	else if(c == '"')
	{
		std::string str;

		if(consume(file, "\"\"\""))
		{
			if(!parseCode(file, str))
				return false;

		}
		else if(!parseString(file, str))
			return false;

		out_value = Value(std::move(str), line_num);
	}
	else if(c == '-' || (c >= '0' && c <= '9'))
	{
		double num;

		if(!parseNumber(file, num))
			return false;

		out_value = Value(num, line_num);
	}
	else if(isAlpha(*file.str))
	{
		if(*file.str == 't' && consume(file, "true"))
		{
			out_value = Value(true, line_num);
			return true;
		}
		else if(*file.str == 'f' && consume(file, "false"))
		{
			out_value = Value(false, line_num);
			return true;
		}
		else if(*file.str == 'n' && consume(file, "null"))
		{
			out_value = Value(line_num);
			return true;
		}

		std::string str;

		if(!parseIdentifier(file, str))
			return false;

		out_value = Value(std::move(str), line_num);
	}
	else if(c == '\0')
	{
		std::cout << "Line " << file.current_line_num << ": Unexpected end-of-file!\n";
		return false;
	}
	else
	{
		std::cout << "Line " << file.current_line_num << ": Unexpected char '" << c << "'!\n";
		return false;
	}

	return true;
}
bool ShaderResource::load( const char *data, int size )
{
	if( !Resource::load( data, size ) ) return false;
	if( data[size - 1] != '\0' )
	{	
		return raiseError( "Data block not NULL-terminated" );
	}
	
	// Parse shader
	XMLResults res;
	XMLNode rootNode = XMLNode::parseString( data, "Shader", &res );
	if( res.error != eXMLErrorNone )
	{
		return raiseError( XMLNode::getError( res.error ), res.nLine );
	}
	
	int nodeItr1 = 0;
	XMLNode node1 = rootNode.getChildNode( "Context", nodeItr1 );
	while( !node1.isEmpty() )
	{
		if( node1.getAttribute( "id" ) == 0x0 ) return raiseError( "Missing Context attribute 'id'" );
		
		ShaderContext sc;

		sc.id = node1.getAttribute( "id" );
		
		// Config
		XMLNode node2 = node1.getChildNode( "RenderConfig" );
		if( !node2.isEmpty() )
		{
			if( _stricmp( node2.getAttribute( "writeDepth", "true" ), "false" ) == 0 ||
				_stricmp( node2.getAttribute( "writeDepth", "1" ), "0" ) == 0 )
				sc.writeDepth = false;
			else
				sc.writeDepth = true;

			if( _stricmp( node2.getAttribute( "blendMode", "REPLACE" ), "BLEND" ) == 0 )
				sc.blendMode = BlendModes::Blend;
			else if( _stricmp( node2.getAttribute( "blendMode", "REPLACE" ), "ADD" ) == 0 )
				sc.blendMode = BlendModes::Add;
			else if( _stricmp( node2.getAttribute( "blendMode", "REPLACE" ), "ADD_BLENDED" ) == 0 )
				sc.blendMode = BlendModes::AddBlended;
			else if( _stricmp( node2.getAttribute( "blendMode", "REPLACE" ), "MULT" ) == 0 )
				sc.blendMode = BlendModes::Mult;
			else
				sc.blendMode = BlendModes::Replace;
		}
		
		// Code 
		node2 = node1.getChildNode( "VertexShader" );
		if( node2.isEmpty() ) return raiseError( "Missing VertexShader node in Context '" + sc.id + "'" );
		if( !parseCode( node2, sc.vertShaderFracts ) ) return raiseError( "Error in VertexShader node of Context '" + sc.id + "'" );

		node2 = node1.getChildNode( "FragmentShader" );
		if( node2.isEmpty() ) return raiseError( "Missing VertexShader node in Context '" + sc.id + "'" );
		if( !parseCode( node2, sc.fragShaderFracts ) ) return raiseError( "Error in FragmentShader node of Context '" + sc.id + "'" );

		_contexts.push_back( sc );
		
		node1 = rootNode.getChildNode( "Context", ++nodeItr1 );
	}

	compileShaders();
	
	return true;
}
void InsertGraphics::setCode(const QString &code) {
	InsertGraphicsConfig conf;
	if (parseCode(code, conf)) setConfig(conf);
}
Exemple #18
0
void gcode_parse(char* data)
{
    // Add buffering logic here
    parseCode(data);
}
Exemple #19
0
Object *parseFile(FILE *file, Object *parent)
{
	/* State:
	   0 = read tag name [ ]
	   1 = wait for property list [(]
	   2 = check new objects [(]
	   3 = Read content if tag name is code
	*/
	int state = 0;
	int c;
	char **propertyList;
	char *name = MALLOCN(char, 255);
	int i = 0;
	int iChild = 0;
	Object **childs;
	childs = MALLOCN(Object *, 255);
	Object *obj;
	
	DMSG("parse file\n");
	
	for (c = fgetc(file); c != ')'; c = fgetc(file)) {
		switch (state) {
		case 0:
			switch (c) {
			case ' ':
				name[i] = '\0';
				state = 1;
				DMSG("switch to state 1\n");
				break;
			default:
				name[i++] = c;
				break;
			}
			break;
			
		case 1:
			switch (c) {
			case '(':
				propertyList = parseProperties(name, file);
				obj = createObject(name, propertyList);
				if (strcmp(name, "code") == 0) {
					state = 3;
					DMSG("switch to state 3\n");
				}
				else {
					state = 2;
					DMSG("switch to state 2\n");
				}
				break;
			}
			break;
			
		case 2:
			switch (c) {
			case '(':
				childs[iChild++] = parseFile(file, obj);
				childs[iChild] = NULL;
				break;
			}
			break;
			
		case 3:
			DMSG("Got code - search vor (\n");
			switch (c) {
			case '(':
				DMSG("Found\n");
				parseCode(file, obj, propertyList);
				state = 2;
				break;
			}
			break;
		}
		
	}
	
	DMSG("Set parent and childs\n");
	obj->parent = parent;
	obj->childs = childs;
	
	DMSG("Insert into Global index\n");
	insertGlobalIndex(obj);
	
	if (obj->onInit != NULL)
		execEvent(obj->onInit, obj);
	
	DMSG("parsing finished\n");
	
	return obj;
}
JSObject* JSLazyEventListener::jsFunction() const
{
    parseCode();
    return m_jsFunction;
}