~verifypn-cpn/verifypn/col_weight_fix

« back to all changes in this revision

Viewing changes to PetriParse/PNMLParser.cpp

  • Committer: Peter G. Jensen
  • Date: 2018-05-12 15:14:12 UTC
  • mto: (204.2.1 verifypn)
  • mto: This revision was merged to the branch mainline in revision 205.
  • Revision ID: peter.gjoel@gmail.com-20180512151412-o0nrg0201xq5n31r
fixed usage of error-codes, changes from cout to cerr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    rapidxml::xml_node<>* root = doc.first_node();
57
57
    if(strcmp(root->name(), "pnml") != 0)
58
58
    {
59
 
        std::cout << "expecting <pnml> tag as root-node in xml tree." << std::endl;
 
59
        std::cerr << "expecting <pnml> tag as root-node in xml tree." << std::endl;
60
60
        exit(ErrorCode);
61
61
    }
62
62
    
362
362
        } else if (strcmp(it->name(),"inhibitorArc") == 0) {
363
363
            parseArc(it, true);
364
364
        } else if (strcmp(it->name(), "variable") == 0) {
365
 
            std::cout << "variable not supported" << std::endl;
366
 
            exit(-1);
 
365
            std::cerr << "variable not supported" << std::endl;
 
366
            exit(ErrorCode);
367
367
        } else if (strcmp(it->name(),"queries") == 0) {
368
368
            parseQueries(it);
369
369
        } else if (strcmp(it->name(), "k-bound") == 0) {
370
 
            std::cout << "k-bound should be given as command line option -k" << std::endl;
371
 
            exit(-1);
 
370
            std::cerr << "k-bound should be given as command line option -k" << std::endl;
 
371
            exit(ErrorCode);
372
372
        } else if (strcmp(it->name(),"query") == 0) {
373
 
            std::cout << "query tag not supported, please use PQL or XML-style queries instead" << std::endl;
374
 
            exit(-1);            
 
373
            std::cerr << "query tag not supported, please use PQL or XML-style queries instead" << std::endl;
 
374
            exit(ErrorCode);            
375
375
        }
376
376
        else
377
377
        {
453
453
    auto type = element->first_attribute("type");
454
454
    if(type && strcmp(type->value(), "timed") == 0)
455
455
    {
456
 
        std::cout << "timed arcs are not supported" << std::endl;
457
 
        exit(-1);
 
456
        std::cerr << "timed arcs are not supported" << std::endl;
 
457
        exit(ErrorCode);
458
458
    }
459
459
    else if(type && strcmp(type->value(), "inhibitor") == 0)
460
460
    {
469
469
        if(std::find_if(text.begin(), text.end(), [](char c) { return !std::isdigit(c) && !std::isblank(c); }) != text.end())
470
470
        {
471
471
            if(weight == 0) weight = 1;
472
 
            std::cerr << "WARNING: Found non-integer-text in inscription-tag (weight) on arc from " << source << " to " << target << " with value \"" << text << "\". An integer was expected. Using " << weight << " as weight." << std::endl;
 
472
            std::cerr << "ERROR: Found non-integer-text in inscription-tag (weight) on arc from " << source << " to " << target << " with value \"" << text << "\". An integer was expected." << std::endl;
 
473
            exit(ErrorCode);
473
474
        }
474
475
        assert(weight > 0);
475
476
        if(!first)
476
477
        {
477
 
            std::cerr << "WARNING: Multiple inscription tags in xml of a arc from " << source << " to " << target << ". Using last found value" << std::endl;
 
478
            std::cerr << "ERROR: Multiple inscription tags in xml of a arc from " << source << " to " << target << "." << std::endl;
 
479
            exit(ErrorCode);
478
480
        }
479
481
        first = false;
480
482
    }
485
487
        expr = parseArcExpression(it->first_node("structure"));
486
488
        if(!first)
487
489
        {
488
 
            std::cerr << "WARNING: Multiple hlinscription tags in xml of a arc from " << source << " to " << target << ". Using last found value" << std::endl;
 
490
            std::cerr << "ERROR: Multiple hlinscription tags in xml of a arc from " << source << " to " << target << "." << std::endl;
 
491
            exit(ErrorCode);            
489
492
        }
490
493
        first = false;
491
494
    }
500
503
    assert(weight > 0);
501
504
    
502
505
    if (inhibitor && isColored) {
503
 
        std::cout << "inhibitor arcs are not supported in colored Petri nets" << std::endl;
504
 
        exit(-1);
 
506
        std::cerr << "inhibitor arcs are not supported in colored Petri nets" << std::endl;
 
507
        exit(ErrorCode);
505
508
    }
506
509
    
507
510
    if(weight != 0)
517
520
    }
518
521
    else
519
522
    {
520
 
        std::cerr << "WARNING: Ignoring arc from " << source << " to " << target << " with weight 0." << std::endl;            
 
523
        std::cerr << "ERROR: Arc from " << source << " to " << target << " has non-sensible weight 0." << std::endl;         
 
524
        exit(ErrorCode);
521
525
    }
522
526
}
523
527
 
561
565
        } else if (strcmp(it->name(), "condition") == 0) {
562
566
            t.expr = parseGuardExpression(it->first_node("structure"));
563
567
        } else if (strcmp(it->name(), "conditions") == 0) {
564
 
            std::cout << "conditions not supported" << std::endl;
565
 
            exit(-1);
 
568
            std::cerr << "conditions not supported" << std::endl;
 
569
            exit(ErrorCode);
566
570
        } else if (strcmp(it->name(), "assignments") == 0) {
567
 
            std::cout << "assignments not supported" << std::endl;
568
 
            exit(-1);
 
571
            std::cerr << "assignments not supported" << std::endl;
 
572
            exit(ErrorCode);
569
573
        }
570
574
    }
571
575
    //Add transition to list