Exemplo n.º 1
0
// 17/04/2003, flight Barcelona-Manchester
// 03/05/2003 Manchester changed
void Inference::Data::destroy ()
{ 
  TRACER ("Inference::Data::destroy");

  ASS (this);
  ASS (_counter == 0);

  switch (rule()) 
    {
    case FORALL_AND_MINISCOPE:
    case SWAP:
      delete static_cast<Type1*>(this);
      return;

    case FORALL_OR_MINISCOPE:
      delete static_cast<ForallOrMiniscope*>(this);
      return;

    case DUMMY_QUANTIFIER_REMOVAL:
      delete static_cast<DummyQuantifierRemoval*>(this);
      return;

    case FLATTEN:
      delete static_cast<Flatten*>(this);
      return;

    default:
      ASS (false);
    }
} // Inference::Data::destroy ()
Exemplo n.º 2
0
//=========================================================
bool Parser::Statement () {
    PrintRule rule("Statement");
    return rule.Accept(
        FreeStatement() ||
        (DelimitedStatement() && Expect(TokenType::Semicolon))
    );
}
Exemplo n.º 3
0
		node operator()(token_stream *ts) {
			if( ts->end_of_input() ) {
				return node();
			}

			ts_trans tr( ts );

			std::vector<node> nodes;

			for( rule_t rule : ml_ ) {
				node n = rule(ts);

				if( n.is_null() ) {
					return node();
				}

				nodes.push_back( n );
			}

			tr.commit();


			return node(nodes, "list");

		}
Exemplo n.º 4
0
void LabelWidget::update()
{
    if (d->wraps.isEmpty())
    {
        d->updateWraps(rule().width().valuei());
    }
}
Exemplo n.º 5
0
//=========================================================
bool Parser::Goto () {
    PrintRule rule("Goto");
    if (Accept(TokenType::Goto) == false) {
        return false;
    }
    return rule.Accept(Expect(TokenType::Identifier));
}
Exemplo n.º 6
0
//=========================================================
bool Parser::Function () {
    PrintRule rule("Function");
    if (Accept(TokenType::Function) == false) {
        return false;
    }
    Expect(TokenType::Identifier);
    Expect(TokenType::OpenParentheses);

    if (Parameter()) {
        while (Accept(TokenType::Comma)) {
            if (!Parameter()) {
                throw ParsingException("Expected parameter after comma in function sig");
            }
        }
    }

    Expect(TokenType::CloseParentheses);

    SpecifiedType();

    if (!Scope()) {
        throw ParsingException("Expected scope after function");
    }

    return rule.Accept();
}
Exemplo n.º 7
0
void productionRule(){
	if(lookahead==OR){
		//printf(" %s", val);
		arraylist_add(stringArray,val);
		arraylist_add(intArray,lookahead);
		//strcpy(list[count],str); 
		match(OR);
		if(lookahead==EOLN){
			//printf(" ep");
			arraylist_add(stringArray,"Epsilon");
			arraylist_add(intArray,7);
			//strcpy(list[count],"epsilon");
		}
		rule();	productionRule();
	}
	else if(lookahead==SEMI){
		arraylist_add(finalString, stringArray);
		arraylist_add(finalInt,intArray);
		counter++;

		stringArray = arraylist_create(objEquals);
		intArray = arraylist_create(objEquals);
		return;}
	else if(lookahead==EOLN) {
		return;}
	else printf("\nPR");
}
Exemplo n.º 8
0
//------------------------------hash-------------------------------------------
uint MachNode::hash() const {
  uint no = num_opnds();
  uint sum = rule();
  for( uint i=0; i<no; i++ )
    sum += _opnds[i]->hash();
  return sum+Node::hash();
}
Exemplo n.º 9
0
Arquivo: repacks.hpp Projeto: 2php/pcl
 void copyFields(const DeviceArray<PointXYZRGBL>& src, DeviceArray<PointXYZ>& dst)
 {
     //PointXYZRGBL.x (0) -> PointXYZ.x (0)
     //PointXYZRGBL.y (1) -> PointXYZ.y (1)
     //PointXYZRGBL.z (2) -> PointXYZ.z (2)
     copyFieldsEx(src, dst, rule(cp(0, 0), cp(1, 1), cp(2, 2)));
 };
Exemplo n.º 10
0
value::Value* Agent::observation(
    const devs::ObservationEvent& event) const
{
    const std::string port = event.getPortName();

    if (port == "KnowledgeBase") {
        std::stringstream out;
        out << *this;
        return new value::String(out.str());
    } else if (port == "Activities") {
        std::stringstream out;
        out << activities();
        return new value::String(out.str());
    } else if ((port.compare(0, 9, "Activity_") == 0) and port.size() > 9) {
        std::string activity(port, 9, std::string::npos);
        const Activity& act(activities().get(activity)->second);
        std::stringstream out;
        out << act.state();
        return new value::String(out.str());
    } else if ((port.compare(0, 6, "Rules_") == 0) and port.size() > 6) {
        std::string rule(port, 6, std::string::npos);
        const Rule& ru(rules().get(rule));
        return new value::Boolean(ru.isAvailable());
    }
    return 0;
}
Exemplo n.º 11
0
int main(int argc, char *argv[])
{
  extern const char*	resstr[];
  bool	res;

  if (argc == 2)
    {
      pushStream(argv[1]);
      saveContext();
      s_ctx		oLocalCtx = {{NULL, 0}, NULL};
      /*res = rule(csv, csv);*/
      /*res = rule(ini, ini, &oLocalCtx) && readEOF();*/
//      res = rule(debug, debug, &oLocalCtx);
      printf("%d\n", getPos());
      /*res = rule(lisp, s_expression, &oLocalCtx);*/
      /*double i = 1;
      while (i < 10000000)
	{
      */
      res = rule(expression, expression, &oLocalCtx);
	  /*i = i + 1;
	}*/
      printf("[%s]\n", resstr[getPos() == (int)strlen(argv[1])]);

      /*
      popStream();
      pushStream(argv[2]);
      res = rule(debug, debug);
      printf("[%s]\n", resstr[getPos() == (int)strlen(argv[2])]);
      */
    }
  return 0;
}
Exemplo n.º 12
0
static
void
rules(T_PTR_tree entry) {
  size_t i, j, k, nbr_rules;

  if (entry) {
	/* We allocate memory for the transitions */
	nbr_rules = tree_nbrsubtrees(entry);
	sys->limits.nbr_rules = nbr_rules;
	sys->transition = (transition_t *)xmalloc(nbr_rules*sizeof(transition_t));
	for (i = 0; i < nbr_rules; i++) {
		/* We allocate memory for each gd_cmd of each transition */
		sys->transition[i].cmd_for_place = (gd_command_t *)xmalloc(nbr_var*sizeof(gd_command_t));
		/* Default, guard = 0,\infty and delta = 0 */
		for (j = 0; j < nbr_var; j++) {
			ist_assign_values_to_interval(&sys->transition[i].cmd_for_place[j].guard, 0L,  INFINITY);
			sys->transition[i].cmd_for_place[j].delta = 0L;
			/* In the case of places merged the genuine system is the abstraction of itself */
			sys->transition[i].cmd_for_place[j].places_abstracted=1;
		}
		for (k = 0; k < MAXNBTRANS; ++k){
			/* We allocate memory for each transfert */
			sys->transition[i].transfers[k].origin = (integer16 *)xmalloc(nbr_var*sizeof(integer16));
			/* We initialize the origin vector */
			for (j = 0; j < nbr_var; j++) 
				sys->transition[i].transfers[k].origin[j] = 0;
		}
	}
	for (nbrcmd = 0 ; nbrcmd < nbr_rules ; nbrcmd++) {
		rule(tree_subtree(entry,nbrcmd));
	}
  }
}
Exemplo n.º 13
0
void LabelWidget::draw()
{
    Rectanglei pos = rule().recti();
    TextCanvas buf(pos.size());
    buf.clear(d->background);

    // Use the wrapped lines to determine width and height.
    DENG2_ASSERT(!d->wraps.isEmpty());
    Vector2i labelSize(d->wraps.width(), d->wraps.height());

    // Determine position of the label based on alignment.
    Vector2i labelPos;
    if (d->align.testFlag(AlignRight))
    {
        labelPos.x = buf.width() - labelSize.x;
    }
    else if (!d->align.testFlag(AlignLeft))
    {
        labelPos.x = buf.width()/2 - labelSize.x/2;
    }
    if (d->align.testFlag(AlignBottom))
    {
        labelPos.y = buf.height() - labelSize.y;
    }
    else if (!d->align.testFlag(AlignTop))
    {
        labelPos.y = buf.height()/2 - labelSize.y/2;
    }

    buf.drawWrappedText(labelPos, d->label, d->wraps, d->attribs, d->align);

    targetCanvas().draw(buf, pos.topLeft);
}
Exemplo n.º 14
0
void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
{
  int index = ruleString.lastIndexOf(QLatin1String(" ("));

  const QString subscriptionName = ruleString.left(index);
  const QString filter = ruleString.mid(index + 2, ruleString.size() - index - 3);
  AdBlockSubscription* subscription = AdBlockManager::instance()->subscriptionByName(subscriptionName);
  if (filter.isEmpty() || !subscription) {
    return;
  }

  AdBlockRule rule(filter, subscription);

  QPair<AdBlockRule, QUrl> pair;
  pair.first = rule;
  pair.second = url;
  m_blockedPopups.append(pair);

  //!** FIXME
  //    mApp->desktopNotifications()->showNotification(QPixmap(":images/images/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."));

  if (!m_flashTimer) {
    m_flashTimer = new QTimer(this);
  }

  if (m_flashTimer->isActive()) {
    stopAnimation();
  }

  m_flashTimer->setInterval(500);
  m_flashTimer->start();

  connect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
}
Exemplo n.º 15
0
//=========================================================
bool Parser::Label () {
    PrintRule rule("Label");
    if (Accept(TokenType::Label) == false) {
        return false;
    }
    return rule.Accept(Expect(TokenType::Identifier));
}
Exemplo n.º 16
0
int Match(Player p,FONT *font3)
{
    BITMAP *end_=0;
    FILE *fp=fopen("ending.txt", "r");
    if(fp==0)
    {
        printf("The file didn't open.\n");
        return 0;
    }
    while(!feof(fp))
    {
        int de=0;
        char ch=' ',com=' ',rules[30]=" ",attribute[18]="",condition[18]="";
        fscanf(fp,"%s",rules);
        if(feof(fp))break;
        while(ch!='\n')
        {
            if(feof(fp))break;
            if(ch=='(' && de==0)
            {
                if(feof(fp))break;
                fscanf(fp,"%s %c %s",attribute,&com,condition);
                condition[strlen(condition)-1]='\0';
                if(Rematch(p,attribute,com,condition)==0)
                {
                    de=1;
                }
            }
            fscanf(fp,"%c",&ch);
        }
        if(de==0)
        {
            rule(&end_,rules);
            textprintf_ex(screen, font3, 50, 25,makecol(0,0,0), makecol(255,255,255),"You become a %s",rules);
            rest(10000);
            Write_Story(rules,p.name);
            destroy_bitmap(end_);
            return 1;
        }
    }
    rule(&end_,"nobody");
    textprintf_ex(screen, font3, 50, 25,makecol(0,0,0), makecol(255,255,255),"You become nobody");
    Write_Story("nobody",p.name);
    rest(10000);
    return 1;
}
Exemplo n.º 17
0
 void copyFields(const DeviceArray<Normal>& src, DeviceArray<PointNormal>& dst)
 {
     //PointXYZ.normal_x (0)  -> PointNormal.normal_x (4)
     //PointXYZ.normal_y (1)  -> PointNormal.normal_y (5)
     //PointXYZ.normal_z (2)  -> PointNormal.normal_z (6)
     //PointXYZ.curvature (4) -> PointNormal.curvature (8)
     copyFieldsEx(src, dst, rule(cp(0, 4), cp(1, 5), cp(2, 6), cp(4,8)));
 };
Exemplo n.º 18
0
//=========================================================
bool Parser::Return () {
    PrintRule rule("Return");
    if (Accept(TokenType::Return) == false) {
        return false;
    }
    Expression();
    return rule.Accept();
}
Exemplo n.º 19
0
int main() {
	while(1) {
		system("cls");
		MAP();
		rule();
	}
	return 0;
}
Exemplo n.º 20
0
//=========================================================
bool Parser::Value () {
    PrintRule rule("Value");
    return rule.Accept(
        Literal()       ||
        NameReference() ||
        GroupedExpression()
    );
}
Exemplo n.º 21
0
void LabelWidget::setExpandsToFitLines(bool expand)
{
    d->vertExpand = expand;
    if(expand)
    {
        rule().setInput(Rule::Height, *d->height);
    }
    redraw();
}
Exemplo n.º 22
0
void RuleNode::removeOldInputArtifact(Artifact *artifact)
{
    if (m_oldInputArtifacts.remove(artifact)) {
        qCDebug(lcBuildGraph) << "remove old input" << artifact->filePath()
                              << "from rule" << rule()->toString();
        m_oldInputArtifacts.insert(nullptr);
    }
    if (m_oldExplicitlyDependsOn.remove(artifact)) {
        qCDebug(lcBuildGraph) << "remove old explicitlyDependsOn" << artifact->filePath()
                              << "from rule" << rule()->toString();
        m_oldExplicitlyDependsOn.insert(nullptr);
    }
    if (m_oldAuxiliaryInputs.remove(artifact)) {
        qCDebug(lcBuildGraph) << "remove old auxiliaryInput" << artifact->filePath()
                              << "from rule" << rule()->toString();
        m_oldAuxiliaryInputs.insert(nullptr);
    }
}
Exemplo n.º 23
0
//=========================================================
bool Parser::Block () {
    PrintRule rule("Block");
    while (
        Class() ||
        Function() ||
        (Var() && Expect(TokenType::Semicolon))
    );
    return rule.Accept();
}
Exemplo n.º 24
0
//=========================================================
bool Parser::Scope () {
    PrintRule rule("Scope");
    if (Accept(TokenType::OpenCurley) == false) {
        return false;
    }
    while (Statement());

    return rule.Accept(Expect(TokenType::CloseCurley));
}
Exemplo n.º 25
0
rule_list()
#endif
{
	zzRULE;
	zzBLOCK(zztasp1);
	zzMake0;
	{
	if ( (setwd1[LA(1)]&0x8) ) {
		rule();
		zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;  
		{
			zzBLOCK(zztasp2);
			zzMake0;
			{
			while ( (setwd1[LA(1)]&0x10) ) {
				rule();
				{nfa_node *t1;
					t1 = new_nfa_node();
					(t1)->trans[0]=zzaRet.l;
					(t1)->trans[1]=zzaArg(zztasp2,1 ).l;
					/* all accept nodes "dead ends" */
					zzaRet.l=t1; zzaRet.r=NULL;
				}
				zzLOOP(zztasp2);
			}
			zzEXIT(zztasp2);
			}
		}
	}
	else {
		if ( (setwd1[LA(1)]&0x20) ) {
			zzaRet.l = new_nfa_node(); zzaRet.r = NULL;
			warning("no regular expressions", zzline);
		}
		else {zzFAIL(1,zzerr2,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
	}
	zzEXIT(zztasp1);
	return;
fail:
	zzEXIT(zztasp1);
	zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
	zzresynch(setwd1, 0x40);
	}
}
Exemplo n.º 26
0
    Impl(Public *i)
        : Base(i)
        , inverted(false)
    {
        self().add(aux = new ButtonWidget);
        aux->setFont("small");
        aux->setTextColor("text");
        aux->setSizePolicy(ui::Expand, ui::Fixed);
        Rule const &unit = rule(RuleBank::UNIT);
        aux->rule()
                .setInput(Rule::Right,  self().rule().right()  - unit)
                .setInput(Rule::Top,    self().rule().top()    + unit)
                .setInput(Rule::Bottom, self().rule().bottom() - unit);

        aux->audienceForStateChange() += this;

        self().margins().set("dialog.gap").setLeft("gap");
        self().margins().setRight(aux->rule().width() + rule("gap"));
    }
Exemplo n.º 27
0
//-----------------------------cmp---------------------------------------------
uint MachNode::cmp( const Node &node ) const {
  MachNode& n = *((Node&)node).as_Mach();
  uint no = num_opnds();
  if( no != n.num_opnds() ) return 0;
  if( rule() != n.rule() ) return 0;
  for( uint i=0; i<no; i++ )    // All operands must match
    if( !_opnds[i]->cmp( *n._opnds[i] ) )
      return 0;                 // mis-matched operands
  return 1;                     // match
}
Exemplo n.º 28
0
//=========================================================
bool Parser::GroupedExpression () {
    PrintRule rule("GroupedExpression");
    if (Accept(TokenType::OpenParentheses) == false) {
        return false;
    }

    Expression();

    return rule.Accept(Expect(TokenType::CloseParentheses));
}
Exemplo n.º 29
0
//=========================================================
bool Parser::Index () {
    PrintRule rule("Index");
    if (Accept(TokenType::OpenBracket) == false) {
        return false;
    }
    if (!Expression()) {
        throw ParsingException("Expected expression in Indexing");
    }
    return rule.Accept(Expect(TokenType::CloseBracket));
}
Exemplo n.º 30
0
//=========================================================
bool Parser::Cast () {
    PrintRule rule("Cast");
    if (Accept(TokenType::As) == false) {
        return false;
    }
    if (!Type()) {
        throw ParsingException("Expected Type in Cast");
    }
    return rule.Accept();
}