From 6ff005786c41f7b3cd4c2f94f047bb90ffad531a Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 4 Sep 2015 17:23:42 +0200 Subject: [PATCH] Talk about "consuming input", not "advancing parser position" It's shorter, less technical, and more understandible. --- README.md | 13 ++++++------- spec/behavior/generated-parser-behavior.spec.js | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a322fad..1a9ab74 100644 --- a/README.md +++ b/README.md @@ -304,13 +304,12 @@ backtracking. #### & *expression* Try to match the expression. If the match succeeds, just return `undefined` and -do not advance the parser position, otherwise consider the match failed. +do not consume any input, otherwise consider the match failed. #### ! *expression* Try to match the expression. If the match does not succeed, just return -`undefined` and do not advance the parser position, otherwise consider the match -failed. +`undefined` and do not consume any input, otherwise consider the match failed. #### & { *predicate* } @@ -318,8 +317,8 @@ The predicate is a piece of JavaScript code that is executed as if it was inside a function. It gets the match results of labeled expressions in preceding expression as its arguments. It should return some JavaScript value using the `return` statement. If the returned value evaluates to `true` in boolean -context, just return `undefined` and do not advance the parser position; -otherwise consider the match failed. +context, just return `undefined` and do not consume any input; otherwise +consider the match failed. The code inside the predicate can access all variables and functions defined in the initializer at the beginning of the grammar. @@ -347,8 +346,8 @@ The predicate is a piece of JavaScript code that is executed as if it was inside a function. It gets the match results of labeled expressions in preceding expression as its arguments. It should return some JavaScript value using the `return` statement. If the returned value evaluates to `false` in boolean -context, just return `undefined` and do not advance the parser position; -otherwise consider the match failed. +context, just return `undefined` and do not consume any input; otherwise +consider the match failed. The code inside the predicate can access all variables and functions defined in the initializer at the beginning of the grammar. diff --git a/spec/behavior/generated-parser-behavior.spec.js b/spec/behavior/generated-parser-behavior.spec.js index e622320..af73e1a 100644 --- a/spec/behavior/generated-parser-behavior.spec.js +++ b/spec/behavior/generated-parser-behavior.spec.js @@ -268,7 +268,7 @@ describe("generated parser behavior", function() { expect(parser).toParse("a", "a"); }); - it("advances parse position past the matched text", function() { + it("consumes the matched text", function() { var parser = PEG.buildParser('start = "a" .', options); expect(parser).toParse("ab"); @@ -341,7 +341,7 @@ describe("generated parser behavior", function() { expect(parser).toParse("a", "a"); }); - it("advances parse position past the matched character", function() { + it("consumes the matched character", function() { var parser = PEG.buildParser('start = [a] .', options); expect(parser).toParse("ab"); @@ -377,7 +377,7 @@ describe("generated parser behavior", function() { expect(parser).toParse("a", "a"); }); - it("advances parse position past the matched character", function() { + it("consumes the matched character", function() { var parser = PEG.buildParser('start = . .', options); expect(parser).toParse("ab");