官术网_书友最值得收藏!

Applicability and examples

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();
主站蜘蛛池模板: 格尔木市| 内丘县| 满城县| 重庆市| 丽水市| 阳新县| 那坡县| 湘阴县| 阳原县| 阿瓦提县| 西畴县| 蕲春县| 随州市| 南开区| 汨罗市| 安乡县| 通化县| 昭平县| 稷山县| 余干县| 大石桥市| 红安县| 六盘水市| 海林市| 盱眙县| 芜湖市| 调兵山市| 奉化市| 姜堰市| 大厂| 建阳市| 腾冲县| 大港区| 咸宁市| 临江市| 道孚县| 淮北市| 临夏县| 友谊县| 平远县| 宜兰市|