| summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'instr-to-kodkod/parser')
| -rw-r--r-- | instr-to-kodkod/parser/PropertyLexer.g4 | 4 | ||||
| -rw-r--r-- | instr-to-kodkod/parser/PropertyParser.g4 | 44 |
2 files changed, 47 insertions, 1 deletions
diff --git a/instr-to-kodkod/parser/PropertyLexer.g4 b/instr-to-kodkod/parser/PropertyLexer.g4 index 64fccb0..ec01c88 100644 --- a/instr-to-kodkod/parser/PropertyLexer.g4 +++ b/instr-to-kodkod/parser/PropertyLexer.g4 @@ -12,7 +12,9 @@ TAG_EXISTING_KW: '(tag_existing' SEP; AND_OPERATOR_KW: '(and' SEP; OR_OPERATOR_KW: '(or' SEP; NOT_OPERATOR_KW: '(not' SEP ; -IMPLIES_OPERATOR_KW: '(implies' SEP ; +IMPLIES_OPERATOR_KW: '(implies' SEP; + +REGEX_SPECIAL_PREDICATE_KW: '(string_matches' SEP; EXISTS_OPERATOR_KW: '(exists' SEP; FORALL_OPERATOR_KW: '(forall' SEP; diff --git a/instr-to-kodkod/parser/PropertyParser.g4 b/instr-to-kodkod/parser/PropertyParser.g4 index 986ad3b..3e5634f 100644 --- a/instr-to-kodkod/parser/PropertyParser.g4 +++ b/instr-to-kodkod/parser/PropertyParser.g4 @@ -318,6 +318,50 @@ function [Variable current_node] } ; +regex_special_predicate [Variable current_node] + returns [Formula result]: + + (WS)* REGEX_SPECIAL_PREDICATE_KW + id_or_string_or_fun[current_node] + STRING + (WS)* R_PAREN + + { + try + { + $result = + ($id_or_string_or_fun.value).product + ( + Main.get_string_manager().get_regex_as_relation + ( + ($STRING.text) + ) + ).in + ( + Main.get_model().get_predicate_as_relation + ( + "is_start_node" + ).transpose() + ); + } + catch (final Exception e) + { + System.err.println + ( + "[F] A problem occured while handling a regex related predicate in" + + " the property (l." + + ($REGEX_SPECIAL_PREDICATE_KW.getLine()) + + " c." + + ($REGEX_SPECIAL_PREDICATE_KW.getCharPositionInLine()) + + "):" + + e.getMessage() + ); + + System.exit(-1); + } + } +; + non_empty_formula_list [Variable current_node] returns [List<Formula> list] |


