From 1e79880c72d9e16c585f493d2b02bf890eaff63f Mon Sep 17 00:00:00 2001 From: ncannasse Date: Thu, 23 Nov 2017 12:40:50 +0100 Subject: [PATCH] more conformance to haxe syntax wrt mandatory ; added static and macro accessors --- hscript/Expr.hx | 2 ++ hscript/Parser.hx | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/hscript/Expr.hx b/hscript/Expr.hx index e974d6b..368e785 100644 --- a/hscript/Expr.hx +++ b/hscript/Expr.hx @@ -142,6 +142,8 @@ enum FieldAccess { APrivate; AInline; AOverride; + AStatic; + AMacro; } enum FieldKind { diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 9072086..78af119 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -271,7 +271,7 @@ class Parser { return switch( expr(e) ) { case EBlock(_), EObject(_), ESwitch(_): true; case EFunction(_,e,_,_): isBlock(e); - case EVar(_,_,e): e != null && isBlock(e); + case EVar(_, t, e): e != null ? isBlock(e) : t != null ? t.match(CTAnon(_)) : false; case EIf(_,e1,e2): if( e2 != null ) isBlock(e2) else isBlock(e1); case EBinop(_,_,e): isBlock(e); case EUnop(_,prefix,e): !prefix && isBlock(e); @@ -1031,6 +1031,10 @@ class Parser { access.push(APrivate); case "inline": access.push(AInline); + case "static": + access.push(AStatic); + case "macro": + access.push(AMacro); case "function": var name = getIdent(); var inf = parseFunctionDecl(); @@ -1055,7 +1059,17 @@ class Parser { } var type = maybe(TDoubleDot) ? parseType() : null; var expr = maybe(TOp("=")) ? parseExpr() : null; - ensure(TSemicolon); + + if( expr != null ) { + if( isBlock(expr) ) + maybe(TSemicolon); + else + ensure(TSemicolon); + } else if( type != null && type.match(CTAnon(_)) ) { + maybe(TSemicolon); + } else + ensure(TSemicolon); + return { name : name, meta : meta,