Mercurial Hosting > luan
changeset 604:b73f005f3735 0.13
table constructor now uses end_of_line as a delimiter
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 24 Nov 2015 16:29:27 -0700 |
parents | 862d6bb8124c |
children | 5edadbf57352 |
files | blog/src/lib/Post.luan core/src/luan/impl/LuanParser.java website/src/diff.html.luan website/src/manual.html.luan |
diffstat | 4 files changed, 31 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/blog/src/lib/Post.luan Tue Nov 10 06:20:08 2015 -0700 +++ b/blog/src/lib/Post.luan Tue Nov 24 16:29:27 2015 -0700 @@ -13,10 +13,10 @@ local function from_doc(doc) return M.new { - id = doc.id; - subject = doc.subject; - content = doc.content; - date = doc.date; + id = doc.id + subject = doc.subject + content = doc.content + date = doc.date } end @@ -27,11 +27,11 @@ function this.save() local doc = { - type = "post"; - id = this.id; - subject = this.subject; - content = this.content; - date = this.date; + type = "post" + id = this.id + subject = this.subject + content = this.content + date = this.date } Db.save(doc) this.id = doc.id
--- a/core/src/luan/impl/LuanParser.java Tue Nov 10 06:20:08 2015 -0700 +++ b/core/src/luan/impl/LuanParser.java Tue Nov 24 16:29:27 2015 -0700 @@ -765,12 +765,15 @@ int start = parser.begin(); if( !parser.match('{') ) return parser.failure(null); - In inParens = in.parens(); - Spaces(inParens); + Spaces(In.NOTHING); List<TableExpr.Field> fields = new ArrayList<TableExpr.Field>(); List<Expressions> builder = new ArrayList<Expressions>(); - while( Field(fields,builder,inParens) && FieldSep(inParens) ); - Expressions exp = TemplateExpressions(inParens); + Field(fields,builder); + while( FieldSep() ) { + Spaces(In.NOTHING); + Field(fields,builder); + } + Expressions exp = TemplateExpressions(In.NOTHING); if( exp != null ) builder.add(exp); if( !parser.match('}') ) @@ -779,25 +782,22 @@ return parser.success( new TableExpr( se(start), fields.toArray(new TableExpr.Field[0]), ExpList.build(builder) ) ); } - private boolean FieldSep(In in) throws ParseException { - if( !parser.anyOf(",;") ) - return false; - Spaces(in); - return true; + private boolean FieldSep() throws ParseException { + return parser.anyOf(",;") || EndOfLine(); } - private boolean Field(List<TableExpr.Field> fields,List<Expressions> builder,In in) throws ParseException { + private boolean Field(List<TableExpr.Field> fields,List<Expressions> builder) throws ParseException { parser.begin(); - Expr exp = SubExpr(in); + Expr exp = SubExpr(In.NOTHING); if( exp==null ) - exp = NameExpr(in); + exp = NameExpr(In.NOTHING); if( exp!=null && parser.match('=') ) { - Spaces(in); - fields.add( new TableExpr.Field( exp, required(expr(ExprZ(in))) ) ); + Spaces(In.NOTHING); + fields.add( new TableExpr.Field( exp, required(expr(ExprZ(In.NOTHING))) ) ); return parser.success(); } parser.rollback(); - Expressions exprs = ExprZ(in); + Expressions exprs = ExprZ(In.NOTHING); if( exprs != null ) { builder.add(exprs); return parser.success(); @@ -1009,9 +1009,8 @@ parser.begin(); if( !parser.match('[') || parser.test("[") || parser.test("=") ) return parser.failure(null); - In inParens = in.parens(); - Spaces(inParens); - Expr exp = expr(RequiredExpr(inParens)); + Spaces(In.NOTHING); + Expr exp = expr(RequiredExpr(In.NOTHING)); RequiredMatch(']'); Spaces(in); return parser.success(exp);
--- a/website/src/diff.html.luan Tue Nov 10 06:20:08 2015 -0700 +++ b/website/src/diff.html.luan Tue Nov 24 16:29:27 2015 -0700 @@ -118,7 +118,7 @@ <h3 heading><a name="lex">Lexical Conventions</a></h3> -<p>Unlike Lua, Luan generally considers the end of a line to be the end of a statement. This catches errors and encourages readability. The exception to this is in paranthesis ( <em>(...)</em>, <em>[...]</em>, and <em>{...}</em> ) where the end of line is treated as white space.</p> +<p>Unlike Lua, Luan generally considers the end of a line to be the end of a statement. This catches errors and encourages readability. The exception to this is in paranthesis <em>(...)</em> where the end of line is treated as white space.</p> <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
--- a/website/src/manual.html.luan Tue Nov 10 06:20:08 2015 -0700 +++ b/website/src/manual.html.luan Tue Nov 24 16:29:27 2015 -0700 @@ -526,7 +526,7 @@ Luan ignores spaces and comments between lexical elements (tokens), except as delimiters between names and keywords. -Luan generally considers the end of a line to be the end of a statement. This catches errors and encourages readability. The exception to this is in paranthesis ( <em>(...)</em>, <em>[...]</em>, and <em>{...}</em> ) where the end of line is treated as white space. +Luan generally considers the end of a line to be the end of a statement. This catches errors and encourages readability. The exception to this is in paranthesis <em>(...)</em> where the end of line is treated as white space. <p> <em>Names</em> @@ -1423,10 +1423,10 @@ The general syntax for constructors is <pre> - tableconstructor ::= ‘<b>{</b>’ [fieldlist] ‘<b>}</b>’ - fieldlist ::= field {fieldsep field} [fieldsep] + tableconstructor ::= ‘<b>{</b>’ fieldlist ‘<b>}</b>’ + fieldlist ::= [field] {fieldsep [field]} field ::= ‘<b>[</b>’ exp ‘<b>]</b>’ ‘<b>=</b>’ exp | Name ‘<b>=</b>’ exp | exp - fieldsep ::= ‘<b>,</b>’ | ‘<b>;</b>’ + fieldsep ::= ‘<b>,</b>’ | ‘<b>;</b>’ | <b>end_of_line</b> </pre> <p>