aboutsummaryrefslogtreecommitdiff
blob: 1958836fc6340f2b6f86980eb516c2a10f850e2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
   Please use git log for copyright holder and year information

   This file is part of libbash.

   libbash is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 2 of the License, or
   (at your option) any later version.

   libbash is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with libbash.  If not, see <http://www.gnu.org/licenses/>.
*/
gunit java_libbash;

variable_definition_atom:
"asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))
"asdf=(`echo 6` b c d)"-> (= asdf (ARRAY (STRING (COMMAND_SUB `echo 6`)) (STRING b) (STRING c) (STRING d)))
"asdf=(${P} b c d)"->(= asdf (ARRAY (STRING (VAR_REF P)) (STRING b) (STRING c) (STRING d)))
"asdf=($(echo a))" -> (= asdf (ARRAY (STRING (COMMAND_SUB $(echo a)))))
"asdf=(
		--disable-dependency-tracking
		${VAR}
)" -> (= asdf (ARRAY (STRING - - disable - dependency - tracking) (STRING (VAR_REF VAR))))
"asdf=()" -> (= asdf ARRAY)
"asdf+=()" -> (PLUS_ASSIGN asdf ARRAY)
"asdf+=(a)" -> (PLUS_ASSIGN asdf (ARRAY (STRING a)))

builtin_variable_definitions:
"asdf=(a b c d) ade acd=bde" -> (LIST (COMMAND (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (EQUALS ade (STRING (VAR_REF ade))) (= acd (STRING bde)))))

builtin_variable_definition_item:
"local cmakeargs=(
    abc
    def
    ghi
)" -> "local   cmakeargs = ( \n      abc \n      def \n      ghi \n )"
"export cmakeargs=(
    abc
    def
    ghi
)" -> "export   cmakeargs = ( \n      abc \n      def \n      ghi \n )"

variable_reference:
"$asdf" -> (VAR_REF asdf)
"${asdf[0]:-default}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL (asdf (ARITHMETIC 0)) (STRING default)))
"${asdf[3]}" -> (VAR_REF (asdf (ARITHMETIC 3)))
"${asdf[4] }" -> (VAR_REF (asdf (ARITHMETIC 4)))
"${asdf[i*2]}" -> (VAR_REF (asdf (ARITHMETIC (* (VAR_REF i) 2))))
"${asdf[1]:2:2}" -> (VAR_REF (OFFSET (asdf (ARITHMETIC 1)) (OFFSET (ARITHMETIC 2)) (OFFSET (ARITHMETIC 2))))
"${asdf[2]##word}" -> (VAR_REF (REPLACE_AT_START (asdf (ARITHMETIC 2)) (STRING word)))
"${asdf[3]%%word}" -> (VAR_REF (REPLACE_AT_END (asdf (ARITHMETIC 3)) (STRING word)))
"${asdf[4]//pattern}" -> (VAR_REF (REPLACE_ALL (asdf (ARITHMETIC 4)) (STRING pattern)))
"${asdf}" -> (VAR_REF asdf)
"${#asdf[0]}" -> (VAR_REF (# (asdf 0)))
"${#asdf[ $i ]}" ->  (VAR_REF (# (asdf (ARITHMETIC (VAR_REF i)))))
"${asdf[@]}" -> (VAR_REF (ARRAY asdf @))
"${asdf[*]}" -> (VAR_REF (ARRAY asdf *))
"${#asdf[@]}" -> (VAR_REF (# (asdf ARRAY_SIZE)))
"${#asdf[*]}" -> (VAR_REF (# (asdf ARRAY_SIZE)))
"${asdf[@]:0:1}" -> (VAR_REF (OFFSET (ARRAY asdf @) (OFFSET (ARITHMETIC 0)) (OFFSET (ARITHMETIC 1))))
"${asdf[*]#path}" -> (VAR_REF (LAZY_REMOVE_AT_START (ARRAY asdf *) (STRING path)))
"${asdf[@]%word}" ->  (VAR_REF (LAZY_REMOVE_AT_END (ARRAY asdf @) (STRING word)))
"${asdf[*]/pattern/string}" -> (VAR_REF (REPLACE_FIRST (ARRAY asdf *) (STRING pattern) (STRING string)))