aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_goal.peg
diff options
context:
space:
mode:
authorEric <[email protected]>2012-09-08 11:14:51 -0500
committerEric <[email protected]>2012-09-08 11:14:51 -0500
commit13263b778c4f519e27629a2e0772b2466004005b (patch)
tree1c5c710672cc2d009ea8d8052da7f5aff59dc177 /src/rcl_goal.peg
parent6f6fd117cc8c7dd1f139fa7a8bfb53b0e670a968 (diff)
downloadrelx-13263b778c4f519e27629a2e0772b2466004005b.tar.gz
relx-13263b778c4f519e27629a2e0772b2466004005b.tar.bz2
relx-13263b778c4f519e27629a2e0772b2466004005b.zip
add goal parsing capability to the system
Diffstat (limited to 'src/rcl_goal.peg')
-rw-r--r--src/rcl_goal.peg54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/rcl_goal.peg b/src/rcl_goal.peg
new file mode 100644
index 0000000..24e78a8
--- /dev/null
+++ b/src/rcl_goal.peg
@@ -0,0 +1,54 @@
+
+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, erlang:iolist_to_binary(AppName)};
+ [_,AppName,_,Op,_,Vsn,_, _] ->
+ {ok,
+ {erlang:iolist_to_binary(AppName),
+ rcl_goal_utils:to_vsn(Vsn),
+ rcl_goal_utils:to_op(Op)}};
+ [_,AppName,_,Op,_,Vsn1,_,_,_,Vsn2,_,_] ->
+ {ok,
+ {erlang:iolist_to_binary(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_]+ ;
+
+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).` \ No newline at end of file