This repository was archived by the owner on Mar 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,21 +39,18 @@ object ConfigParser {
3939
4040 /** Top-level parser of configuration files */
4141 lazy val topLevel : Parser [List [Directive ]] = " configuration" |: {
42- directives << skipLWS << realEOF
42+ skipLWS >> directives << realEOF
4343 }
4444
4545 /** Parser of configuration files that don't support import directives */
46- lazy val sansImport : Parser [List [Directive ]] = {
47- val d = (skipLWS >> choice(bindDirective, groupDirective) << skipHWS)
48- d.map2(attempt(newline >> d).many)(_ :: _)
49- }
46+ lazy val sansImport : Parser [List [Directive ]] =
47+ (choice(bindDirective, groupDirective) << skipHWS).sepEndBy(newline << skipLWS)
5048
5149 lazy val directives : Parser [List [Directive ]] =
52- directive.map2(attempt(newline >> directive).many)(_ :: _ )
50+ (directive << skipHWS).sepEndBy(newline << skipLWS )
5351
5452 lazy val directive : Parser [Directive ] =
55- (skipLWS >> choice(importDirective, bindDirective, groupDirective) << skipHWS) scope
56- " directive"
53+ choice(importDirective, bindDirective, groupDirective) scope " directive"
5754
5855 lazy val importDirective = " import directive" |: {
5956 word(" import" ) >> skipLWS >> stringLiteral.map(Import (_))
Original file line number Diff line number Diff line change 1+
2+ # param1=true
3+ # param2="hello"
4+
5+ # group {
6+ # this.group.is = "commented out"
7+ # }
Original file line number Diff line number Diff line change 1+
2+
3+
4+ # ^^^ Start with some irritating whitespace
5+
16# Comment
27
38aa # Comment
@@ -41,3 +46,8 @@ dur = 5 seconds
4146ca.cb {
4247 cd = " fuf"
4348}
49+
50+ # And finish with some more irritating whitespace
51+
52+
53+
Original file line number Diff line number Diff line change @@ -164,6 +164,8 @@ object Test extends Properties("Knobs") {
164164 }
165165 }
166166
167+ lazy val allCommentsTest : Task [Prop ] =
168+ load(List (Required (ClassPathResource (" all-comments.cfg" )))).attempt.map(_.isRight)
167169
168170 property(" load-pathological-config" ) = loadTest.unsafePerformSync
169171
@@ -203,4 +205,5 @@ object Test extends Properties("Knobs") {
203205
204206 property(" mutable-config-value-error" ) = mutableConfigValueErrorTest.unsafePerformSync
205207
208+ property(" all-comments" ) = allCommentsTest.unsafePerformSync
206209}
You can’t perform that action at this time.
0 commit comments