summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/expression/parser.rb
blob: f3201ec09792dc313e80c02f8240cec81a3833f4 (plain)
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
module Gitlab
  module Ci
    module Pipeline
      module Expression
        class Parser
          def initialize(syntax)
            if syntax.is_a?(Expression::Lexer)
              @tokens = syntax.tokens
            else
              @tokens = syntax.to_a
            end
          end

          def tree
            if @tokens.many?
              Expression::Equals.new(@tokens.first.build, @tokens.last.build)
            else
              @tokens.first.build
            end
          end
        end
      end
    end
  end
end