From e7d03825e0624667571ee91945ce981e23f98659 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 18 Jun 2016 04:52:49 +0200 Subject: [PATCH] AST: Remove the "rawText" property from "class" nodes It isn't used anymore. --- lib/parser.js | 1 - spec/unit/parser.spec.js | 42 ++++++++++++++-------------------------- src/parser.pegjs | 1 - 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/lib/parser.js b/lib/parser.js index 4df5ac2..74d745e 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -341,7 +341,6 @@ parts: filterEmptyStrings(parts), inverted: inverted !== null, ignoreCase: ignoreCase !== null, - rawText: text(), location: location() }; }, diff --git a/spec/unit/parser.spec.js b/spec/unit/parser.spec.js index 2871cf2..d40a9c3 100644 --- a/spec/unit/parser.spec.js +++ b/spec/unit/parser.spec.js @@ -79,13 +79,12 @@ describe("PEG.js grammar parser", function() { ); } - function classGrammar(parts, inverted, ignoreCase, rawText) { + function classGrammar(parts, inverted, ignoreCase) { return oneRuleGrammar({ type: "class", parts: parts, inverted: inverted, - ignoreCase: ignoreCase, - rawText: rawText + ignoreCase: ignoreCase }); } @@ -360,7 +359,7 @@ describe("PEG.js grammar parser", function() { /* Canonical PrimaryExpression is "\"abcd\"". */ it("parses PrimaryExpression", function() { expect('start = "abcd"' ).toParseAs(trivialGrammar); - expect('start = [a-d]' ).toParseAs(classGrammar([["a", "d"]], false, false, '[a-d]')); + expect('start = [a-d]' ).toParseAs(classGrammar([["a", "d"]], false, false)); expect('start = .' ).toParseAs(anyGrammar()); expect('start = a' ).toParseAs(ruleRefGrammar("a")); expect('start = &{ code }').toParseAs(oneRuleGrammar(semanticAnd)); @@ -527,43 +526,38 @@ describe("PEG.js grammar parser", function() { /* Canonical CharacterClassMatcher is "[a-d]". */ it("parses CharacterClassMatcher", function() { expect('start = []').toParseAs( - classGrammar([], false, false, '[]') + classGrammar([], false, false) ); expect('start = [a-d]').toParseAs( - classGrammar([["a", "d"]], false, false, '[a-d]') + classGrammar([["a", "d"]], false, false) ); expect('start = [a]').toParseAs( - classGrammar(["a"], false, false, '[a]') + classGrammar(["a"], false, false) ); expect('start = [a-de-hi-l]').toParseAs( classGrammar( [["a", "d"], ["e", "h"], ["i", "l"]], false, - false, - '[a-de-hi-l]' + false ) ); expect('start = [^a-d]').toParseAs( - classGrammar([["a", "d"]], true, false, '[^a-d]') + classGrammar([["a", "d"]], true, false) ); expect('start = [a-d]i').toParseAs( - classGrammar([["a", "d"]], false, true, '[a-d]i') + classGrammar([["a", "d"]], false, true) ); expect('start = [\\\n]').toParseAs( - classGrammar([], false, false, '[\\\n]') + classGrammar([], false, false) ); }); /* Canonical ClassCharacterRange is "a-d". */ it("parses ClassCharacterRange", function() { - expect('start = [a-d]').toParseAs( - classGrammar([["a", "d"]], false, false, '[a-d]') - ); + expect('start = [a-d]').toParseAs(classGrammar([["a", "d"]], false, false)); - expect('start = [a-a]').toParseAs( - classGrammar([["a", "a"]], false, false, '[a-a]') - ); + expect('start = [a-a]').toParseAs(classGrammar([["a", "a"]], false, false)); expect('start = [b-a]').toFailToParse({ message: "Invalid character range: b-a." }); @@ -571,15 +565,9 @@ describe("PEG.js grammar parser", function() { /* Canonical ClassCharacter is "a". */ it("parses ClassCharacter", function() { - expect('start = [a]' ).toParseAs( - classGrammar(["a"], false, false, '[a]') - ); - expect('start = [\\n]' ).toParseAs( - classGrammar(["\n"], false, false, '[\\n]') - ); - expect('start = [\\\n]').toParseAs( - classGrammar([], false, false, '[\\\n]') - ); + expect('start = [a]' ).toParseAs(classGrammar(["a"], false, false)); + expect('start = [\\n]' ).toParseAs(classGrammar(["\n"], false, false)); + expect('start = [\\\n]').toParseAs(classGrammar([], false, false)); expect('start = []]' ).toFailToParse(); expect('start = [\\]').toFailToParse(); diff --git a/src/parser.pegjs b/src/parser.pegjs index 7393444..346dcf5 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -385,7 +385,6 @@ CharacterClassMatcher "character class" parts: filterEmptyStrings(parts), inverted: inverted !== null, ignoreCase: ignoreCase !== null, - rawText: text(), location: location() }; }