Skip to content

Commit

Permalink
use code-red's parsing functions to preserve comments in AST (sveltej…
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Jan 21, 2020
1 parent 726567d commit 604867a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/compiler/parse/acorn.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as acorn from 'acorn';
import { Node } from 'acorn';
import * as code_red from 'code-red';

const Parser = acorn.Parser;

export const parse = (source: string) => Parser.parse(source, {
export const parse = (source: string): Node => code_red.parse(source, {
sourceType: 'module',
ecmaVersion: 11,
locations: true
});

export const parse_expression_at = (source: string, index: number) => Parser.parseExpressionAt(source, index, {
export const parse_expression_at = (source: string, index: number): Node => code_red.parseExpressionAt(source, index, {
ecmaVersion: 11,
locations: true
});

0 comments on commit 604867a

Please sign in to comment.