aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-19 15:49:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-19 15:49:40 -0300
commitf84c2ebc4aba7e62618a8177296d95a83167ec06 (patch)
tree3fc89c20bfa245829b743386ae4097dbc0c423d6
parentc8897f2b082616bd5eb5328d3f260273adb53fbd (diff)
downloadlua-f84c2ebc4aba7e62618a8177296d95a83167ec06.tar.gz
lua-f84c2ebc4aba7e62618a8177296d95a83167ec06.tar.bz2
lua-f84c2ebc4aba7e62618a8177296d95a83167ec06.zip
dostring has an optional error method argument;
counter for gsub only when there is a table (to keep full compatibility)
-rw-r--r--manual.tex26
1 files changed, 15 insertions, 11 deletions
diff --git a/manual.tex b/manual.tex
index 2d19ac88..a1d6fd99 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 2.2 1997/06/18 21:11:53 roberto Exp roberto $ 1% $Id: manual.tex,v 2.3 1997/06/19 18:03:04 roberto Exp roberto $
2 2
3\documentstyle[fullpage,11pt,bnf]{article} 3\documentstyle[fullpage,11pt,bnf]{article}
4 4
@@ -38,7 +38,7 @@ Waldemar Celes
38\tecgraf\ --- Computer Science Department --- PUC-Rio 38\tecgraf\ --- Computer Science Department --- PUC-Rio
39} 39}
40 40
41\date{\small \verb$Date: 1997/06/18 21:11:53 $} 41\date{\small \verb$Date: 1997/06/19 18:03:04 $}
42 42
43\maketitle 43\maketitle
44 44
@@ -1624,12 +1624,15 @@ or a non \nil\ value if the chunk returns no values.
1624It issues an error when called with a non string argument. 1624It issues an error when called with a non string argument.
1625\verb|dofile| is equivalent to the API function \verb|lua_dofile|. 1625\verb|dofile| is equivalent to the API function \verb|lua_dofile|.
1626 1626
1627\subsubsection*{\ff {\tt dostring (string)}}\Deffunc{dostring} 1627\subsubsection*{\ff {\tt dostring (string [, errmethod])}}\Deffunc{dostring}
1628This function executes a given string as a Lua chunk. 1628This function executes a given string as a Lua chunk.
1629If there is any error executing the string, it returns \nil. 1629If there is any error executing the string, it returns \nil.
1630Otherwise, it returns the values returned by the chunk, 1630Otherwise, it returns the values returned by the chunk,
1631or a non \nil\ value if the chunk returns no values. 1631or a non \nil\ value if the chunk returns no values.
1632\verb|dostring| is equivalent to the API function \verb|lua_dostring|. 1632If provided, \verb|errmethod| is temporarily set as the error method,
1633while \verb|string| runs.
1634As a particular case, if \verb|errmethod| is \nil,
1635no error messages will be issued during the execution of the string.
1633 1636
1634\subsubsection*{\ff {\tt newtag ()}}\Deffunc{newtag}\label{pdf-newtag} 1637\subsubsection*{\ff {\tt newtag ()}}\Deffunc{newtag}\label{pdf-newtag}
1635Returns a new tag. 1638Returns a new tag.
@@ -1890,10 +1893,11 @@ stands for the value of the n-th captured substring.
1890 1893
1891If \verb|repl| is a function, then this function is called every time a 1894If \verb|repl| is a function, then this function is called every time a
1892match occurs, with the following arguments: 1895match occurs, with the following arguments:
1893If \verb|table| is present, it is the first argument; 1896If \verb|table| is present, the the first argument is this table
1894then all captured substrings, in order (see below); 1897and the second one is a match counter (1 for the first call).
1895finally, the last argument is a match counter 1898Independently of these two optional arguments,
1896(1 for the first call). 1899all captured substrings are passed as arguments,
1900in order (see below);
1897If the value returned by this function is a string, 1901If the value returned by this function is a string,
1898then it is used as the replacement string; 1902then it is used as the replacement string;
1899otherwise, the replacement string is the empty string. 1903otherwise, the replacement string is the empty string.
@@ -1914,17 +1918,17 @@ See some examples below:
1914 x = gsub("4+5 = $return 4+5$", "$(.-)%$", dostring) 1918 x = gsub("4+5 = $return 4+5$", "$(.-)%$", dostring)
1915 --> x="4+5 = 9" 1919 --> x="4+5 = 9"
1916 1920
1921 function f(t, i, v) return t[v] end
1917 t = {name="lua", version="3.0"} 1922 t = {name="lua", version="3.0"}
1918 x = gsub("$name - $version", "$(%w%w*)", rawgettable, t) 1923 x = gsub("$name - $version", "$(%w%w*)", f, t)
1919 --> x="lua - 3.0" 1924 --> x="lua - 3.0"
1920 1925
1921 t = {"apple", "orange", "lime"} 1926 t = {"apple", "orange", "lime"}
1922 x = gsub("x and x and x", "x", rawgettable, t) 1927 x = gsub("x and x and x", "x", rawgettable, t)
1923 --> x="apple and orange and lime" 1928 --> x="apple and orange and lime"
1924 1929
1925 function f(t,v,i) t[i]=v end
1926 t = {} 1930 t = {}
1927 gsub("first second word", "(%w%w*)", f, t) 1931 gsub("first second word", "(%w%w*)", rawsettable, t)
1928 --> t={"first", "second", "word"} 1932 --> t={"first", "second", "word"}
1929\end{verbatim} 1933\end{verbatim}
1930 1934