Interface InvocationMatcher
public interface InvocationMatcher
RuleInvocations.
Primarily used in RelationCollectorListener to match invocations in
the body of predicates.
Implementation notes
See the source; there are many un-exposed classes that implement matchers for
all the operators described in the grammer (cf. invocationMatchers(edu.unc.cs.comp524.parsers.prolog.PrologParser, edu.unc.cs.comp524.parsers.prolog.PrologLexer)).
We use a custom ParseTreePatternMatcher with delimiters set by ParseTreePatternMatcher.setDelimiters(java.lang.String, java.lang.String, java.lang.String) to allow the use of slashes in the
patterns.
The names of classes use a bit of shorthand:
- C: colon (:)
- H: hyphen (-)
- Q: question mark (?)
- SEMI: semi-colon (;)
- BAR: bar or pipe (|)
- HARROW: ->
- S: star (*)
- EQ: equals (=)
- NOT: prolog's not (\+)
- LT: less-than (<)
- LEQ: less-than-equal (=<)
- D: dot (.)
- AT: aerobase (@)
- GT: greater-than (>)
- GEQ: greater-than-equal (>=)
- NEQ: not-equal (\=)
- AND: and (/\)
- OR: or (\/)
- SLASH: slash (/)
- CARET: caret (^)
- BSLASH: backslash (\)
- DOLLAR: dollar-sign ($)
Most others that are not built from this shorthand are represented by name directly (e.g., MOD for mod, DYNAMIC for dynamic).
-
Method Summary
Modifier and Type Method Description List<org.antlr.v4.runtime.tree.ParseTree>getArgs(org.antlr.v4.runtime.tree.pattern.ParseTreeMatch m)Computes the arguments of the invocation given aParseTreeMatchcreated frompattern().static List<InvocationMatcher>invocationMatchers(PrologParser p, PrologLexer l)The default matchers for all operators defined in the grammar.default List<RuleInvocation>invocations(org.antlr.v4.runtime.tree.ParseTree tree)Find all invocations intree.default List<RuleInvocation>invocations(org.antlr.v4.runtime.tree.ParseTree tree, String xpath)Find all invocations intreethat matchxpath.Stringname()The name of the rule the invocation matchesorg.antlr.v4.runtime.tree.pattern.ParseTreePatternpattern()The pattern to be used to match with
-
Method Details
-
name
String name()The name of the rule the invocation matches -
getArgs
List<org.antlr.v4.runtime.tree.ParseTree> getArgs(org.antlr.v4.runtime.tree.pattern.ParseTreeMatch m)Computes the arguments of the invocation given aParseTreeMatchcreated frompattern(). -
pattern
org.antlr.v4.runtime.tree.pattern.ParseTreePattern pattern()The pattern to be used to match with -
invocations
Find all invocations intree.The default implementation is equivalent to
invocations(ParseTree, String)(tree, "//*"). -
invocations
Find all invocations intreethat matchxpath.- See Also:
ParseTreePattern.findAll(org.antlr.v4.runtime.tree.ParseTree, java.lang.String)
-
invocationMatchers
The default matchers for all operators defined in the grammar.See implementation notes above and the source for their definition.
-