Closed kamil-rogon-dragon closed 4 years ago
Working example. Mixing identifier with nested array.
resource "test_resource" "this" { users = setunion( test_resource.other.users, [ "string1", "string2", ], ) } resource "test_resource" "other" { users = [] }
Failing with only difference that nested array is at position 3 of function identifier instead of position 2 as above.
resource "test_resource" "this" { users = setunion( test_resource.other.users, test_resource.other.users, [ "string1", "string2", ], ) } resource "test_resource" "other" { users = [] }
Working example. Empty nested arrays without mixing with identifiers.
resource "test_resource" "this" { users = setunion( [], [], [], [], ) }
Failing example. Single nested array.
resource "test_resource" "this" { users = setunion([]) }
Failing example. Putting identifier after the nested array.
resource "test_resource" "this" { users = setunion( [], test_resource.other.users, ) } resource "test_resource" "other" { users = [] }
PLY: PARSE DEBUG START State : 0 Stack : . LexToken(IDENTIFIER,'resource',1,0) Action : Shift and goto state 8 State : 8 Stack : IDENTIFIER . LexToken(STRING,'test_resource',1,23) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x106fcf830> ('resource') State : 5 Stack : objectkey . LexToken(STRING,'test_resource',1,23) Action : Shift and goto state 7 State : 7 Stack : objectkey STRING . LexToken(STRING,'this',1,30) Action : Reduce rule [objectkey -> STRING] with ['test_resource'] and goto state 19 p_objectkey_0: None | test_resource Result : <str @ 0x106e80f70> ('test_resource') State : 19 Stack : objectkey objectkey . LexToken(STRING,'this',1,30) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey STRING . LexToken(LEFTBRACE,'{',1,32) Action : Reduce rule [objectkey -> STRING] with ['this'] and goto state 19 p_objectkey_0: None | this Result : <str @ 0x106f115b0> ('this') State : 19 Stack : objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',1,32) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'users',2,36) Action : Shift and goto state 8 State : 8 Stack : objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',2,42) Action : Reduce rule [objectkey -> IDENTIFIER] with ['users'] and goto state 5 p_objectkey_0: None | users Result : <str @ 0x106ed40b0> ('users') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',2,42) Action : Shift and goto state 20 State : 20 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(IDENTIFIER,'setunion',2,44) Action : Shift and goto state 44 State : 44 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER . LexToken(LEFTPAREN,'(',2,52) Action : Shift and goto state 91 State : 91 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN . LexToken(IDENTIFIER,'test_resource.other',3,58) Action : Shift and goto state 100 State : 100 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN IDENTIFIER . LexToken(COMMA,',',3,77) Action : Reduce rule [objectkey -> IDENTIFIER] with [<str @ 0x106f7c2b0>] and goto state 98 p_objectkey_0: None | test_resource.other Result : <str @ 0x106f7c2b0> ('test_resource.other') State : 98 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey . LexToken(COMMA,',',3,77) Action : Shift and goto state 132 State : 132 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA . LexToken(LEFTBRACKET,'[',4,83) Action : Shift and goto state 50 State : 50 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET . LexToken(STRING,'string1',5,99) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET STRING . LexToken(COMMA,',',5,100) Action : Reduce rule [objectkey -> STRING] with ['string1'] and goto state 98 p_objectkey_0: None | string1 Result : <str @ 0x106ef8df0> ('string1') State : 98 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET objectkey . LexToken(COMMA,',',5,100) Action : Shift and goto state 132 State : 132 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET objectkey COMMA . LexToken(STRING,'string2',6,116) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET objectkey COMMA STRING . LexToken(COMMA,',',6,117) Action : Reduce rule [objectkey -> STRING] with ['string2'] and goto state 165 p_objectkey_0: None | string2 Result : <str @ 0x106ef8630> ('string2') State : 165 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET objectkey COMMA objectkey . LexToken(COMMA,',',6,117) Action : Reduce rule [listitems -> objectkey COMMA objectkey] with ['string1',',','string2'] and goto state 93 p_listitems_2: None | string1 | , | string2 Result : <list @ 0x106f11100> (['string1', 'string2']) State : 93 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET listitems . LexToken(COMMA,',',6,117) Action : Shift and goto state 130 State : 130 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET listitems COMMA . LexToken(RIGHTBRACKET,']',7,123) Action : Shift and goto state 156 State : 156 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA LEFTBRACKET listitems COMMA RIGHTBRACKET . LexToken(COMMA,',',7,124) Action : Reduce rule [list -> LEFTBRACKET listitems COMMA RIGHTBRACKET] with ['[',<list @ 0x106f11100>,',',']'] and goto state 167 p_list_0: None | [ | ['string1', 'string2'] | , | ] Result : <list @ 0x106f11100> (['string1', 'string2']) State : 167 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA list . LexToken(COMMA,',',7,124) Action : Reduce rule [listitems -> objectkey COMMA list] with [<str @ 0x106f7c2b0>,',',<list @ 0x106f11100>] and goto state 121 p_listitems_2: None | test_resource.other | , | ['string1', 'string2'] Result : <list @ 0x106ec7380> (['test_resource.other', ['string1', 'str ...) State : 121 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems . LexToken(COMMA,',',7,124) Action : Shift and goto state 145 State : 145 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems COMMA . LexToken(RIGHTPAREN,')',8,128) Action : Shift and goto state 187 State : 187 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems COMMA RIGHTPAREN . LexToken(RIGHTBRACE,'}',9,130) Action : Reduce rule [function -> IDENTIFIER LEFTPAREN listitems COMMA RIGHTPAREN] with ['setunion','(',<list @ 0x106ec7380>,',',')'] and goto state 48 p_function_1: None | setunion | ( | ['test_resource.other', ['string1', 'string2']] | , | ) Result : <str @ 0x106f853b0> ('setunion(test_resource.other,"string1", ...) State : 48 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL function . LexToken(RIGHTBRACE,'}',9,130) Action : Reduce rule [objectitem -> objectkey EQUAL function] with ['users','=',<str @ 0x106f853b0>] and goto state 4 p_objectitem_0: None | users | = | setunion(test_resource.other,"string1","string2") Result : <tuple @ 0x106ff44c0> (('users', 'setunion(test_resource.other, ...) State : 4 Stack : objectkey objectkey objectkey LEFTBRACE objectitem . LexToken(RIGHTBRACE,'}',9,130) Action : Reduce rule [objectlist -> objectitem] with [<tuple @ 0x106ff44c0>] and goto state 61 p_objectlist_0: None | ('users', 'setunion(test_resource.other,"string1","string2")') Result : <list @ 0x106ec7380> ([('users', 'setunion(test_resource.other ...) State : 61 Stack : objectkey objectkey objectkey LEFTBRACE objectlist . LexToken(RIGHTBRACE,'}',9,130) Action : Shift and goto state 105 State : 105 Stack : objectkey objectkey objectkey LEFTBRACE objectlist RIGHTBRACE . LexToken(IDENTIFIER,'resource',11,133) Action : Reduce rule [object -> LEFTBRACE objectlist RIGHTBRACE] with ['{',<list @ 0x106ec7380>,'}'] and goto state 21 p_object_0: None | { | [('users', 'setunion(test_resource.other,"string1","string2")')] | } Result : <dict @ 0x106e792c0> ({'users': 'setunion(test_resource.other, ...) State : 21 Stack : objectkey objectkey objectkey object . LexToken(IDENTIFIER,'resource',11,133) Action : Reduce rule [block -> objectkey object] with ['this',<dict @ 0x106e792c0>] and goto state 23 p_block_0: None | this | {'users': 'setunion(test_resource.other,"string1","string2")'} Result : <tuple @ 0x106ff44c0> (('this', {'users': 'setunion(test_resour ...) State : 23 Stack : objectkey objectkey block . LexToken(IDENTIFIER,'resource',11,133) Action : Reduce rule [block -> objectkey block] with ['test_resource',<tuple @ 0x106ff44c0>] and goto state 23 p_block_1: None | test_resource | ('this', {'users': 'setunion(test_resource.other,"string1","string2")'}) Result : <tuple @ 0x106ff4280> (('test_resource', {'this': {'users': 'se ...) State : 23 Stack : objectkey block . LexToken(IDENTIFIER,'resource',11,133) Action : Reduce rule [block -> objectkey block] with ['resource',<tuple @ 0x106ff4280>] and goto state 9 p_block_1: None | resource | ('test_resource', {'this': {'users': 'setunion(test_resource.other,"string1","string2")'}}) Result : <tuple @ 0x106ff44c0> (('resource', {'test_resource': {'this': ...) State : 9 Stack : block . LexToken(IDENTIFIER,'resource',11,133) Action : Reduce rule [objectitem -> block] with [<tuple @ 0x106ff44c0>] and goto state 4 p_objectitem_1: None | ('resource', {'test_resource': {'this': {'users': 'setunion(test_resource.other,"string1","string2")'}}}) Result : <tuple @ 0x106ff44c0> (('resource', {'test_resource': {'this': ...) State : 4 Stack : objectitem . LexToken(IDENTIFIER,'resource',11,133) Action : Reduce rule [objectlist -> objectitem] with [<tuple @ 0x106ff44c0>] and goto state 3 p_objectlist_0: None | ('resource', {'test_resource': {'this': {'users': 'setunion(test_resource.other,"string1","string2")'}}}) Result : <list @ 0x106f11100> ([('resource', {'test_resource': {'this': ...) State : 3 Stack : objectlist . LexToken(IDENTIFIER,'resource',11,133) Action : Shift and goto state 8 State : 8 Stack : objectlist IDENTIFIER . LexToken(STRING,'test_resource',11,156) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x106ef8df0> ('resource') State : 5 Stack : objectlist objectkey . LexToken(STRING,'test_resource',11,156) Action : Shift and goto state 7 State : 7 Stack : objectlist objectkey STRING . LexToken(STRING,'other',11,164) Action : Reduce rule [objectkey -> STRING] with ['test_resource'] and goto state 19 p_objectkey_0: None | test_resource Result : <str @ 0x106ef8630> ('test_resource') State : 19 Stack : objectlist objectkey objectkey . LexToken(STRING,'other',11,164) Action : Shift and goto state 7 State : 7 Stack : objectlist objectkey objectkey STRING . LexToken(LEFTBRACE,'{',11,166) Action : Reduce rule [objectkey -> STRING] with ['other'] and goto state 19 p_objectkey_0: None | other Result : <str @ 0x106ed43f0> ('other') State : 19 Stack : objectlist objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',11,166) Action : Shift and goto state 24 State : 24 Stack : objectlist objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'users',12,170) Action : Shift and goto state 8 State : 8 Stack : objectlist objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',12,176) Action : Reduce rule [objectkey -> IDENTIFIER] with ['users'] and goto state 5 p_objectkey_0: None | users Result : <str @ 0x106ed44f0> ('users') State : 5 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',12,176) Action : Shift and goto state 20 State : 20 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(LEFTBRACKET,'[',12,178) Action : Shift and goto state 50 State : 50 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectkey EQUAL LEFTBRACKET . LexToken(RIGHTBRACKET,']',12,179) Action : Shift and goto state 94 State : 94 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectkey EQUAL LEFTBRACKET RIGHTBRACKET . LexToken(RIGHTBRACE,'}',13,181) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 46 p_list_1: None | [ | ] Result : <list @ 0x106fbd800> ([]) State : 46 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectkey EQUAL list . LexToken(RIGHTBRACE,'}',13,181) Action : Reduce rule [objectitem -> objectkey EQUAL list] with ['users','=',[]] and goto state 4 p_objectitem_0: None | users | = | [] Result : <tuple @ 0x106ff4280> (('users', [])) State : 4 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectitem . LexToken(RIGHTBRACE,'}',13,181) Action : Reduce rule [objectlist -> objectitem] with [('users', [])] and goto state 61 p_objectlist_0: None | ('users', []) Result : <list @ 0x106fce700> ([('users', [])]) State : 61 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectlist . LexToken(RIGHTBRACE,'}',13,181) Action : Shift and goto state 105 State : 105 Stack : objectlist objectkey objectkey objectkey LEFTBRACE objectlist RIGHTBRACE . $end Action : Reduce rule [object -> LEFTBRACE objectlist RIGHTBRACE] with ['{',[('users', [])],'}'] and goto state 21 p_object_0: None | { | [('users', [])] | } Result : <dict @ 0x106ec9400> ({'users': []}) State : 21 Stack : objectlist objectkey objectkey objectkey object . $end Action : Reduce rule [block -> objectkey object] with ['other',{'users': []}] and goto state 23 p_block_0: None | other | {'users': []} Result : <tuple @ 0x106ff4280> (('other', {'users': []})) State : 23 Stack : objectlist objectkey objectkey block . $end Action : Reduce rule [block -> objectkey block] with ['test_resource',<tuple @ 0x106ff4280>] and goto state 23 p_block_1: None | test_resource | ('other', {'users': []}) Result : <tuple @ 0x106fef700> (('test_resource', {'other': {'users': [] ...) State : 23 Stack : objectlist objectkey block . $end Action : Reduce rule [block -> objectkey block] with ['resource',<tuple @ 0x106fef700>] and goto state 9 p_block_1: None | resource | ('test_resource', {'other': {'users': []}}) Result : <tuple @ 0x106ff4280> (('resource', {'test_resource': {'other': ...) State : 9 Stack : objectlist block . $end Action : Reduce rule [objectitem -> block] with [<tuple @ 0x106ff4280>] and goto state 17 p_objectitem_1: None | ('resource', {'test_resource': {'other': {'users': []}}}) Result : <tuple @ 0x106ff4280> (('resource', {'test_resource': {'other': ...) State : 17 Stack : objectlist objectitem . $end Action : Reduce rule [objectlist -> objectlist objectitem] with [<list @ 0x106f11100>,<tuple @ 0x106ff4280>] and goto state 3 p_objectlist_1: None | [('resource', {'test_resource': {'this': {'users': 'setunion(test_resource.other,"string1","string2")'}}})] | ('resource', {'test_resource': {'other': {'users': []}}}) Result : <list @ 0x106ec7380> ([('resource', {'test_resource': {'this': ...) State : 3 Stack : objectlist . $end Action : Reduce rule [top -> objectlist] with [<list @ 0x106ec7380>] and goto state 1 p_top: None | [('resource', {'test_resource': {'this': {'users': 'setunion(test_resource.other,"string1","string2")'}}}), ('resource', {'test_resource': {'other': {'users': []}}})] Result : <dict @ 0x106ec9f80> ({'resource': {'test_resource': {'this': ...) State : 1 Stack : top . $end Done : Returning <dict @ 0x106ec9f80> ({'resource': {'test_resource': {'this': ...) PLY: PARSE DEBUG END <dict at 0x106ec9f80>: resource: <dict at 0x106ec90c0> test_resource: <dict at 0x106ec9200> this: <str at 0x106f83330>: '{\'users\': \'setunion(test_resource.other,"string1","string2")\'}' other: <dict at 0x106ec9400> users: []
PLY: PARSE DEBUG START State : 0 Stack : . LexToken(IDENTIFIER,'resource',1,0) Action : Shift and goto state 8 State : 8 Stack : IDENTIFIER . LexToken(STRING,'test_resource',1,23) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x101cb6d30> ('resource') State : 5 Stack : objectkey . LexToken(STRING,'test_resource',1,23) Action : Shift and goto state 7 State : 7 Stack : objectkey STRING . LexToken(STRING,'this',1,30) Action : Reduce rule [objectkey -> STRING] with ['test_resource'] and goto state 19 p_objectkey_0: None | test_resource Result : <str @ 0x101de20b0> ('test_resource') State : 19 Stack : objectkey objectkey . LexToken(STRING,'this',1,30) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey STRING . LexToken(LEFTBRACE,'{',1,32) Action : Reduce rule [objectkey -> STRING] with ['this'] and goto state 19 p_objectkey_0: None | this Result : <str @ 0x101da4f30> ('this') State : 19 Stack : objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',1,32) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'users',2,36) Action : Shift and goto state 8 State : 8 Stack : objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',2,42) Action : Reduce rule [objectkey -> IDENTIFIER] with ['users'] and goto state 5 p_objectkey_0: None | users Result : <str @ 0x101dc9770> ('users') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',2,42) Action : Shift and goto state 20 State : 20 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(IDENTIFIER,'setunion',2,44) Action : Shift and goto state 44 State : 44 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER . LexToken(LEFTPAREN,'(',2,52) Action : Shift and goto state 91 State : 91 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN . LexToken(IDENTIFIER,'test_resource.other',3,58) Action : Shift and goto state 100 State : 100 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN IDENTIFIER . LexToken(COMMA,',',3,77) Action : Reduce rule [objectkey -> IDENTIFIER] with [<str @ 0x101e54210>] and goto state 98 p_objectkey_0: None | test_resource.other Result : <str @ 0x101e54210> ('test_resource.other') State : 98 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey . LexToken(COMMA,',',3,77) Action : Shift and goto state 132 State : 132 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA . LexToken(IDENTIFIER,'test_resource.other',4,83) Action : Shift and goto state 168 State : 168 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA IDENTIFIER . LexToken(COMMA,',',4,102) Action : Reduce rule [objectkey -> IDENTIFIER] with [<str @ 0x101e54260>] and goto state 165 p_objectkey_0: None | test_resource.other Result : <str @ 0x101e54260> ('test_resource.other') State : 165 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN objectkey COMMA objectkey . LexToken(COMMA,',',4,102) Action : Reduce rule [listitems -> objectkey COMMA objectkey] with [<str @ 0x101e54210>,',',<str @ 0x101e54260>] and goto state 121 p_listitems_2: None | test_resource.other | , | test_resource.other Result : <list @ 0x101d9b380> (['test_resource.other', 'test_resource.o ...) State : 121 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems . LexToken(COMMA,',',4,102) Action : Shift and goto state 145 State : 145 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems COMMA . LexToken(LEFTBRACKET,'[',5,108) ERROR: Error : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems COMMA . LexToken(LEFTBRACKET,'[',5,108) Traceback (most recent call last): File "test.py", line 7, in <module> obj = hcl.load(file) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/api.py", line 62, in load return loads(fp.read(), export_comments=export_comments) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/api.py", line 81, in loads return HclParser().parse(s, export_comments=export_comments) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/parser.py", line 642, in parse return self.yacc.parse( File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/ply/yacc.py", line 503, in parse tok = self.errorfunc(errtoken) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/parser.py", line 634, in p_error raise ValueError(msg) ValueError: Line 5, column 108: unexpected LEFTBRACKET; expected RIGHTPAREN, COMMENT, MULTICOMMENT, IDENTIFIER, STRING, LEFTBRACE, MINUS, NUMBER, FLOAT
PLY: PARSE DEBUG START State : 0 Stack : . LexToken(IDENTIFIER,'resource',1,0) Action : Shift and goto state 8 State : 8 Stack : IDENTIFIER . LexToken(STRING,'test_resource',1,23) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x104917df0> ('resource') State : 5 Stack : objectkey . LexToken(STRING,'test_resource',1,23) Action : Shift and goto state 7 State : 7 Stack : objectkey STRING . LexToken(STRING,'this',1,30) Action : Reduce rule [objectkey -> STRING] with ['test_resource'] and goto state 19 p_objectkey_0: None | test_resource Result : <str @ 0x1047c8eb0> ('test_resource') State : 19 Stack : objectkey objectkey . LexToken(STRING,'this',1,30) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey STRING . LexToken(LEFTBRACE,'{',1,32) Action : Reduce rule [objectkey -> STRING] with ['this'] and goto state 19 p_objectkey_0: None | this Result : <str @ 0x1048593b0> ('this') State : 19 Stack : objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',1,32) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'users',2,36) Action : Shift and goto state 8 State : 8 Stack : objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',2,42) Action : Reduce rule [objectkey -> IDENTIFIER] with ['users'] and goto state 5 p_objectkey_0: None | users Result : <str @ 0x10481cf30> ('users') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',2,42) Action : Shift and goto state 20 State : 20 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(IDENTIFIER,'setunion',2,44) Action : Shift and goto state 44 State : 44 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER . LexToken(LEFTPAREN,'(',2,52) Action : Shift and goto state 91 State : 91 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN . LexToken(LEFTBRACKET,'[',3,58) Action : Shift and goto state 124 State : 124 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACKET . LexToken(RIGHTBRACKET,']',3,59) Action : Shift and goto state 94 State : 94 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACKET RIGHTBRACKET . LexToken(COMMA,',',3,60) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 123 p_list_1: None | [ | ] Result : <list @ 0x104852980> ([]) State : 123 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list . LexToken(COMMA,',',3,60) Action : Shift and goto state 149 State : 149 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list COMMA . LexToken(LEFTBRACKET,'[',4,66) Action : Shift and goto state 50 State : 50 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list COMMA LEFTBRACKET . LexToken(RIGHTBRACKET,']',4,67) Action : Shift and goto state 94 State : 94 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list COMMA LEFTBRACKET RIGHTBRACKET . LexToken(COMMA,',',4,68) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 191 p_list_1: None | [ | ] Result : <list @ 0x104905600> ([]) State : 191 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list COMMA list . LexToken(COMMA,',',4,68) Action : Reduce rule [list_of_lists -> list COMMA list] with [[],',',[]] and goto state 122 p_list_of_lists_0: None | [] | , | [] Result : <tuple @ 0x10493c440> (([], [])) State : 122 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists . LexToken(COMMA,',',4,68) Action : Shift and goto state 147 State : 147 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA . LexToken(LEFTBRACKET,'[',5,74) Action : Shift and goto state 50 State : 50 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA LEFTBRACKET . LexToken(RIGHTBRACKET,']',5,75) Action : Shift and goto state 94 State : 94 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA LEFTBRACKET RIGHTBRACKET . LexToken(COMMA,',',5,76) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 189 p_list_1: None | [ | ] Result : <list @ 0x10480f200> ([]) State : 189 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA list . LexToken(COMMA,',',5,76) Action : Reduce rule [list_of_lists -> list_of_lists COMMA list] with [([], []),',',[]] and goto state 122 p_list_of_lists_1: None | ([], []) | , | [] Result : <tuple @ 0x1049195c0> (([], [], [])) State : 122 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists . LexToken(COMMA,',',5,76) Action : Shift and goto state 147 State : 147 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA . LexToken(LEFTBRACKET,'[',6,82) Action : Shift and goto state 50 State : 50 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA LEFTBRACKET . LexToken(RIGHTBRACKET,']',6,83) Action : Shift and goto state 94 State : 94 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA LEFTBRACKET RIGHTBRACKET . LexToken(COMMA,',',6,84) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 189 p_list_1: None | [ | ] Result : <list @ 0x104905cc0> ([]) State : 189 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA list . LexToken(COMMA,',',6,84) Action : Reduce rule [list_of_lists -> list_of_lists COMMA list] with [([], [], []),',',[]] and goto state 122 p_list_of_lists_1: None | ([], [], []) | , | [] Result : <tuple @ 0x10480b1d0> (([], [], [], [])) State : 122 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists . LexToken(COMMA,',',6,84) Action : Shift and goto state 147 State : 147 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA . LexToken(RIGHTPAREN,')',7,88) Action : Shift and goto state 188 State : 188 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list_of_lists COMMA RIGHTPAREN . LexToken(RIGHTBRACE,'}',8,90) Action : Reduce rule [function -> IDENTIFIER LEFTPAREN list_of_lists COMMA RIGHTPAREN] with ['setunion','(',<tuple @ 0x10480b1d0>,',',')'] and goto state 48 p_function_1: None | setunion | ( | ([], [], [], []) | , | ) Result : <str @ 0x1047c8fb0> ('setunion( )') State : 48 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL function . LexToken(RIGHTBRACE,'}',8,90) Action : Reduce rule [objectitem -> objectkey EQUAL function] with ['users','=','setunion( )'] and goto state 4 p_objectitem_0: None | users | = | setunion( ) Result : <tuple @ 0x10493c440> (('users', 'setunion( )')) State : 4 Stack : objectkey objectkey objectkey LEFTBRACE objectitem . LexToken(RIGHTBRACE,'}',8,90) Action : Reduce rule [objectlist -> objectitem] with [<tuple @ 0x10493c440>] and goto state 61 p_objectlist_0: None | ('users', 'setunion( )') Result : <list @ 0x104852980> ([('users', 'setunion( )')]) State : 61 Stack : objectkey objectkey objectkey LEFTBRACE objectlist . LexToken(RIGHTBRACE,'}',8,90) Action : Shift and goto state 105 State : 105 Stack : objectkey objectkey objectkey LEFTBRACE objectlist RIGHTBRACE . $end Action : Reduce rule [object -> LEFTBRACE objectlist RIGHTBRACE] with ['{',<list @ 0x104852980>,'}'] and goto state 21 p_object_0: None | { | [('users', 'setunion( )')] | } Result : <dict @ 0x104811080> ({'users': 'setunion( )'}) State : 21 Stack : objectkey objectkey objectkey object . $end Action : Reduce rule [block -> objectkey object] with ['this',<dict @ 0x104811080>] and goto state 23 p_block_0: None | this | {'users': 'setunion( )'} Result : <tuple @ 0x10493c440> (('this', {'users': 'setunion( )'})) State : 23 Stack : objectkey objectkey block . $end Action : Reduce rule [block -> objectkey block] with ['test_resource',<tuple @ 0x10493c440>] and goto state 23 p_block_1: None | test_resource | ('this', {'users': 'setunion( )'}) Result : <tuple @ 0x10493c200> (('test_resource', {'this': {'users': 'se ...) State : 23 Stack : objectkey block . $end Action : Reduce rule [block -> objectkey block] with ['resource',<tuple @ 0x10493c200>] and goto state 9 p_block_1: None | resource | ('test_resource', {'this': {'users': 'setunion( )'}}) Result : <tuple @ 0x10493c440> (('resource', {'test_resource': {'this': ...) State : 9 Stack : block . $end Action : Reduce rule [objectitem -> block] with [<tuple @ 0x10493c440>] and goto state 4 p_objectitem_1: None | ('resource', {'test_resource': {'this': {'users': 'setunion( )'}}}) Result : <tuple @ 0x10493c440> (('resource', {'test_resource': {'this': ...) State : 4 Stack : objectitem . $end Action : Reduce rule [objectlist -> objectitem] with [<tuple @ 0x10493c440>] and goto state 3 p_objectlist_0: None | ('resource', {'test_resource': {'this': {'users': 'setunion( )'}}}) Result : <list @ 0x104905600> ([('resource', {'test_resource': {'this': ...) State : 3 Stack : objectlist . $end Action : Reduce rule [top -> objectlist] with [<list @ 0x104905600>] and goto state 1 p_top: None | [('resource', {'test_resource': {'this': {'users': 'setunion( )'}}})] Result : <dict @ 0x104811640> ({'resource': {'test_resource': {'this': ...) State : 1 Stack : top . $end Done : Returning <dict @ 0x104811640> ({'resource': {'test_resource': {'this': ...) PLY: PARSE DEBUG END <dict at 0x104811640>: resource: <dict at 0x10473b340> test_resource: <dict at 0x104811ec0> this: <str at 0x1048c4210>: "{'users': 'setunion( )'}"
PLY: PARSE DEBUG START State : 0 Stack : . LexToken(IDENTIFIER,'resource',1,0) Action : Shift and goto state 8 State : 8 Stack : IDENTIFIER . LexToken(STRING,'test_resource',1,23) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x10d2917f0> ('resource') State : 5 Stack : objectkey . LexToken(STRING,'test_resource',1,23) Action : Shift and goto state 7 State : 7 Stack : objectkey STRING . LexToken(STRING,'this',1,30) Action : Reduce rule [objectkey -> STRING] with ['test_resource'] and goto state 19 p_objectkey_0: None | test_resource Result : <str @ 0x10d143eb0> ('test_resource') State : 19 Stack : objectkey objectkey . LexToken(STRING,'this',1,30) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey STRING . LexToken(LEFTBRACE,'{',1,32) Action : Reduce rule [objectkey -> STRING] with ['this'] and goto state 19 p_objectkey_0: None | this Result : <str @ 0x10d1d43f0> ('this') State : 19 Stack : objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',1,32) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'users',2,36) Action : Shift and goto state 8 State : 8 Stack : objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',2,42) Action : Reduce rule [objectkey -> IDENTIFIER] with ['users'] and goto state 5 p_objectkey_0: None | users Result : <str @ 0x10d1977f0> ('users') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',2,42) Action : Shift and goto state 20 State : 20 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(IDENTIFIER,'setunion',2,44) Action : Shift and goto state 44 State : 44 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER . LexToken(LEFTPAREN,'(',2,52) Action : Shift and goto state 91 State : 91 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN . LexToken(LEFTBRACKET,'[',2,53) Action : Shift and goto state 124 State : 124 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACKET . LexToken(RIGHTBRACKET,']',2,54) Action : Shift and goto state 94 State : 94 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACKET RIGHTBRACKET . LexToken(RIGHTPAREN,')',2,55) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 123 p_list_1: None | [ | ] Result : <list @ 0x10d1cd840> ([]) State : 123 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list . LexToken(RIGHTPAREN,')',2,55) ERROR: Error : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list . LexToken(RIGHTPAREN,')',2,55) Traceback (most recent call last): File "test.py", line 7, in <module> obj = hcl.load(file) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/api.py", line 62, in load return loads(fp.read(), export_comments=export_comments) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/api.py", line 81, in loads return HclParser().parse(s, export_comments=export_comments) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/parser.py", line 642, in parse return self.yacc.parse( File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/ply/yacc.py", line 503, in parse tok = self.errorfunc(errtoken) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/parser.py", line 634, in p_error raise ValueError(msg) ValueError: Line 2, column 55: unexpected RIGHTPAREN; expected PERIOD, COMMA
PLY: PARSE DEBUG START State : 0 Stack : . LexToken(IDENTIFIER,'resource',1,0) Action : Shift and goto state 8 State : 8 Stack : IDENTIFIER . LexToken(STRING,'test_resource',1,23) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x10d6a1170> ('resource') State : 5 Stack : objectkey . LexToken(STRING,'test_resource',1,23) Action : Shift and goto state 7 State : 7 Stack : objectkey STRING . LexToken(STRING,'this',1,30) Action : Reduce rule [objectkey -> STRING] with ['test_resource'] and goto state 19 p_objectkey_0: None | test_resource Result : <str @ 0x10d4237f0> ('test_resource') State : 19 Stack : objectkey objectkey . LexToken(STRING,'this',1,30) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey STRING . LexToken(LEFTBRACE,'{',1,32) Action : Reduce rule [objectkey -> STRING] with ['this'] and goto state 19 p_objectkey_0: None | this Result : <str @ 0x10d463fb0> ('this') State : 19 Stack : objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',1,32) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'users',2,36) Action : Shift and goto state 8 State : 8 Stack : objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',2,42) Action : Reduce rule [objectkey -> IDENTIFIER] with ['users'] and goto state 5 p_objectkey_0: None | users Result : <str @ 0x10d663d70> ('users') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',2,42) Action : Shift and goto state 20 State : 20 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(IDENTIFIER,'setunion',2,44) Action : Shift and goto state 44 State : 44 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER . LexToken(LEFTPAREN,'(',2,52) Action : Shift and goto state 91 State : 91 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN . LexToken(LEFTBRACKET,'[',3,58) Action : Shift and goto state 124 State : 124 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACKET . LexToken(RIGHTBRACKET,']',3,59) Action : Shift and goto state 94 State : 94 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACKET RIGHTBRACKET . LexToken(COMMA,',',3,60) Action : Reduce rule [list -> LEFTBRACKET RIGHTBRACKET] with ['[',']'] and goto state 123 p_list_1: None | [ | ] Result : <list @ 0x10d69a180> ([]) State : 123 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list . LexToken(COMMA,',',3,60) Action : Shift and goto state 149 State : 149 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list COMMA . LexToken(IDENTIFIER,'test_resource.other.users',4,66) ERROR: Error : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN list COMMA . LexToken(IDENTIFIER,'test_resource.other.users',4,66) Traceback (most recent call last): File "pyhcl.py", line 7, in <module> obj = hcl.load(file) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/api.py", line 62, in load return loads(fp.read(), export_comments=export_comments) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/api.py", line 81, in loads return HclParser().parse(s, export_comments=export_comments) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/parser.py", line 642, in parse return self.yacc.parse( File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/ply/yacc.py", line 503, in parse tok = self.errorfunc(errtoken) File "/Users/kamil.rogon/Library/Python/3.8/lib/python/site-packages/hcl/parser.py", line 634, in p_error raise ValueError(msg) ValueError: Line 4, column 66: unexpected IDENTIFIER; expected RIGHTPAREN, COMMA, LEFTBRACKET, LEFTPAREN
parser doesn't support HCL2, try https://pypi.org/project/python-hcl2/ instead.
Examples
Example 1
Working example. Mixing identifier with nested array.
Example 2
Failing with only difference that nested array is at position 3 of function identifier instead of position 2 as above.
Example 3
Working example. Empty nested arrays without mixing with identifiers.
Example 4
Failing example. Single nested array.
Example 5
Failing example. Putting identifier after the nested array.
Debug
Example 1
Example 2
Example 3
Example 4
Example 5