Module: PgVerify::Model::Validation::UnknownTokenValidation

Defined in:
lib/pg-verify/model/validation/unknown_token_validation.rb

Class Method Summary collapse

Class Method Details

.validate(model) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pg-verify/model/validation/unknown_token_validation.rb', line 7

def self.validate(model)
    errors = []
    varset = model.all_variables()
    transitions = model.components.map(&:transitions).flatten
    transitions.each { |tx|
        errors += validate_expression(varset, tx.precon)
        errors += validate_expression(varset, tx.guard)
        errors += validate_expression(varset, tx.action)

    }
    return errors
end

.validate_expression(varset, expression) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/pg-verify/model/validation/unknown_token_validation.rb', line 20

def self.validate_expression(varset, expression)
    return [] if expression.nil?
    tokens = expression.word_tokens()
    tokens = tokens.reject { |token|
        varset.varname?(token) || varset.constname?(token)
    }
    return tokens.map { |token|
        UnknownTokenError.new(token, expression, varset)
    }
end