aboutsummaryrefslogtreecommitdiff
path: root/manual.tex
diff options
context:
space:
mode:
Diffstat (limited to 'manual.tex')
-rw-r--r--manual.tex84
1 files changed, 58 insertions, 26 deletions
diff --git a/manual.tex b/manual.tex
index 45fc1d5e..6e02a917 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.25 1996/11/18 14:27:42 roberto Exp $ 1% $Id: manual.tex,v 1.26 1997/01/23 16:17:53 roberto Exp roberto $
2 2
3\documentstyle[fullpage,11pt,bnf]{article} 3\documentstyle[fullpage,11pt,bnf]{article}
4 4
@@ -35,10 +35,13 @@ Waldemar Celes
35\tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio 35\tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio
36} 36}
37 37
38\date{\small \verb$Date: 1996/11/18 14:27:42 $} 38\date{\small \verb$Date: 1997/01/23 16:17:53 $}
39 39
40\maketitle 40\maketitle
41 41
42\thispagestyle{empty}
43\pagestyle{empty}
44
42\begin{abstract} 45\begin{abstract}
43\noindent 46\noindent
44Lua is an extension programming language designed to be used 47Lua is an extension programming language designed to be used
@@ -69,7 +72,7 @@ ca\-racte\-r\'{\i}sticas do sistema.
69\vfill 72\vfill
70\begin{quotation} 73\begin{quotation}
71\noindent 74\noindent
72\small 75\footnotesize
73Copyright (c) 1994--1996 TeCGraf, PUC-Rio. Written by Waldemar Celes Filho, 76Copyright (c) 1994--1996 TeCGraf, PUC-Rio. Written by Waldemar Celes Filho,
74Roberto Ierusalimschy, Luiz Henrique de Figueiredo. All rights reserved. 77Roberto Ierusalimschy, Luiz Henrique de Figueiredo. All rights reserved.
75% 78%
@@ -97,10 +100,14 @@ documentation.
97\end{quotation} 100\end{quotation}
98\vfill 101\vfill
99 102
100\thispagestyle{empty}
101\setcounter{page}{0}
102\newpage 103\newpage
103 104
105\tableofcontents
106
107\newpage
108\setcounter{page}{1}
109\pagestyle{plain}
110
104 111
105\section{Introduction} 112\section{Introduction}
106 113
@@ -1235,7 +1242,6 @@ the function returns the first index
1235of the table (and its associated value). 1242of the table (and its associated value).
1236When called with the last index, or with \nil\ in an empty table, 1243When called with the last index, or with \nil\ in an empty table,
1237it returns \nil. 1244it returns \nil.
1238This function cannot be written with the standard API.
1239 1245
1240In Lua there is no declaration of fields; 1246In Lua there is no declaration of fields;
1241semantically, there is no difference between a 1247semantically, there is no difference between a
@@ -1243,8 +1249,11 @@ field not present in a table or a field with value \nil.
1243Therefore, the function only considers fields with non \nil\ values. 1249Therefore, the function only considers fields with non \nil\ values.
1244The order in which the indices are enumerated is not specified, 1250The order in which the indices are enumerated is not specified,
1245{\em even for numeric indices}. 1251{\em even for numeric indices}.
1252If the table is modified in any way during a traversal,
1253the semantics of \verb|next| is undefined.
1246 1254
1247See Section~\ref{exnext} for an example of the use of this function. 1255See Section~\ref{exnext} for an example of the use of this function.
1256This function cannot be written with the standard API.
1248 1257
1249\subsubsection*{\ff{\tt nextvar (name)}}\Deffunc{nextvar} 1258\subsubsection*{\ff{\tt nextvar (name)}}\Deffunc{nextvar}
1250This function is similar to the function \verb'next', 1259This function is similar to the function \verb'next',
@@ -1254,6 +1263,9 @@ or \nil\ to get a first name.
1254Similarly to \verb'next', it returns the name of another variable 1263Similarly to \verb'next', it returns the name of another variable
1255and its value, 1264and its value,
1256or \nil\ if there are no more variables. 1265or \nil\ if there are no more variables.
1266There can be no assignments to global variables during the traversal;
1267otherwise the semantics of \verb|nextvar| is undefined.
1268
1257See Section~\ref{exnext} for an example of the use of this function. 1269See Section~\ref{exnext} for an example of the use of this function.
1258This function cannot be written with the standard API. 1270This function cannot be written with the standard API.
1259 1271
@@ -1495,36 +1507,56 @@ where char-set is interpreted as above.
1495\end{description} 1507\end{description}
1496 1508
1497\paragraph{Pattern Item:} 1509\paragraph{Pattern Item:}
1498a \Def{pattern item} may be a single character class, 1510a \Def{pattern item} may be:
1499or a character class followed by \verb'*' or by \verb'?'. 1511\begin{itemize}
1500A single character class matches any single character in the class. 1512\item
1501A character class followed by \verb'*' matches 0 or more repetitions 1513a single character class,
1502of characters in the class. 1514which matches any single character in the class;
1503A character class followed by \verb'?' matches 0 or one occurrence 1515\item
1504of a character in the class. 1516a single character class followed by \verb'*',
1505A pattern item may also has the form \verb'%n', 1517which matches 0 or more repetitions of characters in the class.
1506for \verb-n- between 1 and 9; 1518These repetition itens will always match the longest possible sequence.
1519\item
1520a single character class followed by \verb'-',
1521which also matches 0 or more repetitions of characters in the class.
1522Unlike \verb'*',
1523these repetition itens will always match the shortest possible sequence.
1524\item
1525a single character class followed by \verb'?',
1526which matches 0 or 1 occurrence of a character in the class;
1527\item
1528{\tt \%$n$}, for $n$ between 1 and 9;
1507such item matches a sub-string equal to the n-th captured string 1529such item matches a sub-string equal to the n-th captured string
1508(see below). 1530(see below);
1531\item
1532{\tt \%b$xy$}, where $x$ and $y$ are two distinct characters;
1533such item mathes strings that start with $x$, end with $y$,
1534and where the $x$ and $y$ are {\em balanced}.
1535That means that, if one reads the string from left to write,
1536counting plus 1 for an $x$ and minus 1 for a $y$,
1537the ending $y$ is the first where the count reaches 0.
1538For instance, the item \verb|%()| matches expressions with
1539balanced parentheses.
1540\end{itemize}
1509 1541
1510\paragraph{Pattern:} 1542\paragraph{Pattern:}
1511a \Def{pattern} is a sequence of pattern items. 1543a \Def{pattern} is a sequence of pattern items.
1512Any repetition item (\verb'*') inside a pattern will always
1513match the longest possible sequence.
1514A \verb'^' at the beginning of a pattern anchors the match at the 1544A \verb'^' at the beginning of a pattern anchors the match at the
1515beginning of the subject string. 1545beginning of the subject string.
1516A \verb'$' at the end of a pattern anchors the match at the 1546A \verb'$' at the end of a pattern anchors the match at the
1517end of the subject string. 1547end of the subject string.
1518 1548
1519A pattern may contain sub-patterns enclosed in parentheses, 1549\paragraph{Captures:}
1550a pattern may contain sub-patterns enclosed in parentheses,
1520that describe \Def{captures}. 1551that describe \Def{captures}.
1521When a match succeeds, the sub-strings of the subject string 1552When a match succeeds, the sub-strings of the subject string
1522that match captures are {\em captured\/} for future use. 1553that match captures are stored ({\em captured\/}) for future use.
1523Captures are numbered according to their left parentheses. 1554Captures are numbered according to their left parentheses.
1524For instance, in the pattern \verb|"(a*(.)%w(%s*))"|, 1555For instance, in the pattern \verb|"(a*(.)%w(%s*))"|,
1525the capture \verb|"(a*(.)%w(%s*))"| has number 1 1556the part of the string matching \verb|"a*(.)%w(%s*)"| is
1526(and therefore is the first capture), 1557stored as the first capture (and therefore has number 1);
1527\verb|(.)| has number 2, and \verb|(%s*)| has number 3. 1558the character matching \verb|.| is captured with number 2,
1559and the part matching \verb|%s*| has number 3.
1528 1560
1529\subsection{Mathematical Functions} \label{mathlib} 1561\subsection{Mathematical Functions} \label{mathlib}
1530 1562
@@ -1947,7 +1979,9 @@ end
1947\end{verbatim} 1979\end{verbatim}
1948 1980
1949The next example prints the names of all global variables 1981The next example prints the names of all global variables
1950in the system with non nil values: 1982in the system with non nil values.
1983Notice that the traversal is made with local variables,
1984to avoid changing a global variable:
1951\begin{verbatim} 1985\begin{verbatim}
1952function printGlobalVariables () 1986function printGlobalVariables ()
1953 local i, v = nextvar(nil) 1987 local i, v = nextvar(nil)
@@ -2474,7 +2508,5 @@ Special care should be taken with macros like
2474\input{manual.id} 2508\input{manual.id}
2475\end{theindex} 2509\end{theindex}
2476 2510
2477\pagebreak
2478\tableofcontents
2479 2511
2480\end{document} 2512\end{document}