From 6b75ff0ac9aef784a95f19403334024cc3ae1037 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Sun, 16 Jun 2013 05:34:57 +0400 Subject: [PATCH] Describe lvar-injecting matches in AST_FORMAT (refs #69). --- doc/AST_FORMAT.md | 67 ++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/doc/AST_FORMAT.md b/doc/AST_FORMAT.md index f38b2c038..8dfb4957d 100644 --- a/doc/AST_FORMAT.md +++ b/doc/AST_FORMAT.md @@ -1,11 +1,6 @@ AST and Source Location RFC =========================== -## Open questions: - - * Should we handle these cases at all? They do not have special syntax associated. - 1. How to handle lvar-injecting match (`if /(?foo)/ =~ bar`)? - ## Literals ### Singletons @@ -363,31 +358,6 @@ Format: ~~~~~~~~~~~ expression ~~~ -### Flip-flops - -Format: - -~~~ -(iflipflop (lvar :a) (lvar :b)) -"if a..b; end" - ~~ operator - ~~~~ expression - -(eflipflop (lvar :a) (lvar :b)) -"if a...b; end" - ~~~ operator - ~~~~~ expression -~~~ - -### Implicit matches - -Format: - -~~~ -(match-current-line (regexp (str "a") (regopt))) -"if /a/; end" -~~~ - ## Assignment ### To local variable @@ -1463,3 +1433,40 @@ Format: ~~~~~~~~~~~~~~~~~~ expression ~~~ +## Miscellanea + +### Flip-flops + +Format: + +~~~ +(iflipflop (lvar :a) (lvar :b)) +"if a..b; end" + ~~ operator + ~~~~ expression + +(eflipflop (lvar :a) (lvar :b)) +"if a...b; end" + ~~~ operator + ~~~~~ expression +~~~ + +### Implicit matches + +Format: + +~~~ +(match-current-line (regexp (str "a") (regopt))) +"if /a/; end" +~~~ + +### Local variable injecting matches + +Format: + +~~~ +(match-with-lvasgn (regexp (str "(?bar)") (regopt)) (lvar :baz)) +"/(?bar)/ =~ baz" + ~~ selector + ~~~~~~~~~~~~~~~~~~~~~~ expression +~~~