diff --git a/src/__tests__/whitespace.test.js b/src/__tests__/whitespace.test.js index d2b41a08..61f98390 100644 --- a/src/__tests__/whitespace.test.js +++ b/src/__tests__/whitespace.test.js @@ -97,10 +97,15 @@ const examples = [ ` ] +const extendedExamples = [ + ...examples, + ...examples.map((example: string): string => example.replace('//', '#')) +] + describe('whitespace tests', () => { - examples.forEach((example: string): void => + extendedExamples.forEach((example: string) => { it(`parses '${example.slice(0, 25)}'`, () => { parse(example) }) - ) + }) }) diff --git a/src/parsers/crap.js b/src/parsers/crap.js index 379fffdf..6dee37f7 100644 --- a/src/parsers/crap.js +++ b/src/parsers/crap.js @@ -3,7 +3,10 @@ import P from 'parsimmon' const NotNewline = P.regexp(/[^\n]*/) -const Comment = NotNewline.wrap(P.string('//'), P.string('\n')) +const Comment = NotNewline.wrap( + P.alt(P.string('//'), P.string('#')), + P.string('\n') +) const Whitespace = P.regexp(/[ \n]*/) export default Comment.sepBy(Whitespace).trim(Whitespace)