diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2025-03-13 20:17:51 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2025-04-08 18:39:49 +0200 |
commit | 9e2dbe43abe97c4e60b158e5fa52172468a2afb8 (patch) | |
tree | f58276e500d8ab0b84cdf74cc36fc73d4bca3892 /lib/configuration/expression_parser.mly | |
parent | 0bdc640331b903532fb345930e7078752ba54a2d (diff) |
Declare the files to load from an external configuration file
Diffstat (limited to 'lib/configuration/expression_parser.mly')
-rw-r--r-- | lib/configuration/expression_parser.mly | 33 |
1 files changed, 19 insertions, 14 deletions
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_: |