Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class ParserTest {
// This is a map with some nested maps and arrays within it, as well as some concatenations
qux {
baz: abc 123
biz: [element1, element2] [element3, element4]
buz: [prependelementtoarray] ${arrayref}
bar: {
baz: abcdefg
bar: {
Expand Down Expand Up @@ -118,7 +120,7 @@ class ParserTest {

@Test
def void testSubstitution() {
succeeds("${foo.bar} += ${akka.timeout}\n")
succeeds("foo.bar += ${akka.timeout}\n")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was incorrect. HOCON does not allow a substitution on the left site of a declaration.
I check myself - a play app for example with such a statement would not start up and fail with with a parse exception.

}

@Test
Expand Down
12 changes: 8 additions & 4 deletions com.typesafe.hocon/src/com/typesafe/config/Hocon.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ Member:
;

Literal:
(value += SimpleLiteral)+ | Object | Array ;
(value += SimpleLiteral)+ | Object | (value += Array)+ ;

SimpleLiteral returns EString:
(StringLiteral | name = Boolean | Null | NumberLiteral)
(StringLiteral | name = Boolean | Null | NumberLiteral | Substitution)
;

Array:
('[' NL*
(values+=Literal)
((',' | NL) NL* values+=Literal)*
NL*
']') | ( '[' NL* ']' )
']') | Substitution | ( '[' NL* ']' )
;

Boolean:
Expand All @@ -50,7 +50,11 @@ Null:


StringLiteral returns EString:
(name = STRING | name = UNQUOTED_STRING | '${' ('?')? UNQUOTED_STRING '}')
(name = STRING | name = UNQUOTED_STRING)
;

Substitution returns EString:
'${' ('?')? UNQUOTED_STRING '}'
;

NumberLiteral:
Expand Down