From 5a31b0886ca36364c34ed04011bcdac211bb5bd7 Mon Sep 17 00:00:00 2001 From: André Aparício Date: Fri, 27 Jul 2012 04:02:20 +0100 Subject: Parser: Multiline string declaration Support quoted strings line breaks in builtin variable definitions --- bashast/bashast.g | 9 ++++++++- scripts/command_execution.bash | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 4438b8c..0d59e8c 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -466,15 +466,22 @@ array_atom builtin_variable_definition_item scope { int parens; +#ifdef OUTPUT_C + bool dquotes; +#else + boolean dquotes; +#endif } @init { $builtin_variable_definition_item::parens = 0; + $builtin_variable_definition_item::dquotes = false; } : ( (LPAREN) => LPAREN { ++$builtin_variable_definition_item::parens; } |(RPAREN) => RPAREN { --$builtin_variable_definition_item::parens; } + |(DQUOTE) => DQUOTE { $builtin_variable_definition_item::dquotes = ! $builtin_variable_definition_item::dquotes; } |(~(EOL|SEMIC)) => expansion_base - | {LA(1) == EOL && $builtin_variable_definition_item::parens > 0}? => EOL + | {LA(1) == EOL && $builtin_variable_definition_item::parens > 0 || $builtin_variable_definition_item::dquotes}? => EOL )+; #ifdef OUTPUT_C diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash index c526d75..ca8a4e5 100644 --- a/scripts/command_execution.bash +++ b/scripts/command_execution.bash @@ -82,6 +82,20 @@ echo ${array[@]} ech\ o Hello\ world +function multiline() +{ + declare var1="foo +bar" + export var2="one + two +three" + local var3="foo +bar" + echo $var1 + echo $var2 + echo $var3 +} +multiline echo \`\(\)\$\>\<\` export SRC_URI="${SRC_URI} http://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}" > /dev/null -- cgit v1.2.3-65-gdbad