[DesignPattern] Interpreter pattern

2013. 11. 24. 22:41Architecture/DesignPattern

반응형

 

2013/07/21 - [Architecture/DesignPattern] - [첫번째 스터디] singleton 패턴

 

2013/07/21 - [Architecture/DesignPattern] - [첫번째 스터디] abstractFactory 패턴

지금까지 공부 한 디자인 패턴 목록

  : http://acet.pe.kr/notice/325

 

음..정리는 2개뿐이 하질 않았군요.. 하하;;

 

프로젝트와 병행을 하고 있어서..11월 19일부터 내부 스터디 다시 시작 합니다^-^/

 

매주 월요일 - 눈이 오나 비가오나 지구가 망해도 스터디는 진행 합니다. 아무도 참여하지 않아도 진도는 나갑니다.ㅋㅋㅋㅋ

 

<< 2013년 11월 19일 >>

범 위  : Interperter 패턴

참여 인원 : 4명 중 3명 참여

  참 여 : 공K, 박D, Mr. 권

  불 참 : 이D(교육 참여)

 

참고 사이트 : http://ko.wikipedia.org/wiki/%EC%98%B5%EC%84%9C%EB%B2%84_%ED%8C%A8%ED%84%B4

 

인터프리터 패턴 이란??

In computer programming, the interpreter pattern is a design pattern that specifies how to evaluate sentences in a language.

위의 빨간 문장이 어떻게 보면 핵심인 것 같다. 영어라서 그런지..해석해보면 Interpreter가 뭔지 잘 모르면

난감 할 수 있는 문장이다.

evaluate를 네이버에서 찾아보면 아래와 같다 ㅋㅋ

 

 암튼 해석을 해보면 어떤 특별한(상징적인) 문장을 평가(해석)한다는 뜻이다.

 

The basic idea is to have a class for each symbol (terminal or nonterminal) in a specialized computer language. The syntax tree of a sentence in the language is an instance of the composite pattern and is used to evaluate (interpret) the sentence

 

syntax tree 라는 것은 예를 들어서 a b + c a - -  이런 상징적인 녀석들이 모여서 차례차례 수행이 되는데

      syntax tree라는 용어를 사용 한다. 소스에서 syntax tree라는 변수가 있으니 그 용도를 보면 알 것 이다.

구조를 살펴보도록 하자! 

 

 

 

소스 -  패키지는 package kr.pe.acet.interpreter; 이다.

 

InterpreterPatternTest.java

 

Evaluator.java

 

Expression.java

 

Minus.java

 

Number.java

 

Plus.java

 

Variable.java

 

반응형