June 2018
Intermediate to advanced
280 pages
7h 46m
English
The interpreter pattern can be used whenever an expression should be interpreted and transformed to its internal representation. The pattern cannot be applied to complex grammars since the internal representation is based on a composite pattern.
Java implements the interpreter pattern in java.util.Parser and it is used to interpret regular expressions. First, when a regular expression is interpreted, a matcher object is returned. The matcher uses the internal structure that was created by the pattern class based on the regular expression:
Pattern p = Pattern. compile("a*b");Matcher m = p.matcher ("aaaaab");boolean b = m.matches();
Read now
Unlock full access