Spec-Zone .ru
спецификации, руководства, описания, API
Spec-Zone .ru
спецификации, руководства, описания, API
Библиотека разработчика Mac Разработчик
Поиск

 

Эта страница руководства для  версии 10.9 Mac OS X

Если Вы выполняете различную версию  Mac OS X, просматриваете документацию локально:

Читать страницы руководства

Страницы руководства предназначаются как справочник для людей, уже понимающих технологию.

  • Чтобы изучить, как руководство организовано или узнать о синтаксисе команды, прочитайте страницу руководства для страниц справочника (5).

  • Для получения дополнительной информации об этой технологии, ищите другую документацию в Библиотеке Разработчика Apple.

  • Для получения общей информации о записи сценариев оболочки, считайте Shell, Пишущий сценарий Учебника для начинающих.



pt::pe::op(n)                                   Parser Tools                                   pt::pe::op(n)



____________________________________________________________________________________________________________

NAME
       pt::pe::op - Parsing Expression Utilities

SYNOPSIS
       package require Tcl  8.5

       package require pt::pe::op  ?1?

       package require pt::pe  ?1?

       package require struct::set

       ::pt::pe::op drop dropset pe

       ::pt::pe::op rename nt ntnew pe

       ::pt::pe::op called pe

       ::pt::pe::op flatten pe

       ::pt::pe::op fusechars pe

____________________________________________________________________________________________________________

DESCRIPTION
       Are you lost ?  Do you have trouble understanding this document ?  In that case please read the over-view overview
       view provided by the Introduction to Parser Tools. This document is the entrypoint to the whole  sys-tem system
       tem the current package is a part of.

       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 PE serialization format.

       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.

API
       ::pt::pe::op drop dropset pe
              This command removes all occurences of any of the nonterminals symbols in the set dropset from
              the parsing expression pe, and simplifies it. This  may  result  in  the  expression  becoming
              "epsilon", i.e. matching nothing.

       ::pt::pe::op rename nt ntnew pe
              This  command  renames  all occurences of the nonterminal nt in the parsing expression pe into
              ntnew.

       ::pt::pe::op called pe
              This command extracts the set of all nonterminal symbols used, i.e. 'called', in  the  parsing
              expression pe.

       ::pt::pe::op flatten 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 fur-ther further
              ther eliminates all sequences and choices with only one child, as these are redundant.

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

       ::pt::pe::op fusechars pe
              This  command  transforms the parsing expression by fusing adjacent terminals in sequences and
              adjacent terminals and ranges in choices, it (re)constructs highlevel  strings  and  character
              classes.

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

              The  result  is called a pseudo-parsing expression because it is not a true parsing expression
              anymore, and will fail a check with ::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 ::pt::peg bottomup and ::pt::peg topdown will process them without trouble.


PE SERIALIZATION FORMAT
       Here we specify the format used by the Parser Tools to serialize  Parsing  Expressions  as  immutable
       values for transport, comparison, etc.

       We  distinguish  between  regular  and canonical serializations.  While a parsing expression may have
       more than one regular serialization only exactly one of them will be canonical.

       Regular serialization

              Atomic Parsing Expressions

                     [1]    The string epsilon is an atomic parsing expression. It matches the empty string.

                     [2]    The string dot is an atomic parsing expression. It matches any character.

                     [3]    The  string alnum is an atomic parsing expression. It matches any Unicode alpha-bet alphabet
                            bet or digit character. This is a custom extension of PEs based on Tcl's builtin
                            command string is.

                     [4]    The  string alpha is an atomic parsing expression. It matches any Unicode alpha-bet alphabet
                            bet character. This is a custom extension of PEs based on Tcl's builtin  command
                            string is.

                     [5]    The string ascii is an atomic parsing expression. It matches any Unicode charac-ter character
                            ter below U0080. This is a custom extension of PEs based on Tcl's  builtin  com-mand command
                            mand string is.

                     [6]    The  string control is an atomic parsing expression. It matches any Unicode con-trol control
                            trol character. This is a custom extension of PEs based on Tcl's builtin command
                            string is.

                     [7]    The  string  digit is an atomic parsing expression. It matches any Unicode digit
                            character. Note that this includes characters outside of the [0..9] range.  This
                            is a custom extension of PEs based on Tcl's builtin command string is.

                     [8]    The  string graph is an atomic parsing expression. It matches any Unicode print-ing printing
                            ing character, except for space. This is a custom  extension  of  PEs  based  on
                            Tcl's builtin command string is.

                     [9]    The  string lower is an atomic parsing expression. It matches any Unicode lower-case lowercase
                            case alphabet character. This is a  custom  extension  of  PEs  based  on  Tcl's
                            builtin command string is.

                     [10]   The  string print is an atomic parsing expression. It matches any Unicode print-ing printing
                            ing character, including space. This is a custom extension of PEs based on Tcl's
                            builtin command string is.

                     [11]   The string punct is an atomic parsing expression. It matches any Unicode punctu-ation punctuation
                            ation character. This is a custom extension of PEs based on Tcl's  builtin  com-mand command
                            mand string is.

                     [12]   The  string  space is an atomic parsing expression. It matches any Unicode space
                            character. This is a custom extension of PEs  based  on  Tcl's  builtin  command
                            string is.

                     [13]   The  string upper is an atomic parsing expression. It matches any Unicode upper-case uppercase
                            case alphabet character. This is a  custom  extension  of  PEs  based  on  Tcl's
                            builtin command string is.

                     [14]   The string wordchar is an atomic parsing expression. It matches any Unicode word
                            character. This is any alphanumeric character (see  alnum),  and  any  connector
                            punctuation  characters  (e.g.   underscore).  This is a custom extension of PEs
                            based on Tcl's builtin command string is.

                     [15]   The string xdigit is an atomic parsing expression. It  matches  any  hexadecimal
                            digit  character.  This is a custom extension of PEs based on Tcl's builtin com-mand command
                            mand string is.

                     [16]   The string ddigit is an atomic parsing expression. It matches any decimal  digit
                            character. This is a custom extension of PEs based on Tcl's builtin command reg-exp. regexp.
                            exp.

                     [17]   The expression [list t x] is an atomic parsing expression. It matches the termi-nal terminal
                            nal string x.

                     [18]   The  expression  [list n A] is an atomic parsing expression. It matches the non-terminal nonterminal
                            terminal A.

              Combined Parsing Expressions

                     [1]    For parsing expressions e1, e2, ... the result of [list / e1 e2 ... ] is a pars-ing parsing
                            ing expression as well.  This is the ordered choice, aka prioritized choice.

                     [2]    For parsing expressions e1, e2, ... the result of [list x e1 e2 ... ] is a pars-ing parsing
                            ing expression as well.  This is the sequence.

                     [3]    For a parsing expression e the result of [list * e] is a parsing  expression  as
                            well.  This is the kleene closure, describing zero or more repetitions.

                     [4]    For  a  parsing expression e the result of [list + e] is a parsing expression as
                            well.  This is the positive kleene closure, describing one or more  repetitions.

                     [5]    For  a  parsing expression e the result of [list & e] is a parsing expression as
                            well.  This is the and lookahead predicate.

                     [6]    For a parsing expression e the result of [list ! e] is a parsing  expression  as
                            well.  This is the not lookahead predicate.

                     [7]    For  a  parsing expression e the result of [list ? e] is a parsing expression as
                            well.  This is the optional input.

       Canonical serialization
              The canonical serialization of a parsing expression has the format as specified in the  previ-ous previous
              ous  item,  and  then additionally satisfies the constraints below, which make it unique among
              all the possible serializations of this parsing expression.

              [1]    The string representation of the value is the canonical representation of  a  pure  Tcl
                     list. I.e. it does not contain superfluous whitespace.

              [2]    Terminals are not encoded as ranges (where start and end of the range are identical).



   EXAMPLE
       Assuming the parsing expression shown on the right-hand side of the rule


           Expression <- '(' Expression ')'
                       / Factor (MulOp Factor)*


       then its canonical serialization (except for whitespace) is


           {/ {x {t (} {n Expression} {t )}} {x {n Factor} {* {x {n MulOp} {n Factor}}}}}



BUGS, IDEAS, FEEDBACK
       This  document,  and  the  package  it  describes,  will undoubtedly contain bugs and other problems.
       Please  report  such   in   the   category   pt   of   the   Tcllib   SF   Trackers   [http://source -
       forge.net/tracker/? group_id=12883].   Please  also report any ideas for enhancements you may have for
       either package and/or documentation.

KEYWORDS
       EBNF, LL(k), PEG, TDPL,  context-free  languages,  expression,  grammar,  matching,  parser,  parsing
       expression, parsing expression grammar, push down automaton, recursive descent, state, top-down pars-ing parsing
       ing languages, transducer

CATEGORY
       Parsing and Grammars

COPYRIGHT
       Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>




pt                                                    1                                        pt::pe::op(n)

Сообщение о проблемах

Способ сообщить о проблеме с этой страницей руководства зависит от типа проблемы:

Ошибки содержания
Ошибки отчета в содержании этой документации со ссылками на отзыв ниже.
Отчеты об ошибках
Сообщите об ошибках в функциональности описанного инструмента или API через Генератор отчетов Ошибки.
Форматирование проблем
Отчет, форматирующий ошибки в интерактивной версии этих страниц со ссылками на отзыв ниже.