parseSource method

ASTSource parseSource(
  1. HTSource source, {
  2. bool printPerformanceStatistics = false,
})

Convert string content into ASTSource by a certain grammar rules set.

Implementation

ASTSource parseSource(HTSource source,
    {bool printPerformanceStatistics = false}) {
  final tik = DateTime.now().millisecondsSinceEpoch;
  currrentFileName = source.fullName;
  resetFlags();
  currentModuleImports = <ImportExportDecl>[];
  final tokens = lexer.lex(source.content);
  final nodes = parseTokens(tokens, source: source);
  final result = ASTSource(
      nodes: nodes,
      source: source,
      imports: currentModuleImports,
      errors: errors); // copy the list);
  final tok = DateTime.now().millisecondsSinceEpoch;
  if (printPerformanceStatistics) {
    print('hetu: ${tok - tik}ms\tto parse\t[${source.fullName}]');
  }
  return result;
}