From d7e853b87c91ccb9a74ef706f70288866f854cf1 Mon Sep 17 00:00:00 2001 From: fpirsch Date: Sat, 12 Jan 2013 18:59:49 +0100 Subject: [PATCH] Fix automatic semi-colon insertion Fix automatic semi-colon insertion in var statements without initialisers. var i i = 1; is valid and not accepted by the parser but var i = 2 i = 3; is valid and accepted by the parser, as it should be. With this fix, both are accepted. --- examples/javascript.pegjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/javascript.pegjs b/examples/javascript.pegjs index e42333c..8a22b7d 100644 --- a/examples/javascript.pegjs +++ b/examples/javascript.pegjs @@ -1164,20 +1164,20 @@ VariableDeclarationListNoIn } VariableDeclaration - = name:Identifier __ value:Initialiser? { + = name:Identifier value:(__ Initialiser)? { return { type: "VariableDeclaration", name: name, - value: value !== "" ? value : null + value: value !== "" ? value[1] : null }; } VariableDeclarationNoIn - = name:Identifier __ value:InitialiserNoIn? { + = name:Identifier value:(__ InitialiserNoIn)? { return { type: "VariableDeclaration", name: name, - value: value !== "" ? value : null + value: value !== "" ? value[1] : null }; }