index.js 478 B

123456789101112131415161718
  1. import {nextToken, skipLineComment} from "../tokenizer/index";
  2. import {charCodes} from "../util/charcodes";
  3. import {input, state} from "./base";
  4. import {parseTopLevel} from "./statement";
  5. export function parseFile() {
  6. // If enabled, skip leading hashbang line.
  7. if (
  8. state.pos === 0 &&
  9. input.charCodeAt(0) === charCodes.numberSign &&
  10. input.charCodeAt(1) === charCodes.exclamationMark
  11. ) {
  12. skipLineComment(2);
  13. }
  14. nextToken();
  15. return parseTopLevel();
  16. }