function findOccurrences(source, grammars, with_string=false) {
  if (!(source instanceof SourceFile)) {
    throw new ArgumentError('source');
  }
  if (!(grammars instanceof GrammarRegistry)) {
    throw new ArgumentError('grammar');
  }

  const occurrences = [];
  for (const string of source.strings()) {
    const entry = [];
    for (const grammar of grammars.findAllMatchingGrammars(string)) {
      entry.push(grammar);
    }

    occurrences.push(with_string ? { string, grammars: entry } : entry);
  }

  return occurrences;
}
/**
 * For every string in the file, finds every grammar that matches it.
 * Returns the array of occurrences per string, ordered by its position in the
 * file.
 */
For every string in the file, finds every grammar that matches it.
Returns the array of occurrences per string, ordered by its position in the
file.
For every string in the file finds every grammar that matches it . Returns the array of occurrences per string ordered by its position in the file .
function findOccurrences(source, grammars, with_string=false) {
  if (!(source instanceof SourceFile)) {
    throw new ArgumentError('source');
  }
  if (!(grammars instanceof GrammarRegistry)) {
    throw new ArgumentError('grammar');
  }
  const occurrences = [];
  for (const string of source.strings()) {
    const entry = [];
    for (const grammar of grammars.findAllMatchingGrammars(string)) {
      entry.push(grammar);
    }
    occurrences.push(with_string ? { string, grammars: entry } : entry);
  }
  return occurrences;
}
function findOccurrences ( source , grammars , with_string = false ) { if ( ! ( source instanceof SourceFile ) ) { throw new ArgumentError ( 'source' ) ; } if ( ! ( grammars instanceof GrammarRegistry ) ) { throw new ArgumentError ( 'grammar' ) ; } const occurrences = [ ] ; for ( const string of source . strings ( ) ) { const entry = [ ] ; for ( const grammar of grammars . findAllMatchingGrammars ( string ) ) { entry . push ( grammar ) ; } occurrences . push ( with_string ? { string , grammars : entry } : entry ) ; } return occurrences ; }
For every string in the file, finds every grammar that matches it.
For every string in the file finds every grammar that matches it .