슬라이드 1

Size: px
Start display at page:

Download "슬라이드 1"

Transcription

1 LEX & YACC An Introduction Aug 2009

2 Part I. (F)LEX

3 Overview of Lex Automata Revisited 목표 : integer 또는 real number를 인식하는 Finite State Automaton 작성 (단, 소수점 이후에는 숫자가 하나 이상 있도록) accept : 정수 0~9 0~9 1~9. 0~9 S accept : 실수 starting state 0. accept : zero 3

4 Overview of Lex What s (F)lex? Lex = Lexical Analyzer Generator Flex = The Fast Lexical Analyzer - 오래된 Lex 에 대한 대체 프로그램 (Adobe Flex 와는 무관) Scanner (=tokenizer) 생성을 위한 도구 - recognize lexical patterns in text 확장 regular expression으로 패턴 규칙을 명시하고, 각 규칙에 대해 액션을 지정한다 Lex code lex C/C++ code 주어진 패턴을 분석할 수 있는 DFA (Deterministic Finite Automata) 코드를 생 성 4

5 Overview of Lex Lex 프로그램의 구조 Definitions section %% Rules section C/C++ code block simple name definitions start conditions patterns & actions %% User code section user-supplied C/C++ code 5

6 %{ #include <stdio.h> #include <string.h> #include <math.h> %} DIGIT [0-9] HEX [0-9A-Fa-f] ID [A-Za-z][A-Za-z0-9]* DOT "." %% {DIGIT}+{DOT}{DIGIT}* {DIGIT}+ printf("[%s]: float, value=%g\n", yytext, atof(yytext)); printf("[%s]: decimal, value=%d\n", yytext, atoi(yytext)); "0"[Xx]{HEX}+ { printf("[%s]: hexadecimal, value=%ld\n", yytext, strtol(yytext+2,0,16)); } {ID} printf("[%s]: identifier\n", yytext); [ \t\n]+ ;. printf("[%s]: unknown input\n", yytext); patterns actions %% #ifndef yywrap extern "C" int yywrap() { return 1; } #endif

7 $ ls foo.l main.cpp $ cat main.cpp #include <stdio.h> extern int yylex(); int main() { return yylex(); } $ flex foo.l $ ls foo.l lex.yy.c main.cpp $ c++ -c lex.yy.c main.cpp ; c++ *.o $ ls a.out foo.l lex.yy.c lex.yy.o main.cpp main.o $./a.out jbkang xAC00 foo123 what's up? [jbkang]: identifier [100]: decimal, value=100 [ ]: float, value= [0xAC00]: hexadecimal, value=44032 [foo123]: identifier [what]: identifier [']: unknown input [s]: identifier [up]: identifier [?]: unknown input

8 Lex Definitions Code Block %{ 과 %} 사이에 임의의 C/C++ 코드 삽입 가능 #include, #define, 변수 및 함수 선언 등에 사용 Simple Name Definitions 일종의 macro라고 보면 됨 %{ #include <stdio.h> #include <string.h> #include <math.h> %} definition에는 확장 regular expression 사용 가능 Start Conditions Lex에서는 규칙을 조건적으로 적용 가능 그런 경우들을 symbolic하게 정의해둠 DIGIT [0-9] HEX [0-9A-Fa-f] ID [A-Za-z][A-Za-z0-9]* DOT "." %x COMMENT 8

9 Lex Rules Patterns x Character x. Newline (\n) 제외한 모든 char [xyz] [abc-gz] [^A-Z\n] x, y, z 중 하나 a, b, c ~ g사이, z 중 하나 대문자와 newline을 제외한 모든 char {DIGIT}+ {DIGIT}+{DOT}{DIGIT}* R* R+ R? 0 or more; 1 or more; optional R R{4} R{2,5} 4번의 R; 2~5번의 R "0"[Xx]{HEX}+ {ID} {NAME} "[hello\"" \n\t\b\f \xba definitions section에 정의된 NAME이라는 패 턴 문자 그대로의 [hello" C언어에서와 같음 16진수로 0xBA인 char [ \t\n]+. ^R R$ 행 시작에 있는 R; 행 끝에 있는 R <sc>r Start condition = sc 일 때의 R 9

10 Lex Rules Actions 아무 C/C++ statement나 사용 가능. 여러 줄에 걸칠 때는 { } 로 싸 준다. 여러 pattern에 대해 같은 action일 경우 로 이어준다. 예) a b printf( matched a or b\n ); Special Directives ECHO : 현재 매치된 내용(yytext)을 그대로 출력(yyout) BEGIN : 특정 start condition을 시작함 ( 초기 condition은 INITIAL 로 정의) REJECT : 현재 패턴에 대한 second best rule로 넘어감 10

11 C Language Interface Available to the User int yylex(void) char* yytext int yyleng FILE* yyin void yyrestart(file*) FILE* yyout lexical analyzer 메인 함수 현재 매치된 token 현재 매치된 token의 길이 입력 스트림 (default: stdin) 입력을 전환함 출력 스트림 (default: stdout) (cf. ECHO) YY_CURRENT_BUFFER 현재 text buffer의 핸들 (메모리 해제시 등) YY_START 현재 start condition을 나타내는 정수 값 (cf. BEGIN) Supplied by User int yywrap(void) 입력이 끝났을 때 종료 (return 1) 혹은 계속 (return 0) 11

12 Starting Conditions Example : One-Line Comment int commentcaller; %x COMMENT %% // commentcaller = YY_START; BEGIN(COMMENT); \n. /* anything else is ignored */; <COMMENT>{ \r\n \n BEGIN(commentCaller);. /* eat up comment */; } %% 12

13 The Generated Scanner lex.yy.c 의 대략적인 구조 state transition 등 각종 table을 비롯한 global 정의; int yylex() { loop { scan된 token에 따라 state 변경; action 수행; yyin EOF 이면 return 0; (입력이 여러개라면 caller측에서 yyrestart()로 전환하면 됨) action에 return이 있을 경우 해당 값으로 return; (다음 yylex 호출시는 거기서 resume) } } 그 외 각종 support functions. 13

14 %{ #include <stdio.h> #include <string.h> #include <math.h> %} 다시 봅시다.. DIGIT [0-9] HEX [0-9A-Fa-f] ID [A-Za-z][A-Za-z0-9]* DOT "." %% {DIGIT}+{DOT}{DIGIT}* {DIGIT}+ printf("[%s]: float, value=%g\n", yytext, atof(yytext)); printf("[%s]: decimal, value=%d\n", yytext, atoi(yytext)); "0"[Xx]{HEX}+ { printf("[%s]: hexadecimal, value=%ld\n", yytext, strtol(yytext+2,0,16)); } {ID} printf("[%s]: identifier\n", yytext); [ \t\n]+ ;. printf("[%s]: unknown input\n", yytext); %% #ifndef yywrap extern "C" int yywrap() { return 1; } #endif int main() { return yylex(); }

15 Part II. YACC

16 Overview of Yacc What s Yacc? Yet Another Compiler-Compiler 컴파일러 제작에서 Parser (Syntactic Analyzer) 생성을 위한 도구 Lex와 함께 1975년 발표되었음 Yacc code yacc C/C++ code Lexical analyzer를 필요로 함 (따라서 lex와 종종 같이 쓰임) GNU Bison, Berkeley Yacc, MKS Yacc 등의 변종이 있음 16

17 The Power of Automata? Lex로 처리할 수 없는 패턴? 예 1. ((( a ) b ) c ) 예 2. a k b k, k 0 현재 state와 input만 알 수 있을 뿐, 지난 일을 기억해둘 수는 없다. Finite State Automata 혹은 regular language의 한계. 기억 을 위해 Stack을 추가 Pushdown Automata 이런 식으로 automata의 능력이 증대되면, 인식 가능한 패턴들이 더 늘어난다...사람이란, 기억의 총합인가? from <Ghost in the Shell> 17

18 Formal Language Theory 먼저, 용어부터 단 어 설 명 비 고 alphabet a set of symbols { 0, 1 } string ordered sequence of symbols ε empty string epsilon language a set of words (finite strings) { 00, 01, 10, 11, ε } terminal literal string을 나타내는 기호 (트리 단말 노드를 연상) a nonterminal production rule을 나타내는 기호 (트리 중간 노드) A production rule grammar LHS RHS 형태로 된, symbol sequence의 rewriting rule 어떤 string이 특정 language에 속하는지를 기술하기 위한 변환 규칙의 집합. A ab terminals, nonterminals, rules, starting symbol 18

19 Formal Language Theory Formal Language Theory? (formal) language : a set of finite strings formal language theory : 이런 언어들의 구조적인 성질을 연구하는 분야 (의 미: ) language가 grammar에 의해 생성 혹은 grammar가 language를 인식 Different Power of Grammars grammars minimal automaton 비 고 Type-0 Unrestricted Turing Machine α β Type-1 Context- Sensitive Linear-bounded αaβ αγβ Nondeterministic Type-2 Context-Free V w cf. Yacc Pushdown See Chomsky Type-3 hierarchy Regular Finite A ab a cf. Lex 19

20 Regular Grammar Regular Language 다음에 의해 정의된다: - alphabet에 속하는 각 symbol들과 empty string ε - union (A B), concatenation (AB) - Kleene star (A*) /'kleini:/ Production Rule A a / A ab / A ε 의 모습 right regular grammar A a / A Ba / A ε 의 모습 left regular grammar a*는 A aa, A ε로 표현 가능 +와?는 불필요 : a+ 는 aa*로, a? 는 ( a ε) 로 대체 Regular Expression : expressive power가 regular language를 종종 넘어선 다. 20

21 Context-Free Grammar 특 징 프로그래밍 언어와 컴파일러의 설계에서 핵심적인 역할 자연언어 처리에서도 종종 사용됨 1950년대에 언어학자 Noam Chomsky에 의해 제시 (cf. Chomsky hierarchy) Production Rule V w 의 모습 : V는 nonterminal 이고 w는 (term nonterm)* 좌항(LHS)이 하나뿐이라 앞뒤 문맥과 무관하다고 해서 context-free라고 함 언어 { a k b k k 0 } 을 생성하는 CFG의 예 : S a S b S ε S S S S S a a a ε b b b 21

22 Context-Free Grammar Pushdown Automata Context-Free Language 를 생성 { a k b k k 0 } 를 생성하는 오토마타의 예 push A a ; Z/AZ a ; A/AA b ; A/ε pop ε ε; Z/Z A, Z : stack alphabet Z : initial stack symbol 22

23 So Far So Good.. So What? Where is Yacc? 많은 프로그래밍 언어가 그 문법을 BNF (Backus-Naur Form) 로 정의한다. C 언어의 예 : <Typedef Decl> ::= typedef <Type> ID ';' Yacc에서는 BNF 와 유사한 방식으로 Context-Free Grammar를 기술할 수 있다. typedef_decl : T_TYPEDEF type T_ID ';' (물론 프로그래밍 언어 외의 용도로도 쓸 수 있다) What about Lex? Yacc는 내부적으로 yylex()를 호출 Lex의 yylex()는 입력으로부터 token들 (terminal) 을 추려내어 yacc에게 공급 yylex()의 return 값을 yacc에서 token 종류로 인식 (예: T_ID) token definition은 y.tab.h 헤더파일을 통해 공유 23

24 Compilation Sequence source code a = b + c * d Lexical Analyzer Lex patterns tokens id1 = id2 + id3 * id4 Syntactic Analyzer Yacc grammar syntax tree id1 = + id2 * id3 id4 Code Generator generated code LDA id3 MUL id4 ADD id2 STO id1 from 24

25 Lex & Yacc Co-operating foo.y yacc y.tab.c source code yyparse() y.tab.h cc foo.exe foo.l lex lex.yy.c yylex() compiled output from 25

26 Overview of Yacc Yacc 프로그램의 구조 %{ %} Prologue Declarations %% Lex와 거의 같다 Grammar Rules %% Epilogue 26

27 Sample Code : foo.l %{ #include <stdio.h> #include <string.h> #include <math.h> #include <string> #include <map> #include "y.tab.h" using namespace std; typedef map<string,int>::iterator MapIter; namespace { // local scope } %} map<string,int> symtab; int symindex( const char* ); DIGIT [0-9] HEX [0-9A-Fa-f] ID [A-Za-z][A-Za-z0-9]* DOT "." %% %% #ifndef yywrap extern "C" int yywrap() { return 1; } #endif namespace { int symindex( const char* s ) { MapIter it = symtab.find(s); if( it == symtab.end() ) { int idx = symtab.size(); symtab.insert( map<string,int>::value_type(s,idx)); return idx; } else { return it->second; } } } // namespace // EOF {DIGIT}+{DOT}{DIGIT}* yylval.fval = atof(yytext); return T_FLOAT; {DIGIT}+ yylval.ival = atoi(yytext); return T_INT; "0"[Xx]{HEX}+ yylval.ival = strtol(yytext+2,0,16); return T_INT; {ID} yylval.ival = symindex(yytext); return T_ID; [ \t\n]+ /* skip whitespaces */;. return yytext[0];

28 Sample Code : foo.y %{ #include <stdio.h> extern int yylex( void ); int yyerror( char* ); %} %union { int ival; float fval; }; %token <ival> T_ID T_INT %token <fval> T_FLOAT %% stmts stmt : stmts stmt none ; : assign_stmt ; assign_stmt : T_ID '=' T_INT ';' { printf("assignment: ID (idx=%d) <= INT (val=%d)\n", $1, $3); } T_ID '=' T_FLOAT ';' { printf("assignment: ID (idx=%d) <= FLOAT (val=%g)\n", $1, $3); } ; none : /* empty */ ; %% int yyerror( char *s ) { fprintf(stderr, "%s\n", s); return 0; } int main() { return yyparse(); }

29 $ ls Makefile Makefile.dep foo.l foo.y $ make flex -8 foo.l yacc -d foo.y g++ -Wall -O -c lex.yy.c g++ -Wall -O -c y.tab.c g++ -o a.out lex.yy.o y.tab.o $ ls Makefile a.out foo.y lex.yy.o y.tab.h Makefile.dep foo.l lex.yy.c y.tab.c y.tab.o $./a.out foo=100; assignment: ID (idx=0) <= INT (val=100) foo2 = 200 ; assignment: ID (idx=1) <= INT (val=200) bar = 0x1010; assignment: ID (idx=2) <= INT (val=4112) foo2 = ; assignment: ID (idx=1) <= FLOAT (val= )

30 Yacc Declarations %union token이나 nonterminal들이 가질 수 있는 value type이 int가 아닐 때 별도로 지정 %union { int ival; double dval; } %token %right %left %nonassoc token의 이름 선언 %union이 쓰였으면 value type도 지정 token (주로 연산자) 을 선언하면서 associativity (결합 방향) 와 우선순위 (나중에 나온것이 높다) 를 지정 %token T_NUM %token <ival> T_NUM %left T_PLUS T_MINUS %left T_MULTIPLY T_DIVIDE %type %union이 쓰였을 때 nonterminal의 value type 지정 %type <ival> some_expr %start 이 grammar의 start symbol 지정 미지정시 첫번째 rule의 LHS로 간주 %start stmts 30

31 Yacc Grammar Rules Rule LHS : RHS ; 의 형태로 문법을 기술한다. - LHS에는 하나의 nonterminal, RHS에는 terminal / nonterminal 들이 온다. (CFG니 까) 같은 LHS에 대해 여러 RHS를 로 연결할 수 있다. 예) assign_stmt : T_ID '=' T_INT ';' T_ID '=' T_FLOAT ';' ; Action 각 grammar rule 마다 { } 사이에 C/C++ 코드로 액션을 지정한다. special symbols - $$ : 현재 LHS의 value - $1, $2, : 현재 RHS에서 첫번째 심볼, 두번째 심볼, 예) { printf("id (idx=%d): INT (val=%d)\n", $1, $3); $$ = $3; } 31

32 Yacc Grammar Rules Recursive Rules A*, A+, A? 는 regular grammar때와 동일한 방법으로 표현 - A* S : S a ε ; - A+ S : S a a ; - A? S : a ε ; 구현시에는 left recursion 형태의 규칙만 써야 함 (right recursion은 stack에다 나머지 심볼들을 모두 쌓아야 해서 제한이 발생) Empty Rule ε 에 대한 rule은 아래와 같이 하면 된다 empty : /* just a comment */ ; 32

33 C Language Interface Available to the User int yyparse(void) YYACCEPT YYABORT int yylex(void) yylval top level parser function 성공, 0을 리턴하는 매크로 실패, 1을 리턴하는 매크로 Lex가 생성한걸 쓰던지 사용자가 직접 작성 token이 가진 값. 기본값은 int 이며 %union이 지정된 경우 그 중 한 값이 된다. (Lex에서 사용) Supplied by User yyerror void yyerror( const char* ) 정도면 무난함 33

34 Debugging Grammar Rules ADV How to Debug Grammar yacc v 옵션으로 parsing table 파일 생성 (y.output) yacc conflict 메시지와 parsing table에 기초하여 문법 수정 Grammar Ambiguity 어떤 상황에서 action이 유일하게 정의되지 않는 경우 shift/reduce 와 reduce/reduce conflict가 있다. shift/reduce conflict의 예: if_stmt : IF cond THEN stmt IF cond THEN stmt ELSE stmt 34

35 Sample y.output ADV Grammar state 0 state 1 state 2 0 $accept: S $end 1 S: a b 2 a S b 0 $accept:. S $end a shift, and go to state 1 S go to state 2 1 S: a. b 2 a. S b a shift, and go to state 1 b shift, and go to state 3 S go to state 4 0 $accept: S. $end $end shift, and go to state 5 state 3 1 S: a b. $default reduce using rule 1 (S) state 4 2 S: a S. b b shift, and go to state 6 state 5 0 $accept: S $end. $default accept state 6 2 S: a S b. $default reduce using rule 2 (S)??

36 Parser Architecture ADV Table-based Bottom-up Parser input ID = NUM + NUM ; stack Parser grammar output state들 action table goto table state transition 및 rule reduction 정보 See 36

37 The Parsing Table ADV Shift Action 현재 state에서 Terminal 을 만났을 때. (예: s3) 현재 input token을 소비한다. 주어진 next state를 stack에 push 한다. Reduce Action 현재 state에서 Nonterminal 이 생성될 때. (예: r2) 생성에 관련된 rule 번호가 주어진다. input은 그대로 둔다. stat e action goto a b $ S 0 s1 2 1 s1 s3 4 2 s5 3 r1 r1 r1 4 s6 5 acc acc acc 6 r2 r2 r2 rule의 RHS에 있는 심볼 수 만큼 stack에서 pop 한다. (예: S a S b 는 3개) GOTO table에서 (stack[top], nonterminal) 의 entry를 찾아서 next state로 삼고 stack에 push 한다. 37

38 Parsing Procedure Example ADV { a k b k k 1 } 를 생성하는 grammar aabb$ 의 파싱 과정 (1) S : a b (2) a S b stack input act next output stat e action goto a b $ S 0 s1 2 1 s1 s3 4 2 s5 3 r1 r1 r1 4 s6 5 acc acc acc 6 r2 r2 r2 앞 페이지에 나온 테이블 (yacc가 내부적으로 만든다) [0] aabb$ s1 1 [0,1] abb$ s1 1 [0,1,1] bb$ s3 3 [0,1,1,3] b$ r1 4 (1) [0,1,4] b$ s6 6 [0,1,4,6] $ r2 2 (1) (2) [0,2] $ s5 5 [0,2,5] $ acc 38

39 Yacc Review Parser Generator Context-Free Grammar, Pushdown Automata Lex return value & yylval y.tab.h %union, %token Production Rule terminal, nonterminal, LHS, RHS shift, reduce, conflict parsing table, y.output 終 39

컴파일러

컴파일러 YACC 응용예 Desktop Calculator 7/23 Lex 입력 수식문법을위한 lex 입력 : calc.l %{ #include calc.tab.h" %} %% [0-9]+ return(number) [ \t] \n return(0) \+ return('+') \* return('*'). { printf("'%c': illegal character\n",

More information

商用

商用 商用 %{ /* * line numbering 1 */ int lineno = 1 % \n { lineno++ ECHO ^.*$ printf("%d\t%s", lineno, yytext) $ lex ln1.l $ gcc -o ln1 lex.yy.c -ll day := (1461*y) div 4 + (153*m+2) div 5 + d if a then c :=

More information

1. 27 (token descriptions) (regular expressions), grep egrep.. C. 1),., C (expressions), (statements), (declarations), (blocks) (procedures). (parsing

1. 27 (token descriptions) (regular expressions), grep egrep.. C. 1),., C (expressions), (statements), (declarations), (blocks) (procedures). (parsing (lex) (yacc). (object code) C. (unit).. C,,,,. ( ) (lexical analysis) (lexing). C (routine). (lexical analyzer) (lexer) (scanner). (lex specification). 1. 27 (token descriptions) (regular expressions),

More information

EA0015: 컴파일러

EA0015: 컴파일러 4 Flex 무엇을공부하나? " 어휘분석기 (lexical analyzer 혹은 scanner)" 는다음과같은과정을거쳐서프로그램된다. 1 토큰정의, 2 정규식으로표현, 3 NFA로변환, 4 DFA로변환, 5 프로그램작성 위과정은앞장에서배운바와같이기계적으로이루어질수있다. "Flex(Fast Lexical Analyzer)" 는컴파일러개발자를위하여위과정을자동으로처리해주는도구이다.

More information

untitled

untitled 5. hamks@dongguk.ac.kr (regular expression): (recognizer) : F(, scanner) CFG(context-free grammar): : PD(, parser) CFG 1 CFG form : N. Chomsky type 2 α, where V N and α V *. recursive construction ) E

More information

lex-yacc-tutorial.hwp

lex-yacc-tutorial.hwp 컴파일러 구성을 위한 대표적 소프트웨어 도구인 Lex(또는 Flex)와 Yacc(또는 Bison) 입문: Windows 환경에서 김도형(성신여자대학교 IT학부) 0. 소개 (1) Lex와 Yacc은 무엇인가? 컴파일러의 구성을 도와주는 대표적인 소프트웨어 도구들이다. 원래 UNIX의 산실인 벨 연구소(AT&T Bell Laboratories)에서 UNIX 시스템의

More information

4.18.국가직 9급_전산직_컴퓨터일반_손경희_ver.1.hwp

4.18.국가직 9급_전산직_컴퓨터일반_손경희_ver.1.hwp 2015년도 국가직 9급 컴퓨터 일반 문 1. 시스템 소프트웨어에 포함되지 않는 것은? 1 1 스프레드시트(spreadsheet) 2 로더(loader) 3 링커(linker) 4 운영체제(operating system) - 시스템 소프트웨어 : 운영체제, 데이터베이스관리 프로그램,, 컴파일러, 링커, 로더, 유틸리티 소프트웨 어 등 - 스프레드시트 : 일상

More information

자연언어처리

자연언어처리 제 7 장파싱 파싱의개요 파싱 (Parsing) 입력문장의구조를분석하는과정 문법 (grammar) 언어에서허용되는문장의구조를정의하는체계 파싱기법 (parsing techniques) 문장의구조를문법에따라분석하는과정 차트파싱 (Chart Parsing) 2 문장의구조와트리 문장 : John ate the apple. Tree Representation List

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

Microsoft PowerPoint - PL_03-04.pptx

Microsoft PowerPoint - PL_03-04.pptx Copyright, 2011 H. Y. Kwak, Jeju National University. Kwak, Ho-Young http://cybertec.cheju.ac.kr Contents 1 프로그래밍 언어 소개 2 언어의 변천 3 프로그래밍 언어 설계 4 프로그래밍 언어의 구문과 구현 기법 5 6 7 컴파일러 개요 변수, 바인딩, 식 및 제어문 자료형 8

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어 개나리 연구소 C 언어 노트 (tyback.egloos.com) 프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어먹고 하더라구요. 그래서,

More information

Microsoft PowerPoint - PLT_ch04_KOR

Microsoft PowerPoint - PLT_ch04_KOR Chapter 4 : 구문(Syntax) Lexical Structure Syntactic Structure: BNF, EBNF, Syntax Diagrams Parse Tree, Syntax Tree, and Ambiguity Parsing Techniques and Tools Lexics vs. Syntax vs. Semantics Introduction

More information

C++-¿Ïº®Çؼ³10Àå

C++-¿Ïº®Çؼ³10Àå C C++. (preprocessor directives), C C++ C/C++... C++, C. C++ C. C C++. C,, C++, C++., C++.,.. #define #elif #else #error #if #itdef #ifndef #include #line #pragma #undef #.,.,. #include #include

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

3장 어휘분석

3장 어휘분석 Video & Image VIPL Processing Lab. Compiler Construction 한국방송통신대학교컴퓨터과학과출석수업 제 2012-2 공학박사김명진 (HCI & 지능형로봇연구소 ) 숭실대학교연구교수 컴파일러교재구성 2장 : 형식언어와오토마타 3장 : 어휘분석 4장 : Contex-free 언어와푸시다운오토마타 5장 : 구문분석 2 어휘분석

More information

EA0015: 컴파일러

EA0015: 컴파일러 5 Context-Free Grammar 무엇을공부하나? 앞에서배운 " 정규식 " 은언어의 " 어휘 (lexeme)" 를표현하는도구로사용되었다. 언어의 " 구문 (syntax)" 은 " 정규언어 " 의범위를벗어나기때문에 " 정규식 " 으로표현이불가능하다. 본장에서배우는 " 문맥자유문법 " 은언어의 " 구문 (syntax)" 을표현할수있는도구이다. 어떤 " 문맥자유문법

More information

중간코드생성

중간코드생성 컴파일러구성 제 11 강 결정적구문분석 10.1 10.2 10.3 10.4 Introduction Syntax-Directed Translation Code Generation U-Code Translator Formal Specification lexical structure : regular expression syntactic structure : context-free

More information

MPLAB C18 C

MPLAB C18 C MPLAB C18 C MPLAB C18 MPLAB C18 C MPLAB C18 C #define START, c:\mcc18 errorlevel{0 1} char isascii(char ch); list[list_optioin,list_option] OK, Cancel , MPLAB IDE User s Guide MPLAB C18 C

More information

Microsoft PowerPoint - chap03-변수와데이터형.pptx

Microsoft PowerPoint - chap03-변수와데이터형.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num %d\n", num); return 0; } 1 학습목표 의 개념에 대해 알아본다.

More information

DIY 챗봇 - LangCon

DIY 챗봇 - LangCon without Chatbot Builder & Deep Learning bage79@gmail.com Chatbot Builder (=Dialogue Manager),. We need different chatbot builders for various chatbot services. Chatbot builders can t call some external

More information

03장.스택.key

03장.스택.key ---------------- DATA STRUCTURES USING C ---------------- 03CHAPTER 1 ? (stack): (LIFO:Last-In First-Out) 2 : top : ( index -1 ),,, 3 : ( ) ( ) -> ->. ->.... 4 Stack ADT : (LIFO) : init():. is_empty():

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 가 제공하는 매크로 상수와 매크로

More information

Microsoft PowerPoint - chap5.ppt

Microsoft PowerPoint - chap5.ppt 제 5 장 Context-Free 문법 상지대학교컴퓨터정보공학부고광만 (kkman@mail.sangji.ac.kr) Contents 5.1 서론 5.2 유도와유도트리 5.3 문법변환 5.4 CFG 표기법 5.5 Push Down Automata; PDA 5.6 Context-free 언어와 PDA 언어 제 5 장 : Context-Free Grammar 2

More information

untitled

untitled - -, (insert) (delete) - - (insert) (delete) (top ) - - (insert) (rear) (delete) (front) A A B top A B C top push(a) push(b) push(c) A B top pop() top A B D push(d) top #define MAX_STACK_SIZE 100 int

More information

untitled

untitled 3. hmks@dongguk.c.kr..,, Type 3 (N. Chomsky) RLG : A tb, A t LLG : A Bt, A t where, A,B V N nd t V T *. LLG RLG,. ) G : S R S c R Sb L(G) = { n cb n n } is cfl. () A grmmr is regulr if ech rule is i) A

More information

강의10

강의10 Computer Programming gdb and awk 12 th Lecture 김현철컴퓨터공학부서울대학교 순서 C Compiler and Linker 보충 Static vs Shared Libraries ( 계속 ) gdb awk Q&A Shared vs Static Libraries ( 계속 ) Advantage of Using Libraries Reduced

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Verilog: Finite State Machines CSED311 Lab03 Joonsung Kim, joonsung90@postech.ac.kr Finite State Machines Digital system design 시간에배운것과같습니다. Moore / Mealy machines Verilog 를이용해서어떻게구현할까? 2 Finite State

More information

Microsoft PowerPoint - a10.ppt [호환 모드]

Microsoft PowerPoint - a10.ppt [호환 모드] Structure Chapter 10: Structures t and Macros Structure 관련된변수들의그룹으로이루어진자료구조 template, pattern field structure를구성하는변수 (cf) C언어의 struct 프로그램의 structure 접근 entire structure 또는 individual fields Structure는

More information

106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float

106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float Part 2 31 32 33 106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float f[size]; /* 10 /* c 10 /* f 20 3 1

More information

Microsoft Word - FunctionCall

Microsoft Word - FunctionCall Function all Mechanism /* Simple Program */ #define get_int() IN KEYOARD #define put_int(val) LD A val \ OUT MONITOR int add_two(int a, int b) { int tmp; tmp = a+b; return tmp; } local auto variable stack

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

OCaml

OCaml OCaml 2009.. (khheo@ropas.snu.ac.kr) 1 ML 2 ML OCaml INRIA, France SML Bell lab. & Princeton, USA nml SNU/KAIST, KOREA 3 4 (let) (* ex1.ml *) let a = 10 let add x y = x + y (* ex2.ml *) let sumofsquare

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

형식 언어

형식 언어 컴파일러개요 아주대학교정보및컴퓨터공학부 목차 컴파일러란 프로그래밍언어 관련프로그램들 컴파일러의일반적인구조 컴파일러자동화도구 Compiler 2 컴파일러란 Compiler A compiler is a computer program which translates programs written in a particular high-level programming

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

n 정의 정규표현 (Regular Expression) n 정규문법 G 를대수학적인성질로표현 n 정규언어에속해있는스트링의모양을직접기술 n 정규문법은문법이나타내는언어의형태를체계적으로구하여정규표현으로나타낼수있음. 정규문법 (Regular ) 정규표현 (Regular ) 유

n 정의 정규표현 (Regular Expression) n 정규문법 G 를대수학적인성질로표현 n 정규언어에속해있는스트링의모양을직접기술 n 정규문법은문법이나타내는언어의형태를체계적으로구하여정규표현으로나타낼수있음. 정규문법 (Regular ) 정규표현 (Regular ) 유 Regular Expression and Context-free 상지대학교컴퓨터정보공학부고광만 (kkman@mail.sangji.ac.kr) 정규문법과정규언어 n 정규문법 (Regular ) n 촘스키 (Chomsky, N.) 문법규칙 -Type 3 n 토큰구조표현 ( 어휘분석단계 ) n 정규문법의형태 1 우선형문법 (right-linear grammar;

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

chap10.PDF

chap10.PDF 10 C++ Hello!! C C C++ C++ C++ 2 C++ 1980 Bell Bjarne Stroustrup C++ C C++ C, C++ C C 3 C C++ (prototype) (type checking) C C++ : C++ 4 C C++ (prototype) (type checking) [ 10-1] #include extern

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

USER GUIDE

USER GUIDE Solution Package Volume II DATABASE MIGRATION 2010. 1. 9. U.Tu System 1 U.Tu System SeeMAGMA SYSTEM 차 례 1. INPUT & OUTPUT DATABASE LAYOUT...2 2. IPO 중 VB DATA DEFINE 자동작성...4 3. DATABASE UNLOAD...6 4.

More information

Microsoft PowerPoint - semantics

Microsoft PowerPoint - semantics 제 3 장시맨틱스 (Semantics) Reading Chap 13 숙대창병모 Sep. 2007 1 3.1 Operational Semantics 숙대창병모 Sep. 2007 2 시맨틱스의필요성 프로그램의미의정확한이해 소프트웨어의정확한명세 소프트웨어시스템에대한검증혹은추론 컴파일러혹은해석기작성의기초 숙대창병모 Sep. 2007 3 의미론의종류 Operational

More information

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf(hihi\n); } warning: conflicting types for functiona 이름 : 학번 : A. True or False: 각각항목마다 True 인지 False 인지적으세요. 1. (Python:) randint 함수를사용하려면, random 모듈을 import 해야한다. 2. (Python:) '' (single quote) 는한글자를표현할때, (double quote) 는문자열을표현할때사용한다. B. 다음에러를수정하는방법을적으세요.

More information

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600 균형이진탐색트리 -VL Tree delson, Velskii, Landis에의해 1962년에제안됨 VL trees are balanced n VL Tree is a binary search tree such that for every internal node v of T, the heights of the children of v can differ by at

More information

HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M.

HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M. 오늘할것 5 6 HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M. Review: 5-2 7 7 17 5 4 3 4 OR 0 2 1 2 ~20 ~40 ~60 ~80 ~100 M 언어 e ::= const constant

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

Semantic Consistency in Information Exchange

Semantic Consistency in Information Exchange 제 3 장시맨틱스 (Semantics) Reading Chap 13 숙대창병모 1 시맨틱스의필요성 프로그램의미의정확한이해 소프트웨어의정확한명세 소프트웨어시스템에대한검증혹은추론 컴파일러혹은해석기작성의기초 숙대창병모 2 3.1 Operational Semantics 숙대창병모 3 의미론의종류 Operational Semantics 프로그램의동작과정을정의 Denotational

More information

제4장 기본 의미구조 (Basic Semantics)

제4장  기본 의미구조 (Basic Semantics) 제 4 장블록및유효범위 Reading Chap. 5 숙대창병모 1 4.1 변수선언및유효범위 숙대창병모 2 변수선언과유효범위 변수선언 Declaration before Use! 대부분의언어에서변수는사용전에먼저선언해야한다. 변수의유효범위 (scope) 선언된변수가유효한 ( 사용될수있는 ) 프로그램내의범위 / 영역 변수이름뿐아니라함수등다른이름도생각해야한다. 정적유효범위

More information

Microsoft PowerPoint - chap04-연산자.pptx

Microsoft PowerPoint - chap04-연산자.pptx int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); } 1 학습목표 수식의 개념과 연산자, 피연산자에 대해서 알아본다. C의 를 알아본다. 연산자의 우선 순위와 결합 방향에

More information

본 강의에 들어가기 전

본 강의에 들어가기 전 C 기초특강 종합과제 과제내용 구조체를이용하여교과목이름과코드를파일로부터입력받아관리 구조체를이용하여학생들의이름, 학번과이수한교과목의코드와점수를파일로부터입력 학생개인별총점, 평균계산 교과목별이수학생수, 총점및평균을계산 결과를파일에저장하는프로그램을작성 2 Makefile OBJS = score_main.o score_input.o score_calc.o score_print.o

More information

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - additional01.ppt [호환 모드] 1.C 기반의 C++ part 1 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 함수 Jong Hyuk Park 함수오버로딩 (overloading) 함수오버로딩 (function overloading) C++ 언어에서는같은이름을가진여러개의함수를정의가능

More information

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures 단일연결리스트 (Singly Linked List) 신찬수 연결리스트 (linked list)? tail 서울부산수원용인 null item next 구조체복습 struct name_card { char name[20]; int date; } struct name_card a; // 구조체변수 a 선언 a.name 또는 a.date // 구조체 a의멤버접근 struct

More information

5.스택(강의자료).key

5.스택(강의자료).key CHP 5: https://www.youtube.com/watch?v=ns-r91557ds ? (stack): (LIFO:Last-In First-Out):. D C B C B C B C B (element) C (top) B (bottom) (DT) : n element : create() ::=. is_empty(s) ::=. is_full(s) ::=.

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

LXR 설치 및 사용법.doc

LXR 설치 및 사용법.doc Installation of LXR (Linux Cross-Reference) for Source Code Reference Code Reference LXR : 2002512( ), : 1/1 1 3 2 LXR 3 21 LXR 3 22 LXR 221 LXR 3 222 LXR 3 3 23 LXR lxrconf 4 24 241 httpdconf 6 242 htaccess

More information

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4 Introduction to software design 2012-1 Final 2012.06.13 16:00-18:00 Student ID: Name: - 1 - 0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

Modern Javascript

Modern Javascript ES6 - Arrow Function Class Template String Destructuring Default, Rest, Spread let, const for..of Promises Module System Map, Set * Generator * Symbol * * https://babeljs.io/ Babel is a JavaScript compiler.

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE ALTIBASE HDB 6.3.1.10.1 Patch Notes 목차 BUG-45710 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG-45730 ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG-45760 ROLLUP/CUBE 절을포함하는질의는 SUBQUERY REMOVAL 변환을수행하지않도록수정합니다....

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

OCW_C언어 기초

OCW_C언어 기초 초보프로그래머를위한 C 언어기초 4 장 : 연산자 2012 년 이은주 학습목표 수식의개념과연산자및피연산자에대한학습 C 의알아보기 연산자의우선순위와결합방향에대하여알아보기 2 목차 연산자의기본개념 수식 연산자와피연산자 산술연산자 / 증감연산자 관계연산자 / 논리연산자 비트연산자 / 대입연산자연산자의우선순위와결합방향 조건연산자 / 형변환연산자 연산자의우선순위 연산자의결합방향

More information

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 비트연산자 1 1 비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 진수법! 2, 10, 16, 8! 2 : 0~1 ( )! 10 : 0~9 ( )! 16 : 0~9, 9 a, b,

More information

Chapter 4. LISTS

Chapter 4. LISTS 연결리스트의응용 류관희 충북대학교 1 체인연산 체인을역순으로만드는 (inverting) 연산 3 개의포인터를적절히이용하여제자리 (in place) 에서문제를해결 typedef struct listnode *listpointer; typedef struct listnode { char data; listpointer link; ; 2 체인연산 체인을역순으로만드는

More information

슬라이드 1

슬라이드 1 3 장. 선행자료 어휘원소, 연산자와 C 시스템 박종혁교수 UCS Lab Tel: 970-6702 Email: jhpark1@seoultech.ac.kr SeoulTech 2019-1 st 프로그래밍입문 (1) 2 목차 1.1 문자와어휘원소 1.2 구문법칙 1.3 주석 1.4 키워드 (Keyword) 1.5 식별자 (Identifier) 1.6 상수 (Integer,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 DEVELOPMENT ENVIRONMENT 2 MAKE Jo, Heeseung MAKE Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one 2

More information

SIGPLwinterschool2012

SIGPLwinterschool2012 1994 1992 2001 2008 2002 Semantics Engineering with PLT Redex Matthias Felleisen, Robert Bruce Findler and Matthew Flatt 2009 Text David A. Schmidt EXPRESSION E ::= N ( E1 O E2 ) OPERATOR O ::=

More information

<B8AEC6F7C6AEBAE4BEEE20C0CEBCE2>

<B8AEC6F7C6AEBAE4BEEE20C0CEBCE2> 강의계획서 (Syllabus) 2018 학년도제 1 학기 교과목명 Title) 형식언어 학수번호 No. -Class No.) CSE4031-01 이수구분 Classification) 강의실 / 수업시간 (Classroom & Time) 전공 학점 (Credit) 월 7.0-8.0, 수 7.0-8.0 401-5145( 신공학관 ( 기숙사 ) 5145 강의실 ),401-5145(

More information

step 1-1

step 1-1 Written by Dr. In Ku Kim-Marshall STEP BY STEP Korean 1 through 15 Action Verbs Table of Contents Unit 1 The Korean Alphabet, hangeul Unit 2 Korean Sentences with 15 Action Verbs Introduction Review Exercises

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

10주차.key

10주차.key 10, Process synchronization (concurrently) ( ) => critical section ( ) / =>, A, B / Race condition int counter; Process A { counter++; } Process B { counter ;.. } counter++ register1 = counter register1

More information

Microsoft Word - ExecutionStack

Microsoft Word - ExecutionStack Lecture 15: LM code from high level language /* Simple Program */ external int get_int(); external void put_int(); int sum; clear_sum() { sum=0; int step=2; main() { register int i; static int count; clear_sum();

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Crash Unity SDK... Log & Crash Search. - Unity3D v4.0 ios

More information

untitled

untitled 1 hamks@dongguk.ac.kr (goal) (abstraction), (modularity), (interface) (efficient) (robust) C Unix C Unix (operating system) (network) (compiler) (machine architecture) 1 2 3 4 5 6 7 8 9 10 ANSI C Systems

More information

C 언어 프로그래밊 과제 풀이

C 언어 프로그래밊 과제 풀이 과제풀이 (1) 홀수 / 짝수판정 (1) /* 20094123 홍길동 20100324 */ /* even_or_odd.c */ /* 정수를입력받아홀수인지짝수인지판정하는프로그램 */ int number; printf(" 정수를입력하시오 => "); scanf("%d", &number); 확인 주석문 가필요한이유 printf 와 scanf 쌍

More information

(3) Windows 운영체제에 GNU C 컴파일러와 Flex, Bison 설치하기 적용된 Windows 운영체제는 32비트용 Windows 7이나, 다른버전에서도유사할것으로본다. 먼저 GNU C 컴파일러를설치한다. 이것을설치하는편한방법중하나가유명한무료 C/C++ 프로

(3) Windows 운영체제에 GNU C 컴파일러와 Flex, Bison 설치하기 적용된 Windows 운영체제는 32비트용 Windows 7이나, 다른버전에서도유사할것으로본다. 먼저 GNU C 컴파일러를설치한다. 이것을설치하는편한방법중하나가유명한무료 C/C++ 프로 컴파일러구성을위한대표적소프트웨어도구인 Lex( 또는 Flex) 와 Yacc( 또는 Bison) 입문 : Windows 환경에서 김도형 ( 성신여자대학교 IT 학부 ) 0. 소개 (1) Lex 와 Yacc 은무엇인가? 컴파일러의구성을도와주는대표적인소프트웨어도구들이다. 원래 UNIX의산실인벨연구소 (AT&T Bell Laboratories) 에서 UNIX 시스템의유틸리티

More information

Data structure: Assignment 1 Seung-Hoon Na October 1, Assignment 1 Binary search 주어진 정렬된 입력 파일이 있다고 가정하자. 단, 파일내의 숫자는 공백으로 구 분, file내에 숫자들은

Data structure: Assignment 1 Seung-Hoon Na October 1, Assignment 1 Binary search 주어진 정렬된 입력 파일이 있다고 가정하자. 단, 파일내의 숫자는 공백으로 구 분, file내에 숫자들은 Data structure: Assignment 1 Seung-Hoon Na October 1, 018 1 1.1 Assignment 1 Binary search 주어진 정렬된 입력 파일이 있다고 가정하자. 단, 파일내의 숫자는 공백으로 구 분, file내에 숫자들은 multiline으로 구성될 수 있으며, 한 라인에는 임의의 갯수의 숫자가 순서대로 나열될

More information

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout <<  양수입력 : ; cin >> *p; if (*p <= 0) cout <<  양수를입력해야합니다  << endl; return; 동적할 15 장기타주제들 auto_ptr 변환함수 cast 연산자에의한명시적형변환실행시간타입정보알아내기 (RTTI) C++ 프로그래밍입문 1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout > *p; if (*p

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Development Environment 2 Jo, Heeseung make make Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one It

More information

Microsoft PowerPoint - chap11-포인터의활용.pptx

Microsoft PowerPoint - chap11-포인터의활용.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 포인터를 사용하는 다양한 방법에

More information

Microsoft PowerPoint - Chapter_04.pptx

Microsoft PowerPoint - Chapter_04.pptx 프로그래밍 1 1 Chapter 4. Constant and Basic Data Types April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 기본자료형문자표현방식과문자자료형상수자료형변환 기본자료형 (1/8) 3 변수 (Variables)

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

HWP Document

HWP Document CODE A00-B99 A00-A09 A00 KOR_TITLE 특정 감염성 및 기생충성 질환 창자 감염 질환 콜레라 A00.0 비브리오 콜레리 01 전형균에 의한 콜레라 A00.0 전형균에 의한 콜레라 A00.1 비브리오 콜레리 01 엘토르형균에 의한 콜레라 A00.1 엘토르형균에 의한 콜레라 A00.9 상세불명의 콜레라 A01 A01.0 장티푸스 장티푸스

More information

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Function) 1. 함수의개념 입력에대해적절한출력을발생시켜주는것 내가 ( 프로그래머 ) 작성한명령문을연산, 처리, 실행해주는부분 ( 모듈 ) 자체적으로실행되지않으며,

More information

Microsoft PowerPoint - chap05-제어문.pptx

Microsoft PowerPoint - chap05-제어문.pptx int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); 1 학습목표 제어문인,, 분기문에 대해 알아본다. 인 if와 switch의 사용 방법과 사용시 주의사항에 대해 알아본다.

More information

C++ Programming

C++ Programming C++ Programming 연산자다중정의 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 연산자다중정의 C++ 스타일의문자열 2 연산자다중정의 연산자다중정의 단항연산자다중정의 이항연산자다중정의 cin, cout 그리고 endl C++ 스타일의문자열 3 연산자다중정의 연산자다중정의 (Operator

More information

Microsoft PowerPoint - 08-C-App-19-Quick-Preprocessor

Microsoft PowerPoint - 08-C-App-19-Quick-Preprocessor 19. 전처리와분할컴파일 순천향대학교컴퓨터학부이상정 1 학습내용 전처리명령어 #include #define 기호상수 const 분할컴파일 순천향대학교컴퓨터학부이상정 2 전처리과정 전처리 (preprocessor) 전처리명령어는 # 기호로시작 #incldue #define 순천향대학교컴퓨터학부이상정 3 #include (1) 지정된파일을프로그램에삽입 꺽쇠괄호는포함할파일을컴파일러에설정되어있는특정디렉토리에서검색

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \

int main(void) int a; int b; a=3; b=a+5; printf(a : %d \n, a); printf(b : %d \n, b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf( a : %x \ ? 1 int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \n", &a); printf(" b : %x \n", &b); * : 12ff60,

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information

2002년 2학기 자료구조

2002년 2학기 자료구조 자료구조 (Data Structures) Chapter 1 Basic Concepts Overview : Data (1) Data vs Information (2) Data Linear list( 선형리스트 ) - Sequential list : - Linked list : Nonlinear list( 비선형리스트 ) - Tree : - Graph : (3)

More information

Microsoft PowerPoint - KNK_C01_intro_kor

Microsoft PowerPoint - KNK_C01_intro_kor Program: Printing a Pun 파일이름은자유롭게짓되확장자는항상.c 로지정할것을권고 for example: pun.c #include // directive 지시자 C Fundamentals adopted from KNK C Programming : A Modern Approach int main(void) // function

More information

SNU =10100 =minusby by1000 ÇÁto0.03exÇÁto0.03exÇÁ=10100 =minusby by1000 ·Îto0.03ex·Îto0.03ex·Î=10100 =minusby by1000

SNU =10100 =minusby by1000 ÇÁto0.03exÇÁto0.03exÇÁ=10100 =minusby by1000 ·Îto0.03ex·Îto0.03ex·Î=10100 =minusby by1000 SNU 4190.210 프로그래밍 원리 (Principles of Programming) Part III Prof. Kwangkeun Yi 차례 1 값중심 vs 물건중심프로그래밍 (applicative vs imperative programming) 2 프로그램의이해 : 환경과메모리 (environment & memory) 다음 1 값중심 vs 물건중심프로그래밍

More information

KNK_C01_intro_kor

KNK_C01_intro_kor C Fundamentals adopted from KNK C Programming : A Modern Approach Program: Printing a Pun 파일이름은자유롭게짓되확장자는항상.c 로지정할것을권고 for example: pun.c #include // directive 지시자 int main(void) // function

More information