- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 98字
- 2021-06-25 20:52:37
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();
推薦閱讀
- 玩轉(zhuǎn)Scratch少兒趣味編程
- 深入淺出Electron:原理、工程與實(shí)踐
- Learning Flask Framework
- 青少年美育趣味課堂:XMind思維導(dǎo)圖制作
- Visual C++串口通信技術(shù)詳解(第2版)
- Hands-On C++ Game Animation Programming
- 重學(xué)Java設(shè)計(jì)模式
- 小程序開(kāi)發(fā)原理與實(shí)戰(zhàn)
- 青少年P(guān)ython編程入門(mén)
- Scala編程(第5版)
- Python 3 數(shù)據(jù)分析與機(jī)器學(xué)習(xí)實(shí)戰(zhàn)
- Deep Learning with R Cookbook
- UML軟件建模
- Java 9:Building Robust Modular Applications
- SOA Patterns with BizTalk Server 2013 and Microsoft Azure(Second Edition)