-
Hi, My question is: How to configure a standalone EPL module to check if a pattern is syntactically correct without an instance model? var module = new EplModule();
module.parse("""
pattern GoRoute
route: Route from : Route.all.select(rt | rt.entry.signal == Signal#GO) {
match: (route.active) and
route.follows->exists(swP | swP.position != swP.target.currentPosition)
}
"""); // Point (1) (Yes, this is a correct one, but easy to break.)
var instance = new InMemoryEmfModel(makeEmpty()); // placeholder empty resource set
module.getContext().getModelRepository().addModel(instance);
var results = (PatternMatchModel) module.execute(); // Point (2) At (1), 'active' is (erroneously) flagged for no viable input, but it still gives correct results when executed. At (2), if there is a model that somewhat resembles the pattern, then some errors are detected, like undefined variables, but without an instance model, the problems are just ignored. (Metamodel is available in the form of an EPackage and registered to the global epackage registry.) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Regarding the second issue you are describing, essentially you are looking for a static analyser for EPL. We're working on a static analyser for Epsilon in https://github.com/epsilonlabs/epsilon-with-lsp/ but it doesn't cover EPL yet. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. I have two follow-up questions. (1) Is it possible to access the internal representation of the parsed pattern and traverse it somehow? (I'm thinking throwing something together to have some simple checks.) (2) Can you give rough estimate on the timeline on the static analyser? |
Beta Was this translation helpful? Give feedback.
active
is a keyword in EPL, which is why you get theno viable input
error message. To fix this you'd need to escapeactive
using backticks (i.e.route.`active`
). When you callmodule.parse()
the expectation is that you then check for the presence of parse errors usingmodule.getParseProblems()
before you attempt to execute the module. If you don't do this and execute a module that has parse errors, you may run into unexpected behaviour.Regarding the second issue you are describing, essentially you are looking for a static analyser for EPL. We're working on a static analyser for Epsilon in https://github.com/epsilonlabs/epsilon-with-lsp/ but it doesn't cover EPL yet.