From 567dac033fbf50d6cb77f49c8f5bc6fcbc7cf529 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Sun, 13 Nov 2016 12:37:18 +0000 Subject: [PATCH] fix meta parsing --- src/meta.ml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/meta.ml b/src/meta.ml index 6064728c..75f8979b 100644 --- a/src/meta.ml +++ b/src/meta.ml @@ -47,25 +47,25 @@ module Parse = struct | Plus_equal -> Add | _ -> error lb "'=' or '+=' expected" - let comma lb = - match next lb with - | Comma -> () - | _ -> error lb "',' expected" - let rec predicates_and_action lb acc = match next lb with | Rparen -> (List.rev acc, action lb) - | Name n -> comma lb; predicates_and_action lb (P n :: acc) + | Name n -> after_predicate lb (P n :: acc) | Minus -> let n = match next lb with | Name p -> p | _ -> error lb "name expected" in - comma lb; - predicates_and_action lb (A n :: acc) + after_predicate lb (A n :: acc) | _ -> error lb "name, '-' or ')' expected" + and after_predicate lb acc = + match next lb with + | Rparen -> (List.rev acc, action lb) + | Comma -> predicates_and_action lb acc + | _ -> error lb "')' or ',' expected" + let rec entries lb depth acc = match next lb with | Rparen -> @@ -73,6 +73,11 @@ module Parse = struct List.rev acc else error lb "closing parenthesis without matching opening one" + | Eof -> + if depth = 0 then + List.rev acc + else + error lb "%d closing parentheses missing" depth | Name "package" -> let name = package_name lb in lparen lb;