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

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();
主站蜘蛛池模板: 息烽县| 绥江县| 淮安市| 卢龙县| 贵定县| 盐亭县| 荥经县| 闽侯县| 迁安市| 皋兰县| 乡城县| 正镶白旗| 库尔勒市| 平武县| 柳河县| 华阴市| 江城| 封丘县| 山西省| 峡江县| 江陵县| 甘谷县| 铁岭市| 安陆市| 浦北县| 砚山县| 阳江市| 松阳县| 开平市| 富民县| 新龙县| 汉源县| 鹿邑县| 鄢陵县| 恩平市| 滕州市| 将乐县| 东乌珠穆沁旗| 巴塘县| 惠来县| 凤台县|