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

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();
主站蜘蛛池模板: 岑溪市| 西昌市| 衡南县| 深水埗区| 萝北县| 汾西县| 卓资县| 长海县| 石嘴山市| 肇庆市| 井研县| 宜兴市| 五指山市| 青阳县| 比如县| 娱乐| 南华县| 松江区| 广宁县| 融水| 遂川县| 平武县| 正定县| 宁陵县| 新津县| 滦平县| 乌审旗| 伊春市| 潜江市| 康定县| 东方市| 基隆市| 祥云县| 南木林县| 当涂县| 闸北区| 邯郸市| 凤山市| 锦屏县| 平塘县| 滨海县|