From 9e2dbe43abe97c4e60b158e5fa52172468a2afb8 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 13 Mar 2025 20:17:51 +0100 Subject: Declare the files to load from an external configuration file --- lib/configuration/expression_parser.mly | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'lib/configuration/expression_parser.mly') diff --git a/lib/configuration/expression_parser.mly b/lib/configuration/expression_parser.mly index 1761cce..9b97637 100644 --- a/lib/configuration/expression_parser.mly +++ b/lib/configuration/expression_parser.mly @@ -34,20 +34,25 @@ column_expr: path_: | COLUMN - column = IDENT - { ImportExpression.T.Path - ImportDataTypes.Path.{ alias = None - ; column = ImportDataTypes.Path.column_of_string column - } - } - - | COLUMN - table = IDENT - DOT - column = IDENT - { ImportExpression.T.Path - ImportDataTypes.Path.{ alias = Some table - ; column = ImportDataTypes.Path.column_of_string column} + (* The dot character is required as a separator between the table and the + colum, like in [:table.XX] but the table name can also contains [.] + (this is allowed in the toml configuration syntax, as long as the + identifier is quoted. + + So we have to handle cases like [:foo.bar.XX] + *) + path = separated_nonempty_list(DOT, IDENT) + { let reversed_path = List.rev path in + (* reversed_path is nonempty, and we can take head and tail safely *) + let tail = List.tl reversed_path in + let alias = match tail with + | [] -> None + | tl -> Some (String.concat "." (List.rev tl)) + in + + ImportExpression.T.Path + ImportDataTypes.Path.{ alias + ; column = ImportDataTypes.Path.column_of_string (List.hd reversed_path)} } column_: -- cgit v1.2.3