1page_util_peg(n)            Parser generator tools            page_util_peg(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       page_util_peg - page PEG transformation utilities
9

SYNOPSIS

11       package require page::util::peg  ?0.1?
12
13       package require snit
14
15       ::page::util::peg::symbolNodeOf tree node
16
17       ::page::util::peg::symbolOf tree node
18
19       ::page::util::peg::updateUndefinedDueRemoval tree
20
21       ::page::util::peg::flatten treequery tree
22
23       ::page::util::peg::getWarnings tree
24
25       ::page::util::peg::printWarnings msg
26
27       ::page::util::peg::peOf tree eroot
28
29       ::page::util::peg::printTclExpr pe
30
31______________________________________________________________________________
32

DESCRIPTION

34       This  package  provides a few common operations to PEG transformations.
35       They assume a Normalized PE Grammar Tree  as  input,  see  the  package
36       page::util::norm::peg,  possibly  augmented with attributes coming from
37       transformations not in conflict with the base definition.
38

API

40       ::page::util::peg::symbolNodeOf tree node
41              Given an arbitrary expression node in the AST tree it determines
42              the node (itself or an ancestor) containing the name of the non‐
43              terminal symbol the node belongs to, and  returns  its  id.  The
44              result  is  either  the  root of the tree (for the start expres‐
45              sion), or a definition node.
46
47       ::page::util::peg::symbolOf tree node
48              As ::page::util::peg::symbolNodeOf, but returns the symbol  name
49              instead of the node.
50
51       ::page::util::peg::updateUndefinedDueRemoval tree
52              The  removal  of nodes in the AST tree can cause symbols to lose
53              one or more users.
54
55
56                A used by B and C,
57                B is reachable,
58                C is not,
59
60                so A now loses the node in the expression for C calling it,
61                or rather, not calling it anymore.
62
63
64              This command updates the cross-references and which nonterminals
65              are now undefined.
66
67       ::page::util::peg::flatten treequery tree
68              This  commands  flattens nested sequence and choice operators in
69              the AST tree, re-using the treeql object treequery  to  run  the
70              query determining which nodes to cut.
71
72       ::page::util::peg::getWarnings tree
73              This  command  looks at the attributes of the AST tree for prob‐
74              lems with the grammar and issues warnings. They do  not  prevent
75              us  from  writing the grammar, but still represent problems with
76              it the user should be made aware of.
77
78              The result of the command is a  dictionary  mapping  nonterminal
79              names to their associated warnings.
80
81       ::page::util::peg::printWarnings msg
82              The  argument of the command is a dictionary mapping nonterminal
83              names to their associated warnings, as generated by,  for  exam‐
84              ple, the command ::page::util::peg::getWarnings.
85
86              The  warnings  contained  therein are formatted and then printed
87              via the log command page_info. This means that this command  can
88              be  used  only  from  within  a  plugin  managed  by the package
89              page::pluginmgr.
90
91       ::page::util::peg::peOf tree eroot
92              This command converts the parsing  expression  starting  at  the
93              node  eroot in the AST tree into a nested list. The exact syntax
94              of this list specified by the package grammar::peg.
95
96       ::page::util::peg::printTclExpr pe
97              This command converts the parsing expression  contained  in  the
98              nested  list pe into a Tcl string which can be placed into a Tcl
99              script.  See the package grammar::peg for the  exact  syntax  of
100              pe.
101

BUGS, IDEAS, FEEDBACK

103       This  document,  and the package it describes, will undoubtedly contain
104       bugs and other problems.  Please report such in the  category  page  of
105       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
106       also report any ideas for enhancements you may have for either  package
107       and/or documentation.
108
109       When proposing code changes, please provide unified diffs, i.e the out‐
110       put of diff -u.
111
112       Note further that  attachments  are  strongly  preferred  over  inlined
113       patches.  Attachments  can  be  made  by  going to the Edit form of the
114       ticket immediately after its creation, and  then  using  the  left-most
115       button in the secondary navigation bar.
116

KEYWORDS

118       PEG,  page, parser generator, parsing expression grammar, text process‐
119       ing, transformation
120

CATEGORY

122       Page Parser Generator
123
125       Copyright (c) 2007 Andreas Kupries <andreas_kupries@users.sourceforge.net>
126
127
128
129
130tcllib                                1.0                     page_util_peg(n)
Impressum