Mercurial Hosting > luan
diff website/src/manual.html.luan @ 389:497d4ef0a89f
documentation work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 24 Apr 2015 12:25:50 -0600 |
parents | 23d075ce1e48 |
children | 2f5cc9c2cbf0 |
line wrap: on
line diff
--- a/website/src/manual.html.luan Thu Apr 23 18:54:35 2015 -0600 +++ b/website/src/manual.html.luan Fri Apr 24 12:25:50 2015 -0600 @@ -48,6 +48,12 @@ <ul> <li><a href="#lex">Lexical Conventions</a></li> <li><a href="#vars">Variables</a></li> + <li> + <a href="#stmts">Statements</a> + <ul> + <li><a href="#blocks">Blocks</a></li> + </ul> + </li> </ul> </div> @@ -525,12 +531,12 @@ and cannot be used as names: -<p><pre> +<p><tt><pre> and break do else elseif end false for function goto if in local nil not or repeat return then true until while -</pre></p> +</pre></tt></p> <p> Luan is a case-sensitive language: @@ -541,13 +547,13 @@ <p> The following strings denote other tokens: -<p><pre> +<p><tt><pre> + - * / % ^ # & ~ | << >> // == ~= <= >= < > = ( ) { } [ ] :: ; : , . .. ... -</pre></p> +</pre></tt></p> <p> <i>Literal strings</i> @@ -626,7 +632,7 @@ As an example the five literal strings below denote the same string: -<p><pre> +<p><tt><pre> a = 'alo\n123"' a = "alo\n123\"" a = '\97lo\10\04923"' @@ -635,7 +641,7 @@ a = [==[ alo 123"]==] -</pre></p> +</pre></tt></p> <p> A <i>numerical constant</i> (or <i>numeral</i>) @@ -652,17 +658,17 @@ otherwise it denotes an integer. Examples of valid integer constants are -<p><pre> +<p><tt><pre> 3 345 0xff 0xBEBADA -</pre></p> +</pre></tt></p> <p> Examples of valid float constants are -<p><pre> +<p><tt><pre> 3.0 3.1416 314.16e-2 0.31416E1 34e1 0x0.1E 0xA23p-4 0X1.921FB54442D18P+1 -</pre></p> +</pre></tt></p> <p> A <i>comment</i> starts with a double hyphen (<tt>--</tt>) @@ -691,9 +697,9 @@ (or a function's formal parameter, which is a particular kind of local variable): -<p><pre> +<p><tt><pre> var ::= Name -</pre></p> +</pre></tt></p> <p> Name denotes identifiers, as defined in <a href="#3.1">§3.1</a>. @@ -714,9 +720,9 @@ <p> Square brackets are used to index a table: -<p><pre> +<p><tt><pre> var ::= prefixexp ‘<b>[</b>’ exp ‘<b>]</b>’ -</pre></p> +</pre></tt></p> <p> The meaning of accesses to table fields can be changed via metatables. @@ -732,9 +738,9 @@ The syntax <tt>var.Name</tt> is just syntactic sugar for <tt>var["Name"]</tt>: -<p><pre> +<p><tt><pre> var ::= prefixexp ‘<b>.</b>’ Name -</pre></p> +</pre></tt></p> <p> An access to a global variable <tt>x</tt> @@ -746,10 +752,10 @@ -<h2>3.3 – <a name="3.3">Statements</a></h2> - -<p> -Lua supports an almost conventional set of statements, +<h3 margin-top="1em"><a name="stmts">Statements</a></h3> + +<p> +Luan supports an almost conventional set of statements, similar to those in Pascal or C. This set includes assignments, control structures, function calls, @@ -757,59 +763,34 @@ -<h3>3.3.1 – <a name="3.3.1">Blocks</a></h3> +<h3 margin-top="1em"><a name="blocks">Blocks</a></h3> <p> A block is a list of statements, which are executed sequentially: -<pre> +<p><tt><pre> block ::= {stat} -</pre><p> -Lua has <em>empty statements</em> +</pre></tt></p> + +<p> +Luan has <i>empty statements</i> that allow you to separate statements with semicolons, start a block with a semicolon or write two semicolons in sequence: -<pre> +<p><tt><pre> stat ::= ‘<b>;</b>’ -</pre> - -<p> -Function calls and assignments -can start with an open parenthesis. -This possibility leads to an ambiguity in Lua's grammar. -Consider the following fragment: - -<pre> - a = b + c - (print or io.write)('done') -</pre><p> -The grammar could see it in two ways: - -<pre> - a = b + c(print or io.write)('done') - - a = b + c; (print or io.write)('done') -</pre><p> -The current parser always sees such constructions -in the first way, -interpreting the open parenthesis -as the start of the arguments to a call. -To avoid this ambiguity, -it is a good practice to always precede with a semicolon -statements that start with a parenthesis: - -<pre> - ;(print or io.write)('done') -</pre> +</pre></tt></p> <p> A block can be explicitly delimited to produce a single statement: -<pre> +<p><tt><pre> stat ::= <b>do</b> block <b>end</b> -</pre><p> +</pre></tt></p> + +<p> Explicit blocks are useful to control the scope of variable declarations. Explicit blocks are also sometimes used to