All files / src/analysis/parser ImportsRules.ts

100% Statements 30/30
100% Branches 0/0
100% Functions 14/14
100% Lines 30/30

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 61  1x 1x   1x 7x 13x 8x 8x 8x       7x 8x 8x       7x 8x 8x       7x 8x 8x 8x     7x 8x     9x         7x 9x         7x 9x     7x   8x 8x     7x 8x      
import {ASN1CstParser} from '../ASN1CstParser';
import {COMMA, Identifier, SEMI_COLUMN, TypeReference} from '../ASN1Lexer';
import {k} from '../lexer/ASN1Keyword';
 
export function initImportsRules(this: ASN1CstParser) {
  this.RULE('Imports', () => {
    this.OPTION(() => {
      this.CONSUME(k.IMPORTS);
      this.SUBRULE(this.SymbolsImported);
      this.CONSUME(SEMI_COLUMN);
    });
  });
 
  this.RULE('SymbolsImported', () => {
    this.OPTION(() => {
      this.SUBRULE(this.SymbolsFromModuleList);
    });
  });
 
  this.RULE('SymbolsFromModuleList', () => {
    this.MANY(() => {
      this.SUBRULE(this.SymbolsFromModule);
    });
  });
 
  this.RULE('SymbolsFromModule', () => {
    this.SUBRULE(this.SymbolList);
    this.CONSUME(k.FROM);
    this.SUBRULE(this.GlobalModuleReference);
  });
 
  this.RULE('SymbolList', () => {
    this.MANY_SEP({
      SEP: COMMA,
      DEF: () => {
        this.SUBRULE(this.Symbol);
      },
    });
  });
 
  this.RULE('Symbol', () => {
    this.addOrList([
      'Reference',
      // 'ParameterizedReference'
    ]);
  });
  this.RULE('Reference', () => {
    this.addOrTokenList([TypeReference, Identifier]);
  });
 
  this.RULE('GlobalModuleReference', () => {
    // module reference
    this.CONSUME(TypeReference);
    this.SUBRULE(this.AssignedIdentifier);
  });
 
  this.RULE('AssignedIdentifier', () => {
    this.addOrList(['ObjectIdentifierValue', 'DefinedValue']);
  });
}