All files / src/analysis/parser ModuleIdentifierRules.ts

100% Statements 24/24
100% Branches 0/0
100% Functions 11/11
100% Lines 24/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60    1x                   1x   7x 13x 13x     7x 13x     10x                 7x 10x 10x 10x     7x 10x 30x       7x 30x     7x 10x     7x 27x 27x 27x 27x      
import {ASN1CstParser} from '../ASN1CstParser';
 
import {
  Identifier,
  TypeReference,
  L_CURLY,
  R_CURLY,
  R_PARENTHESIS,
  L_PARENTHESIS,
  NumberToken,
} from '../ASN1Lexer';
 
export function initModuleIdentifierRules(this: ASN1CstParser) {
  // Clause 13.1
  this.RULE('ModuleIdentifier', () => {
    this.CONSUME(TypeReference);
    this.SUBRULE(this.DefinitiveIdentification);
  });
 
  this.RULE('DefinitiveIdentification', () => {
    this.OR([
      {
        ALT: () => {
          this.SUBRULE(this.DefinitiveOID);
        },
      },
      {
        ALT: () => {},
      },
    ]);
  });
 
  this.RULE('DefinitiveOID', () => {
    this.CONSUME(L_CURLY);
    this.SUBRULE(this.DefinitiveObjIdComponentList);
    this.CONSUME(R_CURLY);
  });
 
  this.RULE('DefinitiveObjIdComponentList', () => {
    this.MANY(() => {
      this.SUBRULE(this.DefinitiveObjIdComponent);
    });
  });
 
  this.RULE('DefinitiveObjIdComponent', () => {
    this.addOrList(['DefinitiveNumberForm', 'DefinitiveNameAndNumberForm']);
  });
 
  this.RULE('DefinitiveNumberForm', () => {
    this.CONSUME(NumberToken);
  });
 
  this.RULE('DefinitiveNameAndNumberForm', () => {
    this.CONSUME(Identifier);
    this.CONSUME(L_PARENTHESIS);
    this.CONSUME(NumberToken);
    this.CONSUME(R_PARENTHESIS);
  });
}