Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- check value for wildcard/operator pattern:
- 1. split pattern to OR statements (by | divider)
- 2. for each OR statement:
- 1. split statement to AND statements (by & divider)
- 2. set and_success to true
- 3. for each AND statement:
- 1. check value with this statement
- 2. if value does not pass check - set and_success to false, break
- 4. if and_success is true - return true, else - continue
- When comparing two values in YAML file we can get pattern type:
- - bool - if target is also bool, check for equality, else - return false
- - int - if target is int or float without fraction (cast it to int then), check for equality, else - return false
- - float:
- * if pattern value has no fraction, cast it to int. GOTO int
- * pattern has fraction. If value is float - check for equality, else - return false
- - string - GOTO "if the pattern is string"
- - object - NOT SUPPORTED
- - array - NOT SUPPORTED
- - null - check that value is also null
- if the pattern is string:
- 0. cast any value to string
- 1. grab operator from front it (could be only one of: !, >=, <=, >, <; and must be specified from very start of pattern)
- 2. let we have regexp that gets number and string suffix from pattern.
- 3. if string pattern is boolean value - check for bool and then apply operator; return
- 4. if number part is empty
- if operator is ! or empty
- return: check string value with wildcard from pattern string ("" is wildcard too)
- else
- error: could not apply comparison operators with strings
- end if
- else
- ok = check string value with string pattern
- if (ok) return: compare pattern number and value number with operator
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement