Changeset 102 in default


Ignore:
Timestamp:
10/12/16 17:05:06 (8 years ago)
Author:
phdmakk
Message:

+ added checking of rule numbering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/validation/EbnfValidator.xtend

    r72 r102  
    4242        //public  static final String duplicateSubRulesDescription = "A part the of rule is a duplicate"; 
    4343        public static final String nonUniqueNameDescription = "The rule has the same Name as the Rule in Line "; 
     44        public static final String wrongNumbering = "The rule numbering is wrong in Line "; 
    4445 
    4546        // ---------------------------------------------------------------------------------------------------- 
     
    169170 
    170171        // ---------------------------------------------------------------------------------------------------- 
     172        /*Checks if the rule numbering is correct: 
     173         * 1. a ::= "foo" 
     174         * 3. b ::= "bar" 
     175         */ 
     176        @Check 
     177        def void checkRuleNumbering(Rule rule) { 
     178                val EtsiBnf bnf = rule.eContainer.eContainer as EtsiBnf; 
     179                if (EbnfAnalysisUtils.getAllRules(bnf).indexOf(rule)+1 != rule.rulenumber) { 
     180                        warning(wrongNumbering + NodeModelUtils.findActualNodeFor(rule).startLine, 
     181                                EbnfPackage$Literals::RULE__RULENUMBER) 
     182                } 
     183        } 
     184 
     185        //alternative implementation, does not work for some reason 
     186        @Check 
     187        def void checkRuleNumberingG(EtsiBnf bnf) { 
     188//              var lastNumber = 0; 
     189//              for (r : EbnfAnalysisUtils.getAllRules(bnf)) { 
     190//                      println(lastNumber + " : " + r.rulenumber) 
     191//                      if (lastNumber!=0 && r.rulenumber != lastNumber+1) { 
     192//                              warning(wrongNumbering + NodeModelUtils.findActualNodeFor(r).startLine, 
     193//                                      EbnfPackage$Literals::RULE__RULENUMBER) 
     194//                      } 
     195//                      lastNumber = r.rulenumber 
     196//              } 
     197        } 
     198 
     199 
     200        // ---------------------------------------------------------------------------------------------------- 
    171201        /*Checks if a Rule, except for the #1 is not referenced, e.g.: 
    172202         * a::= b 
Note: See TracChangeset for help on using the changeset viewer.