From 9911465071103c71bb6adbbd478013f1160beeb0 Mon Sep 17 00:00:00 2001 From: Zjnue Brzavi Date: Mon, 12 Jan 2015 20:49:29 +0100 Subject: [PATCH 1/2] allow expr printing when -D hscriptPos is set --- hscript/Printer.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hscript/Printer.hx b/hscript/Printer.hx index 7ae3d33..6189eda 100644 --- a/hscript/Printer.hx +++ b/hscript/Printer.hx @@ -64,12 +64,12 @@ class Printer { } } - function expr( e : Expr) { + function expr( e : Expr ) { if( e == null ) { add("??NULL??"); return; } - switch( e ) { + switch( #if hscriptPos e.e #else e #end ) { case EConst(c): switch( c ) { case CInt(i): add(i); @@ -119,7 +119,7 @@ class Printer { case ECall(e, args): if( e == null ) expr(e); - else switch( e ) { + else switch( #if hscriptPos e.e #else e #end ) { case EField(_), EIdent(_), EConst(_): expr(e); default: From 287ff751cf71a808e7e86c3ba0abdc2c11a01eae Mon Sep 17 00:00:00 2001 From: Zjnue Brzavi Date: Mon, 12 Jan 2015 20:51:23 +0100 Subject: [PATCH 2/2] ensure if cond expr is surrounded by brackets --- hscript/Parser.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 2f63bbf..3ea9e38 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -434,7 +434,9 @@ class Parser { #end return switch( id ) { case "if": + ensure(TPOpen); var cond = parseExpr(); + ensure(TPClose); var e1 = parseExpr(); var e2 = null; var semic = false;