diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-22 13:54:22 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-22 13:54:22 +0100 |
commit | 867a4f68cbbe58652e8389e05edfd36df81cb72b (patch) | |
tree | ac3451c33a5f812f3405bc2fdabbe8eca82090f8 /lib/gitlab/ci/pipeline/expression/parser.rb | |
parent | b92ce0ccb68d1dd39a1dd06f4a57979db7299526 (diff) | |
download | gitlab-ce-867a4f68cbbe58652e8389e05edfd36df81cb72b.tar.gz |
Extract pipeline expressions parser to a separate class
Diffstat (limited to 'lib/gitlab/ci/pipeline/expression/parser.rb')
-rw-r--r-- | lib/gitlab/ci/pipeline/expression/parser.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline/expression/parser.rb b/lib/gitlab/ci/pipeline/expression/parser.rb new file mode 100644 index 00000000000..f3201ec0979 --- /dev/null +++ b/lib/gitlab/ci/pipeline/expression/parser.rb @@ -0,0 +1,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 |