Beispiel #1
0
//--------------------------------------------------------------
// substitute vars into message and return
void mgErrorTable::unknownMsg(
  mgString& text,               // returned message text
  const char* msgId,
  const char* varNames,
  const char* varValues)
{
  // no error message, so format args
  text.format("Unknown error(%s)", (const char*) msgId);
  int namePosn = 0;
  int valuePosn = 0;

  mgString argName;
  mgString argValue;
  while (true)
  {
    namePosn = parseVar(argName, varNames, namePosn);
    valuePosn = parseVar(argValue, varValues, valuePosn);
    if (namePosn == -1 || valuePosn == -1)
      break;

    text += ", ";
    text += argName;
    text += "=\"";
    text += argValue;
    text += "\"";
  }
}
Beispiel #2
0
//--------------------------------------------------------------
// find value of variable
BOOL mgErrorTable::findVar(
  mgString& value,
  const char* varNames,
  const char* varValues,
  const char* name)
{
  int namePosn = 0;
  int valuePosn = 0;

  mgString argName;
  mgString argValue;
  while (true)
  {
    namePosn = parseVar(argName, varNames, namePosn);
    valuePosn = parseVar(argValue, varValues, valuePosn);
    if (namePosn == -1 || valuePosn == -1)
      return false;

    if (argName.equalsIgnoreCase(name))
    {
      value = argValue;
      return true;
    }
  }
}
void CalculateConfig::parseVariables(const QDomNode& node, MapConfig& cfg)
{
	QDomNode domNode = node.firstChild();
	while ( !domNode.isNull() )
	{
		if ( domNode.isElement() )
		{
			QDomElement domElement = domNode.toElement();
			if ( !domElement.isNull() )
			{
				if (domElement.tagName() == "var")
				{
					if (domElement.attribute("type") == "var")
					{
						parseVar(domElement, cfg);
					}
					else if (domElement.attribute("type") == "list")
					{
						parseVarList(domElement, cfg);
					}
				}
			}
		}
		domNode = domNode.nextSibling();
	}
}
VariableList_t* PythonDBGPVariableParser::parseList(const QDomNodeList& list, Variable* parent)
{
    QDomElement e;
    VariableList_t* vlist = new VariableList_t;
    PythonVariable* var;
    for(uint i = 0; i < list.count(); i++)
    {
        e = list.item(i).toElement();

        if(e.tagName() != "property")
            continue;

        var = parseVar(e, parent);
        vlist->append(var);
    }
    return vlist;
}
VariableList_t* XDVariableParser::parseList(const QDomNodeList& list, Variable* parent, bool fullname)
{
  QDomElement e;
  VariableList_t* vlist = new VariableList_t;
  Variable* var;
  uint count = list.count();
  for(uint i = 0; i < count; i++)
  {
    e = list.item(i).toElement();
    
    if(e.attributeNode("type").value() == "uninitialized")
      continue;

    var = parseVar(e, parent, fullname);
    vlist->append(var);
  }
  return vlist;
}
Beispiel #6
0
ExpPtr parseLet (Lexer& lex)
{
	Span spStart, spEnd;
	std::string name;
	TyPtr ty;
	ExpPtr init;

	// 'let' <var> '=' <exp> ';'

	spStart = lex.eat(tLet).span;
	parseVar(lex, name, ty, spEnd);
	lex.eat(tEqual);
	init = parseExp(lex);
	spEnd = init->span;

	auto e = Exp::make(eLet, ty, name, { init }, spStart + spEnd);
	return e;
}
Beispiel #7
0
/**
 * parenthesized expression or variable
 */
bool CondParser::parseLevel3() {
  // check if it is a parenthesized expression
  if (m_tokenType == DELIMITER) {
    if (m_token == "(") {
      getToken();
      int ans = parseLevel1();
      if (m_tokenType != DELIMITER || m_token != ")") {
        m_err = "Parenthesis ) missing";
        return FALSE;
      }
      getToken();
      return ans;
    }
  }

  // if not parenthesized then the expression is a variable
  return parseVar();
}
Beispiel #8
0
std::unique_ptr<ArgsAST> Parser::parseArgs() {

	std::vector<std::shared_ptr<ExprAST>> args;

	do {

		lexer->getNextToken();

		if (lexer->currentToken == ')')
			return std::make_unique<ArgsAST> (std::move(args));

		auto arg = parseVar();
		args.push_back (std::move(arg));

	} while (lexer->currentToken == ';');

	return std::make_unique<ArgsAST> (std::move(args));

}
Beispiel #9
0
static void parseVar (Lexer& lex, SigPtr sig)
{
	std::string name;
	TyPtr ty;
	Span sp;

	parseVar(lex, name, ty, sp);

	for (auto& a : sig->args)
		if (a.first == name)
		{
			std::ostringstream ss;
			ss << "variable '" << name << "' already declared in signature";
			throw sp.die(ss.str());
		}

	sig->args.push_back(Sig::Arg { name, ty });
	sig->span = sig->span + sp;
}
Beispiel #10
0
SigPtr parseSig (Lexer& lex, bool anything)
{
	auto res = std::make_shared<Sig>();
	
	// sig := (<var> (',' <var>)*)?

	for (;; anything = true)
	{
		if (anything)
			lex.expect(tIdent);
		else if (lex.current() != tIdent)
			break;

		parseVar(lex, res);

		if (lex.current() == tComma)
			lex.advance();
		else
			break;
	}

	return res;
}
PythonVariable* PythonDBGPVariableParser::parse(QDomNode& node)
{
    return parseVar(node, 0);
}
Variable* XDVariableParser::parse(QDomNode& node)
{
  return parseVar(node, 0);
}