From 208594ca9f95a87f60ff052490a4d5824dc23801 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 5 Jan 2026 14:35:26 +0100 Subject: Make deterministic the default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libparser.7 | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'libparser.7') diff --git a/libparser.7 b/libparser.7 index 2d921a7..c50b5c9 100644 --- a/libparser.7 +++ b/libparser.7 @@ -88,12 +88,14 @@ integer = _decimal | _hexadecimal; (* May not exceed 255. *) _low = character | integer; _high = character | integer; +nondeterministic = \(dq?\(dq; + committed = \(dq+\(dq, _, _operand; rejection = \(dq!\(dq, _, _operand; concatenation = _operand, {_, \(dq,\(dq, _, _operand}; -alternation = concatenation, {_, \(dq|\(dq, _, concatenation}; -optional = \(dq[\(dq, _, _expression, _, \(dq]\(dq; -repeated = \(dq{\(dq, _, _expression, _, \(dq}\(dq; +alternation = concatenation, {_, [nondeterministic], \(dq|\(dq, _, concatenation}; +optional = [nondeterministic], \(dq[\(dq, _, _expression, _, \(dq]\(dq; +repeated = [nondeterministic], \(dq{\(dq, _, _expression, _, \(dq}\(dq; group = \(dq(\(dq, _, _expression, _, \(dq)\(dq; char-range = \(dq<\(dq, _, _low, _, \(dq,\(dq, _, _high, \(dq_\(dq, \(dq>\(dq; exception = \(dq-\(dq; @@ -132,18 +134,18 @@ Optional symbols are taken whenever possible. Concatenation has higher precedence than alternation, groups .RB (\(dq ( "\(dq, ..., \(dq" ) \(dq) -have no semantic meaning and are useful only to put a -alternation inside a concatenation without creating a -new rule for that. +have no semantic meaning and are useful only for including +alternations inside concatenations or put alternations +or concatenations inside a commitment or rejection. .PP -The parser is non-deterministic, which can make it really -slow. The speed up parsing, you can add commits. Once the -committed sentence has been matched, the branching-points -inside it are unrecorded, so when the parser backtracks, -it will not try different choices inside the committed -sentence. Commit sentences are undone by the parser when -it backtracks to a branching-point outside the committed -sentence. +The parser has the ability to be non-deterministic, which +can make it really slow. The speed up parsing, you can add +commits. Once the committed sentence has been matched, +the branching-points inside it are unrecorded, so when +the parser backtracks, it will not try different choices +inside the committed sentence. Commit sentences are undone +by the parser when it backtracks to a branching-point +outside the committed sentence. .PP In character ranges, the .B _high -- cgit v1.2.3-70-g09d2