From 79bd3c01377f0b7c2b7dc8e97e5890fd2dc7ec41 Mon Sep 17 00:00:00 2001 From: Sawyer X Date: Mon, 30 May 2022 16:17:27 +0200 Subject: [PATCH] Add more comments to help understand the BNF --- lib/Guacamole.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/Guacamole.pm b/lib/Guacamole.pm index e010ca9..b9c88c3 100644 --- a/lib/Guacamole.pm +++ b/lib/Guacamole.pm @@ -148,10 +148,23 @@ ConditionForeachPostfixExpr ::= ConditionForeach Expression Label ::= IdentComp Colon # this is based on the order of ops in `perldoc perlop` -# U can be LHS of shift and up -# 0 can be LHS of assignment and up -# L can be LHS of comma and up -# R can be LHS of anything +# U can be LHS of shift and up (value) << >> +# 0 can be LHS of assignment and up (value or unary) = += -= *= +# L can be LHS of comma and up (value, assign, unary) , => +# R can be LHS of anything (value, list, assign, unary) (anything) + +# There are four types of keywords: +# * Nullary (This is "OpNullaryKeywordExpr" -> Value") +# * Unary (This is "OpUnaryKeywordExpr") +# * Assign (This is "OpAssignKeywordExpr") +# * List (This is "OpListKeywordExpr") + +# Hence, there are four types of expressions: +# ExprValueU: Those that are just values +# ExprValue0: Those that are values, and unary keywords +# ExprValueL: Those that are values, assignment keywords (+ goto,last,next,redo,dump), or unary keywords +# ExprValueR: Those that are values, list, assigment, or unary + ExprValueU ::= Value ExprValue0 ::= Value | OpUnaryKeywordExpr ExprValueL ::= Value | OpAssignKeywordExpr | OpUnaryKeywordExpr