All files / src/analysis/parser ObjectIdentifierValueRules.ts

100% Statements 24/24
100% Branches 0/0
100% Functions 10/10
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  1x                 1x 7x 10x     8x 8x 8x 8x         9x 9x 9x           7x 10x 23x       7x 23x     7x 22x 22x 22x 22x     7x 23x     23x            
import {ASN1CstParser} from '../ASN1CstParser';
import {
  Identifier,
  L_CURLY,
  L_PARENTHESIS,
  NumberToken,
  R_CURLY,
  R_PARENTHESIS,
} from '../ASN1Lexer';
 
export function initObjectIdentifierValueRules(this: ASN1CstParser) {
  this.RULE('ObjectIdentifierValue', () => {
    this.OR([
      {
        ALT: () => {
          this.CONSUME(L_CURLY);
          this.SUBRULE(this.DefinedValue);
          this.SUBRULE(this.ObjIdComponentsList);
          this.CONSUME(R_CURLY);
        },
      },
      {
        ALT: () => {
          this.CONSUME1(L_CURLY);
          this.SUBRULE1(this.ObjIdComponentsList);
          this.CONSUME1(R_CURLY);
        },
      },
    ]);
  });
 
  this.RULE('ObjIdComponentsList', () => {
    this.MANY(() => {
      this.SUBRULE(this.ObjIdComponents);
    });
  });
 
  this.RULE('ObjIdComponents', () => {
    this.addOrList(['NameAndNumberForm', 'NumberForm']);
  });
 
  this.RULE('NameAndNumberForm', () => {
    this.CONSUME(Identifier);
    this.CONSUME(L_PARENTHESIS);
    this.SUBRULE(this.NumberForm);
    this.CONSUME(R_PARENTHESIS);
  });
 
  this.RULE('NumberForm', () => {
    this.OR([
      {
        ALT: () => {
          this.CONSUME(NumberToken);
        },
      },
    ]);
  });
}