}
} ;
-ARTICLE: "peg.ebnf.strings" "Strings"
+ARTICLE: "peg.ebnf.strings" "EBNF Rule: Strings"
"A string in a rule will match that sequence of characters from the input string. "
"The string is delimited by matching single or double quotes. "
"Factor's escape sequences are interpreted: " { $link "escape" } ". "
}
} ;
-ARTICLE: "peg.ebnf.any" "Any"
+ARTICLE: "peg.ebnf.any" "EBNF Rule: Any"
"A full stop character (.) will match any single token in the input string. "
"The AST resulting from this is the token itself."
{ $examples
}
} ;
-ARTICLE: "peg.ebnf.sequence" "Sequence"
+ARTICLE: "peg.ebnf.sequence" "EBNF Rule: Sequence"
"Any white space separated rule element is considered a sequence. Each rule "
"in the sequence is matched from the input stream, consuming the input as it "
"goes. The AST result is a vector containing the results of each rule element in "
}
;
-ARTICLE: "peg.ebnf.grouping" "Group"
+ARTICLE: "peg.ebnf.grouping" "EBNF Rule: Group"
"Any sequence of rules may be grouped using parentheses (" { $snippet "()" } "). "
"The parenthesized sequence can then be modified as a group. Parentheses also "
"delimit sets of choices separated by pipe (|) characters."
}
;
-ARTICLE: "peg.ebnf.choice" "Choice"
-"Any rule element separated by a pipe character (|) is considered a choice. Choices "
+ARTICLE: "peg.ebnf.choice" "EBNF Rule: Choice"
+"Any rule element separated by a pipe character (|) is considered a " { $strong "choice" } ". Choices "
"are matched against the input stream in order. If a match succeeds then the remaining "
"choices are discarded and the result of the match is the AST result of the choice."
{ $examples
"Peg parsing error at character position 0.\nExpected 'a' or 'b' or 'c'\nGot 'd'"
}
}
+{ $notes "Due to parser caching, rules can't re-use parsers that have already failed earlier in the choice." }
;
-ARTICLE: "peg.ebnf.ignore" "Ignore"
+ARTICLE: "peg.ebnf.ignore" "EBNF Rule: Ignore"
"Any rule element followed by a tilde (~) will be matched, and its results "
"discarded from the AST."
{ $examples
}
;
-ARTICLE: "peg.ebnf.option" "Option"
+ARTICLE: "peg.ebnf.option" "EBNF Rule: Option"
"Any rule element followed by a question mark (?) is considered optional. The "
"rule is tested against the input. If it succeeds the result is stored in the AST. "
"If it fails then the parse still succeeds and false (f) is stored in the AST."
}
;
-ARTICLE: "peg.ebnf.character-class" "Character Class"
+ARTICLE: "peg.ebnf.character-class" "EBNF Rule: Character Class"
"Character class matching can be done using a range of characters defined in "
"square brackets. Multiple ranges can be included in a single character class "
"definition. The syntax for the range is a start character, followed by a minus "
}
;
-ARTICLE: "peg.ebnf.one-or-more" "One or more"
+ARTICLE: "peg.ebnf.one-or-more" "EBNF Rule: One or more"
"Any rule element followed by a plus (+) matches one or more instances of the rule "
"from the input string. The AST result is the vector of the AST results from "
"the matched rule."
}
;
-ARTICLE: "peg.ebnf.zero-or-more" "Zero or more"
+ARTICLE: "peg.ebnf.zero-or-more" "EBNF Rule: Zero or more"
"Any rule element followed by an asterisk (*) matches zero or more instances of the rule "
"from the input string. The AST result is the vector of the AST results from "
"the matched rule. This will be empty if there are no matches."
}
;
-ARTICLE: "peg.ebnf.and" "And"
+ARTICLE: "peg.ebnf.and" "EBNF Rule: And"
"Any rule element prefixed by an ampersand (&) performs the Parsing Expression "
"Grammar 'And Predicate' match. It attempts to match the rule against the input "
"string. It will cause the parse to succeed or fail depending on if the rule "
}
;
-ARTICLE: "peg.ebnf.not" "Not"
+ARTICLE: "peg.ebnf.not" "EBNF Rule: Not"
"Any rule element prefixed by an exclamation mark (!) performs the Parsing Expression "
"Grammar 'Not Predicate' match. It attempts to match the rule against the input "
"string. It will cause the parse to succeed if the rule match fails, and to fail "
}
;
-ARTICLE: "peg.ebnf.action" "Action"
+ARTICLE: "peg.ebnf.action" "EBNF Action"
"An action is a quotation that is run after a rule matches. The quotation "
"consumes the AST of the rule match and leaves a new AST as the result. "
"The stack effect of the action can be " { $snippet "( ast -- ast )" } " or "
}
;
-ARTICLE: "peg.ebnf.semantic-action" "Semantic Action"
+ARTICLE: "peg.ebnf.semantic-action" "EBNF Semantic Action"
"Semantic actions allow providing a quotation that gets run on the AST of a "
"matched rule that returns success or failure. The result of the parse is decided by "
"the result of the semantic action. The stack effect for the quotation is "
}
;
-ARTICLE: "peg.ebnf.variable" "Variable"
+ARTICLE: "peg.ebnf.variable" "EBNF Variable"
"Variables names can be suffixed to a rule element using the colon character (:) "
"followed by the variable name. These can then be used in rule actions to refer to "
"the AST result of the rule element with that variable name."
}
;
-ARTICLE: "peg.ebnf.foreign-rules" "Foreign Rules"
-"Rules can call out to other peg.ebnf defined parsers. The result of "
+ARTICLE: "peg.ebnf.foreign-rules" "EBNF Foreign Rules"
+"Rules can call out to other " { $vocab-link "peg.ebnf" } " defined parsers. The result of "
"the foreign call then becomes the AST of the successful parse. Foreign rules "
"are invoked using '<foreign word-name>' or '<foreign word-name rule>'. The "
"latter allows calling a specific rule in a previously designed peg.ebnf parser. "
}
;
-ARTICLE: "peg.ebnf.tokenizers" "Tokenizers"
+ARTICLE: "peg.ebnf.tokenizers" "EBNF Tokenizers"
"It is possible to override the tokenizer in an EBNF defined parser. "
"Usually the input sequence to be parsed is an array of characters or a string. "
"Terminals in a rule match successive characters in the array or string. "