Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrew cimino <dcimino@gitlab.com>2019-04-26 18:37:20 +0300
committerdrew cimino <dcimino@gitlab.com>2019-06-05 03:03:24 +0300
commitcfaac7532210ef1ce03f335a3198bb7d2ad3979a (patch)
treed544f21c63cc98acb03bd39ca2cd6bde44c135d5 /lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
parent54cc3b64929dfe2eea562089b5fd6656a50ed2ae (diff)
&& and || operators for CI Pipeline expressions.
Refactored regex pattern matching to eagerly return tokens Packaged behind a default-enabled feature flag and added operator documentation.
Diffstat (limited to 'lib/gitlab/ci/pipeline/expression/lexeme/operator.rb')
-rw-r--r--lib/gitlab/ci/pipeline/expression/lexeme/operator.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline/expression/lexeme/operator.rb b/lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
index 3ebceb92eb7..3ddab7800c8 100644
--- a/lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
+++ b/lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
@@ -6,9 +6,29 @@ module Gitlab
module Expression
module Lexeme
class Operator < Lexeme::Base
+ # This operator class is design to handle single operators that take two
+ # arguments. Expression::Parser was originally designed to read infix operators,
+ # and so the two operands are called "left" and "right" here. If we wish to
+ # implement an Operator that takes a greater or lesser number of arguments, a
+ # structural change or additional Operator superclass will likely be needed.
+
+ OperatorError = Class.new(Expression::ExpressionError)
+
+ def initialize(left, right)
+ raise OperatorError, 'Invalid left operand' unless left.respond_to? :evaluate
+ raise OperatorError, 'Invalid right operand' unless right.respond_to? :evaluate
+
+ @left = left
+ @right = right
+ end
+
def self.type
:operator
end
+
+ def self.precedence
+ raise NotImplementedError
+ end
end
end
end