7 4 1 lexical token lexical element lexical

  • Slides: 42
Download presentation

7 4. 1 언어 구문 • 어휘 토큰 (lexical token), 어휘 요소 (lexical element),

7 4. 1 언어 구문 • 어휘 토큰 (lexical token), 어휘 요소 (lexical element), 어휘 단위 (lexical unit) • 언어 구성자 (language construct) • 식별자 [프로그래밍 언어에서] (identifier [in programming language) • 미리 정의된 식별자 (predefined identifier)

15 • Subpascal 시작부 구문 도표 subpascal block program ; ident const ident block

15 • Subpascal 시작부 구문 도표 subpascal block program ; ident const ident block = · number ; var : ident type ’ ; procedure ; ident ( ; begin formal-param ) block statement ; end 2004 Y. H. Won, Hongik University. All rights reserved.

17 4. 1 언어 구문 • 모호성, 결합성 및 우선 순위 – 서로 다른

17 4. 1 언어 구문 • 모호성, 결합성 및 우선 순위 – 서로 다른 유도 과정을 거쳐 B 33을 생성한다. • <identifier> <digit> <identifier> 3 3 • <identifier> 3 <letter> 3 3 <identifier> <digit> <letter> <digit> B 3 <digit> <identifier> <digit> 3 B 33 <identifier> <digit> B 33 <identifier> 파스 트리 <digit> <identifier> <digit> <letter> 3 B 3

24 4. 1 언어 구문 • 구문과 프로그램 신뢰성 – 현수(dangling) else 문제 •

24 4. 1 언어 구문 • 구문과 프로그램 신뢰성 – 현수(dangling) else 문제 • 중첩된 if 문에서 else는 어떤 if의 else인가? – 예제 if c 1 then if c 2 then S 1 else S 2 해석 ① if c 1 then (if c 2 then S 1 else S 2) ② if c 1 then (if c 2 then S 1) else S 2 각 언어에서 해결책 Algol 60: Algol 68: ① if c 1 then begin if c 2 then S 1 else S 2 end ① if c 1 then if c 2 then S 1 else S 2 fi fi ② if c 1 then begin if c 2 then S 1 end else S 2 ② if c 1 then if c 2 then S 1 fi else S 2 fi PL/I : Pascal : ② IF c 1 THEN IF c 2 THEN S 1; ELSE S 2; 또는 IF c 1 THEN IF c 2 THEN S 1; ELSE S 2; ※ PL/1과 pascal은 일반적으로 ①의 경우로 해석 ② if c 1 then begin if c 2 then S 1 end else S 2 또는 if c 1 then if c 2 then S 1 else S 2

슬라이드 쇼가 끝났습니다. 2004 Y. H. Won, Hongik University. All rights reserved. 35

슬라이드 쇼가 끝났습니다. 2004 Y. H. Won, Hongik University. All rights reserved. 35

어휘 토큰 (lexical token), 어휘 요소 (lexical element), 어휘 단위 (lexical unit) 용어 국제

어휘 토큰 (lexical token), 어휘 요소 (lexical element), 어휘 단위 (lexical unit) 용어 국제 표준 규격 15. 01 lexical token lexical element lexical unit 어휘 토큰 어휘 요소 어휘 단위 A string of one or more characters of the alphabet of a programming language that, by convention, represents an elemental unit of meaning. <Example> A literal such as 2 G 5 or an identifier such as last_name in Pascal. 규약에 의거하여 기본 의미 단위를 표현하는, 한 개 이상의 프로그램 언어의 알파벳 문자로 구성된 문자열 <예> 2 G 5와 같은 리터럴 또는 Pascal에서 last_name과 같은 식별자 2004 Y. H. Won, Hongik University. All rights reserved. 37

38 언어 구성자 (language construct) 용어 국제 표준 규격 15. 01. 02 language construct

38 언어 구성자 (language construct) 용어 국제 표준 규격 15. 01. 02 language construct 언어 구성자 A syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language. 프로그래밍 언어의 규칙에 따라서 한 개 이상의 어휘 토큰으로 형성되며, 구문적으로 허용된 프로그램의 일부 2004 Y. H. Won, Hongik University. All rights reserved.

39 식별자 (identifier) 용어 국제 표준 규격 15. 01. 03 identifier (in programming language)

39 식별자 (identifier) 용어 국제 표준 규격 15. 01. 03 identifier (in programming language) 식별자 (프로그래밍 언어에서) A lexical token that names a language construct. <Examples> the names of variables, arrays, records, labels, procedures, etc. <NOTE> An identifier usually consists of a letter optionally followed by letters, digits, or other characters. 언어 구성자를 명명하는 어휘 토큰 <예> 변수, 배열, 레코드, 레이블, 프로시저 등의 이름 <주> 식별자는 일반적으로 문자가 맨 앞에 오고 그 뒤에 영문자, 숫자, 또는 그 밖의 문자가 0개 이상 따라오도록 구성된다. 2004 Y. H. Won, Hongik University. All rights reserved.

40 미리 정의된 식별자 (predefined identifier) 용어 국제 표준 규격 15. 01. 04 predefined

40 미리 정의된 식별자 (predefined identifier) 용어 국제 표준 규격 15. 01. 04 predefined identifier 미리 정의된 식별자 An identifier that is defined as part of a programming language. <Example> A reserved word. <NOTE> If a predefined identifier is not reserved, then a declaration using that identifier redefines its meaning for the scope of the declaration. 프로그래밍 언어의 일부로 정의된 식별자이다. <예> 예약어 <주> 미리 정의된 식별자가 예약되어 있지 않다면, 그 식별자를 사용한 선언으로 선언의 영역에서 식별자의 의미를 재정의 할 수 있다. 2004 Y. H. Won, Hongik University. All rights reserved.

41 예약어 (reserved words or key words) 용어 국제 표준 규격 15. 01. 05

41 예약어 (reserved words or key words) 용어 국제 표준 규격 15. 01. 05 reserved word 예약어 A predefined identifier that cannot be redefined by a programmer. <NOTE> Not all programming languages have reserved words. 프로그래머가 재정의할 수 없는 미리 정의된 식별자 <주> 모든 프로그래밍 언어가 예약어를 가지고 있는 것은 아니다. 2004 Y. H. Won, Hongik University. All rights reserved.

42 모호성 제거 용어 국제 표준 규격 15. 01. 09 disambiguation 모호성 제거 The

42 모호성 제거 용어 국제 표준 규격 15. 01. 09 disambiguation 모호성 제거 The action of determining which language construct, of several whit the same sequence of lexical tokens, is referred to by a particular occurrence within a program. 동일한 어휘 토큰 순서를 가진 다수의 언어 구성자 중 어떤 언어 구성자를 프로그램 내의 특정 사건이 참조하는지 결정하는 행위 2004 Y. H. Won, Hongik University. All rights reserved.