![cover image](https://wikiwandv2-19431.kxcdn.com/_next/image?url=https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Abstract_syntax_tree_for_Euclidean_algorithm.svg/langko-640px-Abstract_syntax_tree_for_Euclidean_algorithm.svg.png&w=640&q=50)
추상 구문 트리
From Wikipedia, the free encyclopedia
컴퓨터 과학에서 추상 구문 트리(abstract syntax tree, AST), 또는 간단히 구문 트리(syntax tree)는 프로그래밍 언어로 작성된 소스 코드의 추상 구문 구조의 트리이다. 이 트리의 각 노드는 소스 코드에서 발생되는 구조를 나타낸다. 구문이 추상적이라는 의미는 실제 구문에서 나타나는 모든 세세한 정보를 나타내지는 않는다는 것을 의미한다. 예를 들어, 그룹핑을 위한 괄호는 암시적으로 트리 구조를 가지며, 분리된 노드로 표현되지는 않는다. 마찬가지로, if-condition-then 표현식과 같은 구문 구조는 3개의 가지에 1개의 노드가 달린 구조로 표기된다.
![Thumb image](http://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Abstract_syntax_tree_for_Euclidean_algorithm.svg/640px-Abstract_syntax_tree_for_Euclidean_algorithm.svg.png)
- while b ≠ 0
- if a > b
- a := a − b
- else
- b := b − a
- if a > b
- return a
이것이 추상 구문 트리를 상세 구문 트리, 즉 원래의 파스 트리 개념과 구별한다. 파스 트리는 소스코드가 compile, translation되는 도중에 일반적으로는 컴파일 과정에 파서에 의해 빌드된다. 한번 빌드된 이후에는 추가 정보가 후속 처리에 의해 AST트리에 추가된다. (예시. contextual analysis)
추상 구문 트리는 프로그램 분석과 프로그램 변환 시스템에도 사용된다.