Pre-processor for rules #11
Answered
by
gciatto
vasily-kartashov
asked this question in
Q&A
-
When loading a file with an example rule: :- response_body(endpoint, [json]).
endpoint([message('Hello, World!')]). I'd like to automatically replace it with the following rule (based on the presence of endpoint(Response) :-
original_endpoint(Response0), // keeping the original goal
term_json(Response0, Payload),
Response = [headers(['Content-Type': 'application/json']), payload(Payload)]. What is the best way to achieve it? |
Beta Was this translation helpful? Give feedback.
Answered by
gciatto
Aug 9, 2021
Replies: 1 comment 6 replies
-
The first line you wrote its a directive, which is not properly a rule. Both rules and directives are clauses. A theory is a sequence of clauses, essentially. So the best way to do what you propose is to parse the theory, selecting the directive and manipulating it from java, thus crating a new theory having a rule instead of a directory |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
vasily-kartashov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The first line you wrote its a directive, which is not properly a rule.
Both rules and directives are clauses.
A theory is a sequence of clauses, essentially.
So the best way to do what you propose is to parse the theory, selecting the directive and manipulating it from java, thus crating a new theory having a rule instead of a directory