diff options
Diffstat (limited to 'manual.tex')
-rw-r--r-- | manual.tex | 84 |
1 files changed, 58 insertions, 26 deletions
@@ -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 |
44 | Lua is an extension programming language designed to be used | 47 | Lua 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 |
73 | Copyright (c) 1994--1996 TeCGraf, PUC-Rio. Written by Waldemar Celes Filho, | 76 | Copyright (c) 1994--1996 TeCGraf, PUC-Rio. Written by Waldemar Celes Filho, |
74 | Roberto Ierusalimschy, Luiz Henrique de Figueiredo. All rights reserved. | 77 | Roberto 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 | |||
1235 | of the table (and its associated value). | 1242 | of the table (and its associated value). |
1236 | When called with the last index, or with \nil\ in an empty table, | 1243 | When called with the last index, or with \nil\ in an empty table, |
1237 | it returns \nil. | 1244 | it returns \nil. |
1238 | This function cannot be written with the standard API. | ||
1239 | 1245 | ||
1240 | In Lua there is no declaration of fields; | 1246 | In Lua there is no declaration of fields; |
1241 | semantically, there is no difference between a | 1247 | semantically, there is no difference between a |
@@ -1243,8 +1249,11 @@ field not present in a table or a field with value \nil. | |||
1243 | Therefore, the function only considers fields with non \nil\ values. | 1249 | Therefore, the function only considers fields with non \nil\ values. |
1244 | The order in which the indices are enumerated is not specified, | 1250 | The order in which the indices are enumerated is not specified, |
1245 | {\em even for numeric indices}. | 1251 | {\em even for numeric indices}. |
1252 | If the table is modified in any way during a traversal, | ||
1253 | the semantics of \verb|next| is undefined. | ||
1246 | 1254 | ||
1247 | See Section~\ref{exnext} for an example of the use of this function. | 1255 | See Section~\ref{exnext} for an example of the use of this function. |
1256 | This 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} |
1250 | This function is similar to the function \verb'next', | 1259 | This function is similar to the function \verb'next', |
@@ -1254,6 +1263,9 @@ or \nil\ to get a first name. | |||
1254 | Similarly to \verb'next', it returns the name of another variable | 1263 | Similarly to \verb'next', it returns the name of another variable |
1255 | and its value, | 1264 | and its value, |
1256 | or \nil\ if there are no more variables. | 1265 | or \nil\ if there are no more variables. |
1266 | There can be no assignments to global variables during the traversal; | ||
1267 | otherwise the semantics of \verb|nextvar| is undefined. | ||
1268 | |||
1257 | See Section~\ref{exnext} for an example of the use of this function. | 1269 | See Section~\ref{exnext} for an example of the use of this function. |
1258 | This function cannot be written with the standard API. | 1270 | This 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:} |
1498 | a \Def{pattern item} may be a single character class, | 1510 | a \Def{pattern item} may be: |
1499 | or a character class followed by \verb'*' or by \verb'?'. | 1511 | \begin{itemize} |
1500 | A single character class matches any single character in the class. | 1512 | \item |
1501 | A character class followed by \verb'*' matches 0 or more repetitions | 1513 | a single character class, |
1502 | of characters in the class. | 1514 | which matches any single character in the class; |
1503 | A character class followed by \verb'?' matches 0 or one occurrence | 1515 | \item |
1504 | of a character in the class. | 1516 | a single character class followed by \verb'*', |
1505 | A pattern item may also has the form \verb'%n', | 1517 | which matches 0 or more repetitions of characters in the class. |
1506 | for \verb-n- between 1 and 9; | 1518 | These repetition itens will always match the longest possible sequence. |
1519 | \item | ||
1520 | a single character class followed by \verb'-', | ||
1521 | which also matches 0 or more repetitions of characters in the class. | ||
1522 | Unlike \verb'*', | ||
1523 | these repetition itens will always match the shortest possible sequence. | ||
1524 | \item | ||
1525 | a single character class followed by \verb'?', | ||
1526 | which matches 0 or 1 occurrence of a character in the class; | ||
1527 | \item | ||
1528 | {\tt \%$n$}, for $n$ between 1 and 9; | ||
1507 | such item matches a sub-string equal to the n-th captured string | 1529 | such 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; | ||
1533 | such item mathes strings that start with $x$, end with $y$, | ||
1534 | and where the $x$ and $y$ are {\em balanced}. | ||
1535 | That means that, if one reads the string from left to write, | ||
1536 | counting plus 1 for an $x$ and minus 1 for a $y$, | ||
1537 | the ending $y$ is the first where the count reaches 0. | ||
1538 | For instance, the item \verb|%()| matches expressions with | ||
1539 | balanced parentheses. | ||
1540 | \end{itemize} | ||
1509 | 1541 | ||
1510 | \paragraph{Pattern:} | 1542 | \paragraph{Pattern:} |
1511 | a \Def{pattern} is a sequence of pattern items. | 1543 | a \Def{pattern} is a sequence of pattern items. |
1512 | Any repetition item (\verb'*') inside a pattern will always | ||
1513 | match the longest possible sequence. | ||
1514 | A \verb'^' at the beginning of a pattern anchors the match at the | 1544 | A \verb'^' at the beginning of a pattern anchors the match at the |
1515 | beginning of the subject string. | 1545 | beginning of the subject string. |
1516 | A \verb'$' at the end of a pattern anchors the match at the | 1546 | A \verb'$' at the end of a pattern anchors the match at the |
1517 | end of the subject string. | 1547 | end of the subject string. |
1518 | 1548 | ||
1519 | A pattern may contain sub-patterns enclosed in parentheses, | 1549 | \paragraph{Captures:} |
1550 | a pattern may contain sub-patterns enclosed in parentheses, | ||
1520 | that describe \Def{captures}. | 1551 | that describe \Def{captures}. |
1521 | When a match succeeds, the sub-strings of the subject string | 1552 | When a match succeeds, the sub-strings of the subject string |
1522 | that match captures are {\em captured\/} for future use. | 1553 | that match captures are stored ({\em captured\/}) for future use. |
1523 | Captures are numbered according to their left parentheses. | 1554 | Captures are numbered according to their left parentheses. |
1524 | For instance, in the pattern \verb|"(a*(.)%w(%s*))"|, | 1555 | For instance, in the pattern \verb|"(a*(.)%w(%s*))"|, |
1525 | the capture \verb|"(a*(.)%w(%s*))"| has number 1 | 1556 | the part of the string matching \verb|"a*(.)%w(%s*)"| is |
1526 | (and therefore is the first capture), | 1557 | stored as the first capture (and therefore has number 1); |
1527 | \verb|(.)| has number 2, and \verb|(%s*)| has number 3. | 1558 | the character matching \verb|.| is captured with number 2, |
1559 | and 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 | ||
1949 | The next example prints the names of all global variables | 1981 | The next example prints the names of all global variables |
1950 | in the system with non nil values: | 1982 | in the system with non nil values. |
1983 | Notice that the traversal is made with local variables, | ||
1984 | to avoid changing a global variable: | ||
1951 | \begin{verbatim} | 1985 | \begin{verbatim} |
1952 | function printGlobalVariables () | 1986 | function 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} |