@@ -21,7 +21,7 @@ import uk.gov.nationalarchives.csv.validator.{SchemaMessage, FailMessage}
2121
2222trait SchemaParser extends RegexParsers {
2323
24- override protected val whiteSpace = """ [ \t]+ """ .r
24+ override protected val whiteSpace = """ [ \t]* """ .r
2525
2626 // val white: Parser[String] = whiteSpace
2727
@@ -95,8 +95,8 @@ trait SchemaParser extends RegexParsers {
9595
9696 def multiLineComment : Parser [String ] = """ \/\*(?:[^*\r\n]+|(?:\r?\n))*\*\/(?:\r?\n)?""" .r
9797
98- // def columnDefinitions = (positioned(columnDefinition))
99- def columnDefinitions = columnDefinition
98+ def columnDefinitions = (positioned(columnDefinition))
99+ // def columnDefinitions = columnDefinition
100100
101101 def columnDefinition : Parser [ColumnDefinition ] = (
102102 ((columnIdentifier | quotedColumnIdentifier) <~ " :" ) ~ columnRule <~ (endOfColumnDefinition | comment) ^^ {
@@ -339,7 +339,8 @@ trait SchemaParser extends RegexParsers {
339339// case cond ~ bdy ~ optBdy => IfRule(cond, bdy, optBdy)
340340// }) | failure("Invalid rule")
341341
342- def ifExpr : Parser [IfRule ] = ((" if(" ~> nonConditionalExpr <~ " ," ) ~ rep1(columnValidationExpr) ~ opt(" ," ~> rep1(columnValidationExpr)) <~ " )" ^^ {
342+ // TODO update EBNF to match this
343+ def ifExpr : Parser [IfRule ] = ((" if(" ~> (combinatorialExpr | nonConditionalExpr) <~ " ," ) ~ rep1(columnValidationExpr) ~ opt(" ," ~> rep1(columnValidationExpr)) <~ " )" ^^ {
343344 case cond ~ bdy ~ optBdy => IfRule (cond, bdy, optBdy)
344345 }) | failure(" Invalid rule" )
345346
@@ -364,7 +365,7 @@ trait SchemaParser extends RegexParsers {
364365
365366 def algorithmExpr : Parser [String ] = " \" " ~> stringRegex <~ " \" " ^^ { a => a }
366367
367- private def endOfColumnDefinition : Parser [Any ] = eol | endOfInput | failure(" Invalid column definition" )
368+ private def endOfColumnDefinition : Parser [Any ] = whiteSpace ~ ( eol | endOfInput | failure(" Invalid column definition" ) )
368369
369370 private def endOfInput : Parser [Any ] = new Parser [Any ] {
370371 def apply (input : Input ) = {
0 commit comments