From 067f596822b80b2786ce2bb895a593d479516cad Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Mon, 31 Jul 2017 15:05:30 +0200 Subject: First shot at the handling of regular expressions. --- instr-to-kodkod/parser/PropertyParser.g4 | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'instr-to-kodkod/parser/PropertyParser.g4') 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 list] -- cgit v1.2.3-70-g09d2