() / (front end) (back end) (phase) (pass) 1 2

Size: px
Start display at page:

Download "() / (front end) (back end) (phase) (pass) 1 2"

Transcription

1 1 () () lex

2 () / (front end) (back end) (phase) (pass) 1 2

3 () () var left, right; fun int main() { left = 0; right = 10; return ((left + right) / 2); } ID:left, ID:right ; FUN INT ID:main ( ) { ID:left = NUM:0 ; ID:right = NUM:10 ; RTURN ( ( ID:left + ID:right ) / NUM:2 ) ; } / prog var seq seq fun left seq int main seq right = seq left 0 = seq right 10 ret / + 2 left right 3

4 () () = val / * m + + n 1 n 1 tmp1 = n + 1 tmp2 = n + 1 tmp3 = tmp1 * tmp2 val = tmp3 / m tmp1 = n + 1 tmp3 = tmp1 * tmp1 val = tmp3 / m LD R1 n ADD R1 1 ST tmp1 R1 LD R1 tmp1 MUL R1 tmp1 ST tmp3 R1 LD R1 tmp3 DIV R1 m ST val R1 4

5 () Σ ϵ a Σ a R S (R S) (R S) (R ) < < ϵ { } a { a } R S L R L S R S { xy x L R, y L S } R { x 1 x 2 x n n 0, x 1, x 2,..., x n L R } ( 0 ) xy x y R S L R L S 2 2 { 0, 1 } ::= 0 1 ( 0 1 ) I 2 J. R. J J.. F

6 () 1 () (Q, Σ, δ, q 0, F ) Q Σ δ q a δ(q, a) q 0 q 0 Q F F Q 2 a, b A B 0, 1, % % C a, b, 0, 1, % a, b, 0, 1 Q = { A, B, C } Σ = { a, b, 0, 1, % } δ q 0 = A F = { B } a b 0 1 % A B B C C C B B B B B C C C C C C C 1 () ab1 A, B, B, B B b0%a A, B, B, C, C C I 2 J. R. J

7 () () () 0 1 ( 0 1 ) () B 0 C A 1 F G H I 0 J M 1 N K L D () 0 { C, D } { A, B, } 1 { F, G, H, I, M, L, D } 0, 1 0, 1 { } { J, K, H, I, M, L, D } { N, K, H, I, M, L, D } 0 1 () 0 0, 1 1 0, 1 0, 1 7

8 () lex lex lex lex /* * cprime.l -- CPrime flex * * flex cprime.l && gcc lex.yy.c -lfl &&./a.out < input.txt */ %% var printf(" "); fun printf("fun "); void printf("void "); int printf("int "); if printf("if "); else printf("ls "); while printf("whil "); return printf("rturn "); "==" printf("q "); "!=" printf("nq "); "<=" printf("lq "); ">=" printf("gq "); [+\-*/%<>=(){},;] printf("%c ", *yytext); [0-9]+ printf("num:%s ", yytext); [_a-za-z][_a-za-z0-9]* printf("id:%s ", yytext); [ \t\n]+ /* */. printf("??? "); /* */ %% int main(void) { yylex(); printf("\n"); return 0; } if else while return var fun void int + - * / % > >= < <= ==!= = ( ) { }, ; 123 var x; fun void main() { x = 5; } IF LS WHIL RTURN FUN VOID INT + - * / % > GQ < LQ Q NQ = ( ) { }, ; NUM:123 ID:value??? ID:x ; FUN VOID ID:main ( ) { ID:x = NUM:5 ; } 8

9 () (context-free grammar) (V, T, P, S) V (variable)() T (terminal symbol) P (production rule) A α A V, α (V T ) S (start symbol)s V V T α 0 () ID NUM 1 : ( + ) 5 : ID 2 : ( - ) 6 : NUM 3 : ( * ) 4 : ( / ) V = { } T = { (, ), +, -, *, /, ID, NUM } P 6 ( + ) ( - ) ( * ) ( / ) ID NUM () ( + ) ( ( * ) + ) ( ( NUM * ) + ) ( ( NUM * ID ) + ) ( ( NUM * ID ) + NUM ) 1, 3, 6, 5, 6 { w T S w } 9

10 CPrime () C var ; fun ID ( ) { } void int ID ( ) ; ID = ; if ( ) else if ( ) while ( ) { } return ; return ; NUM ( ) ID ( ) ID ==!= > < >= <= + - * / % ID, ID, I 2 J. R. J

11 () 1 : ( + ) 5 : ID 2 : ( - ) 6 : NUM 3 : ( * ) 4 : ( / ) ( / ) 4 ( ( + ) / ) 1 ( ( ID + ) / ) 5 ( ( ID + ID ) / ) 5 ( ( ID + ID ) / NUM ) 6 ( / ) 4 ( / NUM ) 6 ( ( + ) / NUM ) 1 ( ( + ID ) / NUM ) 5 ( ( ID + ID ) / NUM ) 5 ( ( ID + ID ) / NUM ) 1 : + 6 : ID 2 : - 7 : NUM 3 : * 4 : / 5 : ( ) ( ID + ID ) / NUM ID + ID / NUM ID + ID / NUM 11

12 () () 1 1 () 1 : && 2 :! 3 : 4 : CON ! {}} {! {}} && {! {}}{ &&! && {}}{ CON! && CON () !!!! && && && CON 12

13 () () 1 1 () 1 : && 2 :! 3 : 4 : CON {}} && { && { CON }}{ {}}! { && CON! {}}{ && CON &&! CON !! CON &&! CON () 13

14 () ()! && ( (!, ( ) ) ), &&, ( CON ) CON def traverse( T ) visit( T ) n = T for i = 1 to n traverse( T i ) traverse( (!, ( ( ), &&, ( CON ) ) ) ) visit( ) 1 traverse(! ) visit(! ) 2! traverse( ( ( ), &&, ( CON ) ) ) visit( ) 3 traverse( ( ) ) visit( ) 4 traverse( ) visit( ) 5 traverse( && ) visit( && ) 6 && traverse( ( CON ) ) visit( ) 7 traverse( CON ) visit( CON ) 8 CON 14

15 () ()! && ( (!, ( ) ) ), &&, ( CON ) CON def traverse( T ) n = T for i = 1 to n traverse( T i ) visit( T ) traverse( (!, ( ( ), &&, ( CON ) ) ) ) traverse(! ) visit(! ) 1! traverse( ( ( ), &&, ( CON ) ) ) traverse( ( ) ) traverse( ) visit( ) 2 visit( ) 3 traverse( && ) visit( && ) 4 && traverse( ( CON ) ) traverse( CON ) visit( CON ) 5 CON visit( ) 6 visit( ) 7 visit( ) 8 15

( ) ( ) lex LL(1) LL(1)

( ) ( ) lex LL(1) LL(1) () () lex LL(1) LL(1) http://www.cs.info.mie-u.ac.jp/~toshi/lectures/compiler/ 29 5 14 1 1 () / (front end) (back end) (phase) (pass) 1 2 1 () () var left, right; fun int main() { left = 0; right = 10;

More information

untitled

untitled II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}

More information

untitled

untitled II 4 Yacc Lex 2005 : 0 1 Yacc 20 Lex 1 20 traverse 1 %% 2 [0-9]+ { yylval.val = atoi((char*)yytext); return NUM; 3 "+" { return + ; 4 "*" { return * ; 5 "-" { return - ; 6 "/" { return / ; 7 [ \t] { /*

More information

() () (parse tree) ( (( ) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM (abstract syntax tree, AST) ( (( ) * 5

() () (parse tree) ( (( ) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM (abstract syntax tree, AST) ( (( ) * 5 3 lex yacc http://www.cs.info.mie-u.ac.jp/~toshi/lectures/compiler/ 2018 6 1 () () (parse tree) ( ((10 + 30) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM 10 30 (abstract syntax tree,

More information

(ver. 1.3 (2018) ) yacc 1 1 yacc yacc (Yet Another Compiler Compiler) UNIX yacc yacc y *.y yacc ) yacc *.tab.h *.tab.c C C yacc yacc UNIX yacc bison 2

(ver. 1.3 (2018) ) yacc 1 1 yacc yacc (Yet Another Compiler Compiler) UNIX yacc yacc y *.y yacc ) yacc *.tab.h *.tab.c C C yacc yacc UNIX yacc bison 2 (ver. 1.3 (2018) ) yacc 1 1 yacc yacc (Yet Another Compiler Compiler) UNIX yacc yacc y *.y yacc ) yacc *.tab.h *.tab.c C C yacc yacc UNIX yacc bison 2 yacc yacc lex %token yacc yacc token *.tab.h #define

More information

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C 1 6 9 1 main main 1 NULL NULL 1 15 23 25 48 26 30 32 36 38 43 45 47 50 52 for 2 (a) 2 2 1 Yacc 2 (b) 2 3 yytext tmp2 ("") tmp2->next->word tmp2 yytext tmp2->next->word

More information

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * * 2015 2015 07 30 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) +

More information

main

main 14 1. 12 5 main 1.23 3 1.230000 3 1.860867 1 2. 1988 1925 1911 1867 void JPcalendar(int x) 1987 1 64 1 1 1 while(1) Ctrl C void JPcalendar(int x){ if (x > 1988) printf(" %d %d \n", x, x-1988); else if(x

More information

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* ( 2016 2016 07 28 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF : 11011 N N 0 N N 11 1001 N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) 1100100 (2) 1111011 (3) 1110010 (4) 1001011

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx

More information

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v 1 http://www7.bpe.es.osaka-u.ac.jp/~kota/classes/jse.html kota@fbs.osaka-u.ac.jp /* do-while */ #include #include int main(void) double val1, val2, arith_mean, geo_mean; printf( \n );

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2017 2017 08 03 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF X [ S ] a S S ; X X X, S [, a, ], ; BNF X (parse tree) (1) [a;a] (2) [[a]] (3) [a;[a]] (4) [[a];a] : [a] X 2 222222

More information

C言語によるアルゴリズムとデータ構造

C言語によるアルゴリズムとデータ構造 Algorithms and Data Structures in C 4 algorithm List - /* */ #include List - int main(void) { int a, b, c; int max; /* */ Ÿ 3Ÿ 2Ÿ 3 printf(""); printf(""); printf(""); scanf("%d", &a); scanf("%d",

More information

compiler-text.dvi

compiler-text.dvi 2018.4 1 2 2.1 1 1 1 1: 1. (source program) 2. (object code) 3. 1 2.2 C if while return C input() output() fun var ( ) main() C (C-Prime) C A B C 2.3 Pascal P 1 C LDC load constant LOD load STR store AOP

More information

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

(search: ) [1] ( ) 2 (linear search) (sequential search) 1 2005 11 14 1 1.1 2 1.2 (search:) [1] () 2 (linear search) (sequential search) 1 2.1 2.1.1 List 2-1(p.37) 1 1 13 n

More information

yacc.dvi

yacc.dvi 2017 c 8 Yacc Mini-C C/C++, yacc, Mini-C, run,, Mini-C 81 Yacc Yacc, 1, 2 ( ), while ::= "while" "(" ")" while yacc 1: st while : lex KW WHILE lex LPAREN expression lex RPAREN statement 2: 3: $$ = new

More information

: gettoken(1) module P = Printf exception End_of_system (* *) let _ISTREAM = ref stdin let ch = ref ( ) let read () = (let c =!ch in ch := inp

: gettoken(1) module P = Printf exception End_of_system (* *) let _ISTREAM = ref stdin let ch = ref ( ) let read () = (let c =!ch in ch := inp 7 OCaml () 1. 2. () (compiler) (interpreter) 2 OCaml (syntax) (BNF,backus normal form ) 1 + 2; let x be 2-1 in x; ::= ; let be in ; ::= + - ::= * / ::= 7.1 ( (printable characters) (tokens) 1 (lexical

More information

Ⅰ Report#1 Report#1 printf() /* Program : hello.c Student-ID : 095740C Author UpDate Comment */ #include int main(){ : Yuhi,TOMARI : 2009/04/28(Thu) : Used Easy Function printf() 10 printf("hello,

More information

橡Pro PDF

橡Pro PDF 1 void main( ) char c; /* int c; */ int sum=0; while ((c = getchar())!= EOF) if(isdigit(c) ) sum += (c-'0'); printf("%d\n", sum); main()int i,sum=0; for(i=0;i

More information

1.

1. 3 ( ) 1. n Tiny C n yacc (bison) lex (flex) n IA n n n n n n (lex ) 50 (yacc ) 400 200 550 n n yacc/lex TA Tiny C n C n int n (if, while) int fact(int n) {! if (n == 1) return 1;! else return n * fact(n-1);!

More information

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf(hello World\n); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o 18 C ( ) 1 1 1.1 hello world.c 5 printf("hello World\n"); 6 } [ ] [ ] #include % cc hello_world.c %./a.out Hello World [a.out ] % cc hello_world.c -o hello_world [ ( ) ] (K&R 4.1.1) #include

More information

R R S S 6 S S D D S3 S3 R R S 6 S 6 S S D D w.o S3 S3 R5 3-0 R S 06 S 6 6 S S 6 D D 30 S3 w.o S3 R R8 7 3-

R R S S 6 S S D D S3 S3 R R S 6 S 6 S S D D w.o S3 S3 R5 3-0 R S 06 S 6 6 S S 6 D D 30 S3 w.o S3 R R8 7 3- 3 9 3 5 5 9 4 5 6 7 8 0 4 R R5 S S D S3 S S D S3 6 6 6 6 6 6 6 30 30 3 0 0 3 4 6 R R8 S S D S3 S S D S3 6 6 7 30 3 0 6 6 3 4 5 6 3 6 0 w.o 3R 30 3 3R3 S S D S3 S S D S3 6 6 6 4 6 6 4 4 0 0 3 6 6 6 R R9

More information

オートマトンと言語理論 テキスト 成蹊大学理工学部情報科学科 山本真基 ii iii 1 1 1.1.................................. 1 1.2................................ 5 1.3............................. 5 2 7 2.1..................................

More information

8 / 0 1 i++ i 1 i-- i C !!! C 2

8 / 0 1 i++ i 1 i-- i C !!! C 2 C 2006 5 2 printf() 1 [1] 5 8 C 5 ( ) 6 (auto) (static) 7 (=) 1 8 / 0 1 i++ i 1 i-- i 1 2 2.1 C 4 5 3 13!!! C 2 2.2 C ( ) 4 1 HTML はじめ mkdir work 作業用ディレクトリーの作成 emacs hoge.c& エディターによりソースプログラム作成 gcc -o fuga

More information

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

離散数理工学 第 2回  数え上げの基礎:漸化式の立て方 2 okamotoy@uec.ac.jp 2015 10 20 2015 10 18 15:29 ( ) (2) 2015 10 20 1 / 45 ( ) 1 (10/6) ( ) (10/13) 2 (10/20) 3 ( ) (10/27) (11/3) 4 ( ) (11/10) 5 (11/17) 6 (11/24) 7 (12/1) 8 (12/8) ( ) (2) 2015 10 20

More information

Taro-2分探索木Ⅱ(公開版).jtd

Taro-2分探索木Ⅱ(公開版).jtd 2 分探索木 Ⅱ 0. 目次 5. 2 分探索木の操作 5. 1 要素の探索 5. 2 直前の要素の探索 5. 3 直後の要素の探索 5. 4 要素の削除 5. 5 問題 問題 1-1 - 5. 2 分探索木の操作 5. 1 要素の探索 要素 44 の探索 (1) 要素 と 44 を比較して 左部分木をたどる (2) 要素 33 と 44 を比較して 右部分木をたどる (3) 要素 44 を見つけた

More information

e.c e.s e.scala /* e.c */ int add(int a, int b) { return a + b; void main() { int a = add(3, 4); printf( %d n, a); ; e.s.text.globl _add _add: pushq %rbp movq %rsp, %rbp movl %edi, -4(%rbp) movl %esi,

More information

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf ("sum=%d n",sum); 2

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf (sum=%d n,sum); 2 アセンブラ (Z80) の例 ORG 100H LD B,10 SUB A LOOP: ADD A,B DEC B JR NZ,LOOP LD (SUM),A HALT ORG 200H SUM: DEFS 1 END 1 C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i

More information

lexex.dvi

lexex.dvi (2018, c ) http://istksckwanseiacjp/ ishiura/cpl/ 4 41 1 mini-c lexc,, 2 testlexc, lexc mini-c 1 ( ) mini-c ( ) (int, char, if, else, while, return 6 ) ( ) (+, -, *, /, %, &, =, ==,!=, >, >=,

More information

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2  2 B R b I 4 003 4 30 1 ASCII ( ) 0 17 0 NUL 16 DLE SP 0 @ P 3 48 64 80 96 11 p 1 SOH 17 DC1! 1 A Q a 33 49 65 81 97 113 q STX 18 DC " B R b 34 50 66 8 98 114 r 3 ETX 19 DC3 # 3 C S c 35 51 67 83 99 115 s 4 EOT

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます.  このサンプルページの内容は, 新装版 1 刷発行時のものです. C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009383 このサンプルページの内容は, 新装版 1 刷発行時のものです. i 2 22 2 13 ( ) 2 (1) ANSI (2) 2 (3) Web http://www.morikita.co.jp/books/mid/009383

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

新・明解C言語で学ぶアルゴリズムとデータ構造

新・明解C言語で学ぶアルゴリズムとデータ構造 第 1 章 基本的 1 n 141 1-1 三値 最大値 algorithm List 1-1 a, b, c max /* */ #include int main(void) { int a, b, c; int max; /* */ List 1-1 printf("\n"); printf("a"); scanf("%d", &a); printf("b"); scanf("%d",

More information

18/12/06 情報工学実験 C コンパイラ (2018 年度 ) 担当 : 笹倉 佐藤 その 3 yacc の構造 定義部 %% 定義部の終了 規則部 %% 規則部の終了 ユーザ定義サブルーチン部 :C のプログラムを書く 形は lex と同じ 1

18/12/06 情報工学実験 C コンパイラ (2018 年度 ) 担当 : 笹倉 佐藤 その 3 yacc の構造 定義部 %% 定義部の終了 規則部 %% 規則部の終了 ユーザ定義サブルーチン部 :C のプログラムを書く 形は lex と同じ 1 情報工学実験 C コンパイラ (2018 年度 ) 担当 : 笹倉 佐藤 2018.12.6 その 3 yacc の構造 定義部 定義部の終了 規則部 規則部の終了 ユーザ定義サブルーチン部 :C のプログラムを書く 形は lex と同じ 1 yacc yacc のキモは規則部 規則部には文法規則を書く左辺 : 右辺 yacc は入力されたプログラムを右辺から左辺に 還元 していく この規則にアクションが書かれていたら還元するときにアクションも実行する.

More information

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

離散数理工学 第 2回  数え上げの基礎:漸化式の立て方 2 okamotoy@uec.ac.jp 2014 10 21 2014 10 29 10:48 ( ) (2) 2014 10 21 1 / 44 ( ) 1 (10/7) ( ) (10/14) 2 (10/21) 3 ( ) (10/28) 4 ( ) (11/4) 5 (11/11) 6 (11/18) 7 (11/25) ( ) (2) 2014 10 21 2 / 44 ( ) 8 (12/2)

More information

1.ppt

1.ppt /* * Program name: hello.c */ #include int main() { printf( hello, world\n ); return 0; /* * Program name: Hello.java */ import java.io.*; class Hello { public static void main(string[] arg)

More information

VDM-SL VDM VDM-SL Toolbox VDM++ Toolbox 1 VDM-SL VDM++ Web bool

VDM-SL VDM VDM-SL Toolbox VDM++ Toolbox 1 VDM-SL VDM++ Web bool VDM-SL VDM++ 23 6 28 VDM-SL Toolbox VDM++ Toolbox 1 VDM-SL VDM++ Web 2 1 3 1.1............................................... 3 1.1.1 bool......................................... 3 1.1.2 real rat int

More information

‚æ4›ñ

‚æ4›ñ ( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9

More information

( 23 )

( 23 ) ( 23 ) 2 9 11 16 21........................................... 21........................................... 24........................................... 28...........................................

More information

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç C (3) if else switch AND && OR (NOT)! 1 BMI BMI BMI = 10 4 [kg]) ( [cm]) 2 bmi1.c Input your height[cm]: 173.2 Enter Input your weight[kg]: 60.3 Enter Your BMI is 20.1. 10 4 = 10000.0 1 BMI BMI BMI = 10

More information

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

1. A0 A B A0 A : A1,...,A5 B : B1,...,B 1. A0 A B A0 A : A1,...,A5 B : B1,...,B12 2. 3. 4. 5. A0 A B f : A B 4 (i) f (ii) f (iii) C 2 g, h: C A f g = f h g = h (iv) C 2 g, h: B C g f = h f g = h 4 (1) (i) (iii) (2) (iii) (i) (3) (ii) (iv) (4)

More information

PowerPoint Presentation

PowerPoint Presentation p.130 p.198 p.208 2 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i i < NUM; i++ ) ) if if ( weight[i] > max ) max = weight[i]: if if ( weight[i] < min ) min = weight[i]: weight

More information

ohp07.dvi

ohp07.dvi 17 7 (2) 2017.9.13 1 BNF BNF ( ) ( ) 0 ( ) + 1 ( ) ( ) [ ] BNF BNF BNF prog ::= ( stat ) stat ::= ident = expr ; read ident ; print expr ; if ( expr ) stat while ( expr ) stat { prog expr ::= term ( +

More information

プログラミング基礎

プログラミング基礎 C プログラミング Ⅰ 条件分岐 if~else if~else 文,switch 文 条件分岐 if~else if~else 文 if~else if~else 文 複数の条件で処理を分ける if~else if~else 文の書式 if( 条件式 1){ 文 1-1; 文 1-2; else if( 条件式 2){ 文 2-1; 文 2-2; else { 文 3-1; 文 3-2; 真条件式

More information

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1 () 2006 2 27 1 10 23 () 30 () 27 [1] p.97252 7 2 2.1 2.1.1 1 LIFO(last in first out, ) (push) (pup) 1 1: 2.1.2 1 List 4-1(p.100) stack[] stack top 1 2 (push) (pop) 1 2 void stack push(double val) val stack

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double

More information

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B A/B (2010/10/08) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2010/soft/soft.html 2010 10 8 A/B 1 2010 10 8 2 1 1 1.1 OHP.................................... 1 1.2.......................................

More information

プログラミング言語 8 字句解析器(lexer)と構文解析器(parser)

プログラミング言語 8   字句解析器(lexer)と構文解析器(parser) 8 (lexer) (parser) 1 / 73 (lexer, tokenizer) (parser) Web Page (HTML XML) CSV, SVG,...... config file... ( )! 2 / 73 1 1 OCaml : ocamllex ocamlyacc 2 Python : ply 2! 3 / 73 ( ) 字句解析器 構文解析器 ご注文はうさぎさんですか?

More information

Microsoft Word - no206.docx

Microsoft Word - no206.docx 3.2 双方向リスト 今までのリストは 前から順にたどることしかできませんでした 今度は逆にもたどることができる 双方向リストを扱います この場合は 構造体には次を表すポインタの他に前を表すポインタを持つ ことになります 今回は最初と最後をポインタを使うと取り扱いが面倒になるので 最初 (start) と最後 (end) を どちらとも構造体 ( 値は意味を持たない ) を使うことにします こうすることによって

More information

文法と言語 ー文脈自由文法とLR構文解析2ー

文法と言語 ー文脈自由文法とLR構文解析2ー 文法と言語ー文脈自由文法とLR 構文解析 2 ー 和田俊和資料保存場所 http://vrl.sys.wakayama-u.ac.jp/~twada/syspro/ 前回までの復習 最右導出と上昇型構文解析 最右導出を前提とした場合, 上昇型の構文解析がしばしば用いられる. 上昇型構文解析では生成規則の右辺にマッチする部分を見つけ, それを左辺の非終端記号に置き換える 還元 (reduction)

More information

Taro-最大値探索法の開発(公開版

Taro-最大値探索法の開発(公開版 最大値探索法の開発 0. 目次 1. 開発過程 1 目標 1 : 4 個のデータの最大値を求める 目標 2 : 4 個のデータの最大値を求める 改良 : 多数のデータに対応するため 配列を使う 目標 3 : n 個のデータの最大値を求める 改良 : コードを簡潔に記述するため for 文を使う 目標 4 : n 個のデータの最大値を求める 改良 : プログラムをわかりやすくするため 関数を使う 目標

More information

#include #include #include int gcd( int a, int b) { if ( b == 0 ) return a; else { int c = a % b; return gcd( b, c); } /* if */ } int main() { int a = 60; int b = 45; int

More information

tuat1.dvi

tuat1.dvi ( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )

More information

P05.ppt

P05.ppt 2 1 list0415.c forfor #include int i, j; for (i = 1; i

More information

untitled

untitled 146,650 168,577 116,665 122,915 22,420 23,100 7,564 22,562 140,317 166,252 133,581 158,677 186 376 204 257 5,594 6,167 750 775 6,333 2,325 298 88 5,358 756 1,273 1,657 - - 23,905 23,923 1,749 489 1,309

More information

C言語7

C言語7 C 言語 7 ポインタ アドレスを出力 int a; a=5; printf(" 変数 aの値は %dです n", a); printf(" 変数 aのアドレスは %pです n", &a); 実行結果 変数 a の値は 5 です 変数 a のアドレスは 0038FAC4 です 変数 a の値は 15 です 変数 a のアドレスは 0038FAC4 です 注 アドレスの値は実行環境やプログラムの実行状況により異なります

More information

untitled

untitled 20 7 1 22 7 1 1 2 3 7 8 9 10 11 13 14 15 17 18 19 21 22 - 1 - - 2 - - 3 - - 4 - 50 200 50 200-5 - 50 200 50 200 50 200 - 6 - - 7 - () - 8 - (XY) - 9 - 112-10 - - 11 - - 12 - - 13 - - 14 - - 15 - - 16 -

More information

untitled

untitled 19 1 19 19 3 8 1 19 1 61 2 479 1965 64 1237 148 1272 58 183 X 1 X 2 12 2 15 A B 5 18 B 29 X 1 12 10 31 A 1 58 Y B 14 1 25 3 31 1 5 5 15 Y B 1 232 Y B 1 4235 14 11 8 5350 2409 X 1 15 10 10 B Y Y 2 X 1 X

More information

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 1. 1.1. 1.2. 1 PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 2. 2.1. 2 1 2 C a b N: PC BC c 3C ac b 3 4 a F7 b Y c 6 5 a ctrl+f5) 4 2.2. main 2.3. main 2.4. 3 4 5 6 7 printf printf

More information

‚æ2›ñ C„¾„ê‡Ìš|

‚æ2›ñ C„¾„ê‡Ìš| I 8 10 10 I ( 6 ) 10 10 1 / 23 1 C ( ) getchar(), gets(), scanf() ( ) putchar(), puts(), printf() 1 getchar(), putchar() 1 I ( 6 ) 10 10 2 / 23 1 (getchar 1 1) 1 #include 2 void main(void){ 3 int

More information

超初心者用

超初心者用 3 1999 10 13 1. 2. hello.c printf( Hello, world! n ); cc hello.c a.out./a.out Hello, world printf( Hello, world! n ); 2 Hello, world printf n printf 3. ( ) int num; num = 100; num 100 100 num int num num

More information

橡点検記録(集約).PDF

橡点検記録(集約).PDF 942.8.8.8.7 671 86 11 1 9 9 9 1 1,792 7,23 2,483 1,324 2,198 7,23 82 7,23 6,327 9,22 9,713 8,525 8,554 9,22. 8,554. 1,79 9,713 95 947 8,525.. 944 671 81 7 17 1,29 1,225 1,241 1,25 1,375 9.3 23,264 25,

More information

初歩のC言語ターミナル_2014_May.pages

初歩のC言語ターミナル_2014_May.pages C Mac OS X ( Vi Mi) Xcode CD >cd C:\Users\\Desktop gcc first.c C:\Users\\Desktop>gcc -o first first.c gcc first.c C:\Users\\Desktop>first Windows OS VisualStudio VisualStudio VS2012 CD C:\ >cd C:\Users\

More information

parser.y 3. node.rb 4. CD-ROM

parser.y 3. node.rb 4. CD-ROM 1. 1 51 2. parser.y 3. node.rb 4. CD-ROM 1 10 2 i 0 i 10 " i i+1 3 for(i = 0; i

More information

(2 Linux Mozilla [ ] [ ] [ ] [ ] URL 2 qkc, nkc ~/.cshrc (emacs 2 set path=($path /usr/meiji/pub/linux/bin tcsh b

(2 Linux Mozilla [ ] [ ] [ ] [ ] URL   2 qkc, nkc ~/.cshrc (emacs 2 set path=($path /usr/meiji/pub/linux/bin tcsh b II 5 (1 2005 5 26 http://www.math.meiji.ac.jp/~mk/syori2-2005/ UNIX (Linux Linux 1 : 2005 http://www.math.meiji.ac.jp/~mk/syori2-2005/jouhousyori2-2005-00/node2. html ( (Linux 1 2 ( ( http://www.meiji.ac.jp/mind/tool/internet-license/

More information

アセンブラ入門(CASL II) 第3版

アセンブラ入門(CASL II) 第3版 CASLDV i COMET II COMET II CASL II COMET II 1 1 44 (1969 ) COMETCASL 6 (1994 ) COMETCASL 13 (2001 ) COMETCASL COMET IICASL II COMET IICASL II CASL II 2001 1 3 3 L A TEX 2 CASL II COMET II 6 6 7 Windows(Windows

More information

XMPによる並列化実装2

XMPによる並列化実装2 2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer

More information

debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology

debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology I117 28 School of Information Science, Japan Advanced Institute of Science and Technology debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology 2008 1-2 1 a) b)

More information

exec.dvi

exec.dvi 2018 c 6, Mini-C C++ 6211 611, 61, print,,, (run ),,, (int ), 7, x, x "a" 3 "b" 4 "x" 10 (, ), x STL map 1 + 2, 1 2,, x = ;, 1, 2 x { 1 ; 2 ; ; m, if ( ) { 1 else { 2, 1,, 2 0, 1, 3 0, 2,,, main 6 1 ,,

More information

VOID SLAB FOR CONSTRUCTION Winding Pipe VOID SLAB FOR CONSTRUCTION Winding Pipe VOID SLAB FOR CONSTRUCTION Winding Pipe VOID SLAB FOR CONSTRUCTION Winding Pipe VOID SLAB FOR CONSTRUCTION Winding Pipe

More information

gcc C C tcc lex yacc flex bison [ ] Tiny C 2 Lex [ 2.6 ] 2.1 lex yacc [ ] lex flex yacc bison yacc yyparse() C yyparse() yylex() yylex() yylex() flex

gcc C C tcc lex yacc flex bison [ ] Tiny C 2 Lex [ 2.6 ] 2.1 lex yacc [ ] lex flex yacc bison yacc yyparse() C yyparse() yylex() yylex() yylex() flex 3 1 C Tiny C Tiny C int if while Tiny C 4 C Tiny C % cat test.tc int f(int x) while(x > 1) x = x - 2; return x; Tiny C NASM [3] tcc C % tcc < test.tc GLOBAL f f push ebp mov ebp, esp L1 mov eax, [ebp+8]

More information

r08.dvi

r08.dvi 19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev

More information

Int Int 29 print Int fmt tostring 2 2 [19] ML ML [19] ML Emacs Standard ML M M ::= x c λx.m M M let x = M in M end (M) x c λx.

Int Int 29 print Int fmt tostring 2 2 [19] ML ML [19] ML Emacs Standard ML M M ::= x c λx.m M M let x = M in M end (M) x c λx. 1, 2 1 m110057@shibaura-it.ac.jp 2 sasano@sic.shibaura-it.ac.jp Eclipse Visual Studio ML Standard ML Emacs 1 ( IDE ) IDE C C++ Java IDE IDE IDE IDE Eclipse Java IDE Java Standard ML 1 print (Int. 1 Int

More information

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx 情報ネットワーク導入ユニット Ⅰ C 言語 if 文 switch 文 3 章 : プログラムの流れの分岐 if 文 if( 条件 ) 条件が成立すれば実行 if( 条件 ) ~ else 場合分け ( 成立, 不成立 ) if( 条件 A) ~ else if( 条件 B) ~ else if( 条件 C) ~ else 場合分け ( 複数の条件での場合分け ) 等価演算子 : == ( 等しい

More information

P06.ppt

P06.ppt p.130 p.198 p.208 2 1 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i < NUM; i++ ) if ( weight[i] > max ) max = weight[i]: if ( weight[i] < min ) min = weight[i]: weight 3 maxof(a,

More information

( 9 1 ) 1 2 1.1................................... 2 1.2................................................. 3 1.3............................................... 4 1.4...........................................

More information

Super perfect numbers and Mersenne perefect numbers /2/22 1 m, , 31 8 P = , P =

Super perfect numbers and Mersenne perefect numbers /2/22 1 m, , 31 8 P = , P = Super perfect numbers and Mersenne perefect numbers 3 2019/2/22 1 m, 2 2 5 3 5 4 18 5 20 6 25 7, 31 8 P = 5 35 9, 38 10 P = 5 39 1 1 m, 1: m = 28 m = 28 m = 10 height48 2 4 3 A 40 2 3 5 A 2002 2 7 11 13

More information

新・明解Javaで学ぶアルゴリズムとデータ構造

新・明解Javaで学ぶアルゴリズムとデータ構造 第 3 章 探索 Arrays.binarySearch 743 3-1 探索 探索 searching key 配列 探索 Fig.3-1 b c 75 a 6 4 3 2 1 9 8 2 b 64 23 53 65 75 21 3-1 53 c 5 2 1 4 3 7 4 Fig.3-1 a 763 3-2 線形探索 線形探索 linear search sequential search 2

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション プログラミング応用 第 15 回 知的情報システム学科張 暁華 プログラミング応用 1 授業のマナー ------ 人の話を聞くときの社会常識 1. 欠席者のかわりに登録を行わない 倫理に反することをやらない あなたの信を問われている蟻の穴から堤防が決壊 2. 私語しないこと : 質問 意見は手を挙げて大きな声ではっきりと意思表示 3. 授業以外のことをしない : 携帯をカバンにいれ イヤホンを使って音楽等を聞かない授業中ゲームを遊ばない

More information

Taro-再帰関数Ⅰ(公開版).jtd

Taro-再帰関数Ⅰ(公開版).jtd 再帰関数 Ⅰ 0. 目次 1. 階乗関数 2. 基本演算 2. 1 乗算 2. 2 除算 2. 3 剰余 3. 最大公約数. フィボナッチ関数 5. べき乗関数 5. 1 解法 1 5. 2 解法 2-1 - 1. 階乗関数 再帰関数は 関数の中で自分自身を呼び出す関数をいう 関数を簡潔に定義することができる 階乗関数 f(n) (n 0) を明示的に書くとつぎのようになる 再帰的定義 f(n) =

More information

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D II 8 2003 11 12 1 6 ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 Daisuke 8 =>. 73 Daisuke 35 Hiroshi 64 Ichiro 87 Junko

More information

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B A/B (2018/06/08) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2018/soft/soft.html 2018 6 8 A/B 1 2018 6 8 2 1 1 1.1 OHP.................................... 1 1.2

More information

Microsoft PowerPoint - prog07.ppt

Microsoft PowerPoint - prog07.ppt プログラミング言語 2 第 07 回 (2007 年 06 月 18 日 ) 1 今日の配布物 片面の用紙 1 枚 今日の課題が書かれています 本日の出欠を兼ねています 2/32 1 今日やること http://www.tnlab.ice.uec.ac.jp/~s-okubo/class/language/ にアクセスすると 教材があります 2007 年 06 月 18 日分と書いてある部分が 本日の教材です

More information

I void* School of Information Science, Japan Advanced Institute of Science and Technology

I void* School of Information Science, Japan Advanced Institute of Science and Technology I117 25 void* School of Information Science, Japan Advanced Institute of Science and Technology sdict ( ) idict ; long long double void* Japan Advanced Institute of Science and Technology 2008 1-2 1 idict

More information

r9.dvi

r9.dvi 2011 9 2011.12.9 Ruby B Web ( ) 1 1.1 2 def delete if at then return @cur = @prev.next = @cur.next (1) EOF (2)@cur 1 ()@prev 1 def exch if at @cur.next == @tail then return a = @prev; b = @cur.next; c

More information

untitled

untitled C -1 - -2 - concept lecture keywords FILE, fopen, fclose, fscanf, fprintf, EOF, r w a, typedef gifts.dat Yt JZK-3 Jizake tsumeawase 45 BSP-15 Body soap set 3 BT-2 Bath towel set 25 TEA-2 Koutya

More information

‚åŁÎ“·„´Šš‡ðŠp‡¢‡½‹âfi`fiI…A…‰…S…−…Y…•‡ÌMarkovŸA“½fiI›ð’Í

‚åŁÎ“·„´Šš‡ðŠp‡¢‡½‹âfi`fiI…A…‰…S…−…Y…•‡ÌMarkovŸA“½fiI›ð’Í Markov 2009 10 2 Markov 2009 10 2 1 / 25 1 (GA) 2 GA 3 4 Markov 2009 10 2 2 / 25 (GA) (GA) L ( 1) I := {0, 1} L f : I (0, ) M( 2) S := I M GA (GA) f (i) i I Markov 2009 10 2 3 / 25 (GA) ρ(i, j), i, j I

More information