diff options
author | Karl Berry <karl@freefriends.org> | 2019-12-19 22:11:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-12-19 22:11:59 +0000 |
commit | 8876a8021514f190d676e4e5261f1084a66754d3 (patch) | |
tree | 9a496107a312a1acbbdb06ea0e1657c285109729 /Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex | |
parent | 693eacf895c01285e2992460bb489142ead8ae8a (diff) |
pgf (19dec19)
git-svn-id: svn://tug.org/texlive/trunk@53187 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex index 1dfec36c239..8a85b57c78e 100644 --- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex +++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex @@ -15,7 +15,7 @@ \begin{pgfmodule}{parser}% This module defines some commands for creating a simple letter-by-letter parser. -\end{pgfmodule}% +\end{pgfmodule} This module provides commands for defining a parser that scans some given text letter-by-letter. For each letter, some code is executed and, possibly a @@ -45,7 +45,7 @@ optionally some code is executed afterwards. In the following example, the parser counts the number of |a|'s in the \text{text}, ignoring any |b|'s. The \meta{text} ends with the first~|c|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{parser}}] \newcount\mycount \pgfparserdef{myparser}{initial}{the letter a}% {\advance\mycount by 1\relax}% @@ -213,8 +213,11 @@ There are \the\mycount\ a's. This macro stores the letter to which |\pgfparsertoken| was let. So if you'd use |\pgfparserparse{foo}a| this macro would be defined with |\def\pgfparserletter{a}|. This definition is done before any action code is - executed. There are two special cases: If |{| or |}| would be the next letter - for the parser, this macro is defined to expand to |\bgroup| or |\egroup|. + executed. There are four special cases: If the next token is of category code + 1, 2, 6, or 10, so with standard category codes the tokens |{|, |}|, |#|, and + \textvisiblespace\ (a space) would be treated differently. In those cases this + macro expands to |\bgroup|, |\egroup|, |##|, and \textvisiblespace\ for the + categories 1, 2, 6, and 10, respectively. \end{command}% \begin{command}{\pgfparserset\marg{key list}}% @@ -223,7 +226,10 @@ There are \the\mycount\ a's. listed in subsection~\ref{sec:parser:keys}. \end{command}% -\subsection{Keys of the Parser Module}\label{sec:parser:keys}% + +\subsection{Keys of the Parser Module} +\label{sec:parser:keys} + \begin{key}{/pgfparser/silent=\meta{boolean} (initially false)}% If |true| then no error will be thrown when a letter is parsed for which no action is specified, silently ignoring it. This holds true for every parser. @@ -244,13 +250,19 @@ the following will be defined: defined parser. \end{key}% -\subsection{Examples}% + +\subsection{Examples} + The following example counts the different letters appearing in a more or less -random string of letters. Every letter is counted only once, this is achieved by -defining a new action for every encountered unknown letter that does nothing. We -can define such rule without knowing which letter is used, because +random string of letters. Every letter is counted only once, this is achieved +by defining a new action for every encountered unknown letter that does +nothing. We can define such rule without knowing which letter is used, because |\pgfparsertoken| has the same meaning as that letter. -\begin{codeexample}[] +% +\begin{codeexample}[ + preamble={\usepgfmodule{parser}}, + pre={\newcount\mycount}, +] \mycount=0 % using the shortcut syntax of just placing ; after the state \pgfparserdef{different letters}{all};{\pgfparserswitch{final}}% @@ -266,7 +278,8 @@ can define such rule without knowing which letter is used, because Next we want to try something that uses some of the different argument types available. -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usepgfmodule{parser}}] % using the same syntax as \pgfparserdef \pgfparserdef{arguments}{initial}{the letter a}[d()] {\pgfparserifmark{#1}{\textcolor{red}{\textit{use}}}{\textbf{#1}} }% |