Exemplo n.º 1
0
int   PG::Main (int na, char** arg)
{
      if (Start (na, arg))
		{
			PGParser::initialize (optn[MAX_SYM]);
			if (PGParser::parse (input_start) > 0)
			{
				PrintGrammar();
				PrintHtml();
				if (CheckGrammar())
				{
					OutputLexicalSymbols();
					if (BuildLR1())  
					{
						if (ComputeLA())
						{
							if (OptimizeStates())
							{
								PrintStates();
								CreateTables();
								PG::Terminate (0);
								return 1;
							} 
						}
			      }
				}
			}
		}
		return 0;
}
Exemplo n.º 2
0
int   LG::Main (int na, char** arg) /* Display program information. */
{
		if (Start (na, arg)) 
		{
			if (Parse())
			{
				if (CheckGrammar())
				{
					if (BuildStates())
					{
						int rc;
						rc  = AddExtra();
						rc += ComputeLA();
						PrintStates (1);
						if (rc == 2)
						{
							if (OptimizeStates())
							{
								PrintStates (2);
								if (!optn[LG_ANALYZEONLY])
								{
									CreateTables();
									LG::Terminate (1);
									return 1;
								}
							}
						}
					}
				}
			}
		}
		LG::Terminate (0);
		return 0;
}
Exemplo n.º 3
0
expressor::expressor(QString _ex, QString _param): ex(_ex), param(_param)
{
    unFunc = new  QMap <QString, double (*)(double)>();
    unFunc->insert("cos", qCos);
    unFunc->insert("sin", qSin);
    unFunc->insert("tan", qTan);

    unFunc->insert("acos", qAcos);
    unFunc->insert("asin", qAsin);
    unFunc->insert("atan", qAtan);

    unFunc->insert("ln"  , qLn);
    unFunc->insert("sqrt", qSqrt);
    unFunc->insert("exp" , qExp);
    unFunc->insert("abs",  abs);

    CheckGrammar();
  //  QString str = "x11+x3-y6*yy5/cos(H6777-54 - 44.33)";
    str.replace(QRegExp("(([a-z]|[A-Z]){1,1}\\d+)|(\\d+)|(\\d*\\.\\d+)"),QString("@"));
  //  qDebug() << str;
}