class Autoproj::RosConditionParser

Parses a conditional expression Syntax and rules as defined in www.ros.org/reps/rep-0149.html#id20

Constants

RESERVED

Public Class Methods

new(context) click to toggle source
Calls superclass method
# File lib/autoproj/ros_condition_parser.rb, line 11
def initialize(context)
    @context = context
    super()
end

Public Instance Methods

any_of(strings) click to toggle source
# File lib/autoproj/ros_condition_parser.rb, line 37
def any_of(strings)
    strings = strings.dup
    strings.reduce(str(strings.shift)) { |acc, s| acc | str(s) }
end
chain(lhs, operator, operation) click to toggle source
# File lib/autoproj/ros_condition_parser.rb, line 48
def chain(lhs, operator, operation)
    (lhs.as(:lhs) >> operator >> operation.as(:rhs)) | lhs
end
evaluate(expr) click to toggle source
# File lib/autoproj/ros_condition_parser.rb, line 31
def evaluate(expr)
    Transform.new.apply(parse(expr.strip), expander: method(:expand))
rescue Parslet::ParseFailed => e
    raise Autoproj::ConfigError, e.message
end
expand(var) click to toggle source
# File lib/autoproj/ros_condition_parser.rb, line 16
def expand(var)
    Autoproj.expand(var, @context)
rescue StandardError
    ""
end
quoted_literal(quote) click to toggle source
# File lib/autoproj/ros_condition_parser.rb, line 42
def quoted_literal(quote)
    str(quote) >> (
        str(quote).absent? >> any
    ).repeat.maybe.as(:literal) >> str(quote)
end