aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_goal.peg
blob: bfac6072f5ccf9d946865a7774c717cd5ebe4e7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
constraint <-   ws? app_name ws? between_op  ws? version ws? "," ws? version ws? !.
              / ws? app_name ws? constraint_op ws? version ws? !.
              / ws? app_name ws? !.

           `
           case Node of
                [_,AppName,_, _] ->
                    {ok, AppName};
                [_,AppName,_,Op,_,Vsn,_, _] ->
                    {ok,
                        {AppName,
                         rcl_goal_utils:to_vsn(Vsn),
                         rcl_goal_utils:to_op(Op)}};
                [_,AppName,_,Op,_,Vsn1,_,_,_,Vsn2,_,_] ->
                    {ok,
                        {AppName,
                         rcl_goal_utils:to_vsn(Vsn1),
                         rcl_goal_utils:to_vsn(Vsn2),
                         rcl_goal_utils:to_op(Op)}};
                _ ->
                 io:format("~p~n", [Node])
           end
           ` ;

ws <- [ \t\n\s\r] ;

app_name <- [a-zA-Z0-9_]+
         ` erlang:list_to_atom(erlang:binary_to_list(erlang:iolist_to_binary(Node))) ` ;

between_op <-
             ":" ws? ( "btwn" / "between" ) ws? ":"
                   ` case Node of
                       [C,_,Op,_,C] -> erlang:iolist_to_binary([C,Op,C]);
                       _ -> Node
                      end
                   ` ;

constraint_op <- "=" / "-" / "<=" / "<" / "~>" / ">=" / ">" / word_constraint_op / ":" ;

word_constraint_op <-
                   ":" ws? ( "gte" / "lte" / "gt" / "lt"  / "pes" ) ws? ":"
                   ` case Node of
                           [C,_,Op,_,C] -> erlang:iolist_to_binary([C,Op,C]);
                       _ -> Node
                      end
                   ` ;


version <- [0-9a-zA-Z-+.]+ ;

%% This only exists to get around a bug in erlang where if
%% warnings_as_errors is specified `nowarn` directives are ignored

 `-compile(export_all).`