aboutsummaryrefslogtreecommitdiffstats
path: root/libparser.7
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-05 13:50:38 +0100
committerMattias Andrée <m@maandree.se>2026-02-23 07:52:18 +0100
commit7dd4970daafdc1992e1dba486a1477a17cb4c53e (patch)
treee56e544ec55e68872397738e0e5064b000d31eba /libparser.7
parentOptimise detection of rejection (diff)
downloadlibparser-7dd4970daafdc1992e1dba486a1477a17cb4c53e.tar.gz
libparser-7dd4970daafdc1992e1dba486a1477a17cb4c53e.tar.bz2
libparser-7dd4970daafdc1992e1dba486a1477a17cb4c53e.tar.xz
Add committed-operator
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libparser.7')
-rw-r--r--libparser.718
1 files changed, 15 insertions, 3 deletions
diff --git a/libparser.7 b/libparser.7
index 7157769..2d921a7 100644
--- a/libparser.7
+++ b/libparser.7
@@ -88,6 +88,7 @@ integer = _decimal | _hexadecimal; (* May not exceed 255. *)
_low = character | integer;
_high = character | integer;
+committed = \(dq+\(dq, _, _operand;
rejection = \(dq!\(dq, _, _operand;
concatenation = _operand, {_, \(dq,\(dq, _, _operand};
alternation = concatenation, {_, \(dq|\(dq, _, concatenation};
@@ -100,7 +101,7 @@ embedded-rule = identifier;
_literal = char-range | exception | string;
_group = optional | repeated | group | embedded-rule;
-_operand = _group | _literal | rejection;
+_operand = _group | _literal | rejection | committed;
_expression = alternation;
@@ -135,6 +136,15 @@ have no semantic meaning and are useful only to put a
alternation inside a concatenation without creating a
new rule for that.
.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.
+.PP
In character ranges, the
.B _high
and
@@ -150,12 +160,14 @@ the rules will appear in the tree-formatted result.
.PP
Left recursion is illegal (it will cause stack
overflow at runtime as the empty condition before the
-recursion is always met).
+recursion is always met). Likewise, repeated optional
+sentences are illegal; a repeated sentence must always
+consume input, otherwise it gets stuck.
.SS Right-context-sensitive grammar
libparser originally used context-free grammar, but with
introduction of the rejection rule, specifically the ability
-to reject a rejection, it became a phrase for
+to reject a rejection, it became a parser for
right-context-sensitive grammar which is a grammar that is
that can generate any context-sensitive language, it is
however weakly equivalent to context-sensitive grammar.