summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/pt/pt_pexpr_op.man
blob: 015e07138efaa6bafa125fa326fb42a9990ca861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
[vset VERSION 1.0.1]
[comment {-*- text -*- doctools manpage}]
[manpage_begin pt::pe::op n [vset VERSION]]
[include include/module.inc]
[titledesc {Parsing Expression Utilities}]
[require pt::pe::op [opt [vset VERSION]]]
[require pt::pe     [opt 1]]
[require struct::set]
[description]
[include include/ref_intro.inc]

This package provides additional commands to work with the
serializations of parsing expressions as managed by the PEG and
related packages, and specified in section
[sectref {PE serialization format}].

[para]

This is an internal package, for use by the higher level packages
handling PEGs, their conversion into and out of various other formats,
or other uses.

[section API]

[list_begin definitions]

[call [cmd ::pt::pe::op] [method drop] \
      [arg dropset] [arg pe]]

This command removes all occurences of any of the nonterminals symbols
in the set [arg dropset] from the parsing expression [arg pe], and
simplifies it. This may result in the expression becoming "epsilon",
i.e. matching nothing.

[call [cmd ::pt::pe::op] [method rename] \
      [arg nt] [arg ntnew] [arg pe]]

This command renames all occurences of the nonterminal [arg nt] in the
parsing expression [arg pe] into [arg ntnew].

[call [cmd ::pt::pe::op] [method called] [arg pe]]

This command extracts the set of all nonterminal symbols used,
i.e. 'called', in the parsing expression [arg pe].

[call [cmd ::pt::pe::op] [method flatten] [arg pe]]

This command transforms the parsing expression by eliminating
sequences nested in sequences, and choices in choices, lifting the
children of the nested expression into the parent. It further
eliminates all sequences and choices with only one child, as these are
redundant.

[para]

The resulting parsing expression is returned as the result of the
command.

[call [cmd ::pt::pe::op] [method fusechars] [arg pe]]

This command transforms the parsing expression by fusing adjacent
terminals in sequences and adjacent terminals and ranges in choices,
it (re)constructs highlevel [term strings] and
[term {character classes}].

[para]

The resulting pseudo-parsing expression is returned as the result of
the command and may contain the pseudo-operators [const str] for
character sequences, aka strings, and [const cl] for character
choices, aka character classes.

[para]

The result is called a [term {pseudo-parsing expression}] because it
is not a true parsing expression anymore, and will fail a check with
[cmd {::pt::peg verify}] if the new pseudo-operators
are present in the result, but is otherwise of sound structure for a
parsing expression.

Notably, the commands [cmd {::pt::peg bottomup}] and
[cmd {::pt::peg topdown}] will process them without
trouble.

[list_end]

[include include/serial/pexpression.inc]
[include include/feedback.inc]
[manpage_end]