Commit 890df1b1 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add code that evaluates pipelines expressions

parent 2c4aa504
...@@ -31,8 +31,8 @@ module Gitlab ...@@ -31,8 +31,8 @@ module Gitlab
end end
## ##
# Our syntax is very simple, so we don't need yet to implement a # Our syntax is very simple, so we don't yet need to implement a
# recurisive parser, we can use the most simple approach to create # recursive parser, we can use the most simple approach to create
# a reverse descent parse tree "by hand". # a reverse descent parse tree "by hand".
# #
def parse_tree def parse_tree
...@@ -42,7 +42,7 @@ module Gitlab ...@@ -42,7 +42,7 @@ module Gitlab
raise ParserError, 'Unknown pipeline expression!' raise ParserError, 'Unknown pipeline expression!'
end end
if lexemes.many? if tokens.many?
Expression::Equals.new(tokens.first.build, tokens.last.build) Expression::Equals.new(tokens.first.build, tokens.last.build)
else else
tokens.first.build tokens.first.build
...@@ -50,6 +50,11 @@ module Gitlab ...@@ -50,6 +50,11 @@ module Gitlab
end end
def evaluate def evaluate
if tokens.many?
parse_tree.evaluate
else
parse_tree.evaluate.present?
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment