From c6ebf85e717075af5c3c089f4ceef8ebe4061d54 Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 25 Aug 2023 01:51:45 +0300 Subject: [PATCH] Revamp `@define` #140 --- docs/revamp_define.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/revamp_define.md b/docs/revamp_define.md index f1befd9..823b8c3 100644 --- a/docs/revamp_define.md +++ b/docs/revamp_define.md @@ -4,6 +4,7 @@ @define ENV_VAR "$ENV_VAR" @define ENV_VAR_WITH_DEFAULT "${ENV_VAR:-default_val}" @define HELLO 'hello' +@define HELLO1 $'hello' @define HW "$HELLO world" ``` @@ -140,4 +141,26 @@ Now this is achieved by $ export VAR=hello $ ./makesure ``` + +## Q. How do we know when to parse with `'`/`$'`/`"` - quoted strings or unquoted? + +Lets defile string quoting types: + +- `u` for `string` +- `'` for `'string'` +- `$` for `$'string'` +- `"` for `"string"` + + +We need to parse two cases separately + +- `@define VAR "value"` + - allowing only unquoted in 1st and 2nd position and any quote in 3rd +- All others re-parsed cases like + - `@goal $'goal name' @params A B @private` + - `u'$` in 2nd, `u` in all other pos + - `@depends_on $'goal name' 'goal name2'` + - `u'$` in 2+ pos + - `@depends_on $'goal name' @args A 'literal' $'literal2'` + - `u'$` in 2nd, `u'$` in 4+