compiler-text.dvi

Size: px
Start display at page:

Download "compiler-text.dvi"

Transcription

1 : 1. (source program) 2. (object code) 3. 1

2 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 arithmatic operation STP stop UJP unconditional jump FJP jump on false XST expand stack COP comparison operation MST mark stack RLN read line WLN write line CAL call RET return 1: P 4 p, i, b, t 2 p p (instruction) i p 1 2 (base) b t C P P ( )

3 p P t i b 2: 3 LDC AOP WLN STP output(7+8-9); LDC 0 7 LDC 0 8 AOP 0 0 LDC 0 9 AOP 0 1 WLN 0 0 STP LDC = 7 = LDC 7 = AOP 15 = LDC 15 = AOP 6 = WLN (a) (b) (c) 3: 2.4 C C (scanner) (token) (identifier) ( ) (reserved word) 3.4 C 2 4 3

4 if else while return var fun void int + - * / % > >= < <= ==!= = ( ) {, ; 2: VAR IDENT(x) SEMICOLON var x; FUN VOID IDENT(main) LPAREN RPAREN LBRACE = IDENT(x) BECOMES NUMBER(5) SEMICOLON x = 5; RBRACE END OF INPUT (a) (b) 4: 3.2 (parser) (recursive descend parser) 1 C (program), (declaration), (definition), (statement), (expression), (comparison), (arithmetic), (term), (factor), (atom) ( B ) program 5 C ( B) program (1) var declaration ( ) (2) fun definition 0 (3) end of input program 5 token_type read_token 1 VAR FUN var fun error void program() { if (token_type() == VAR) { read_token(); declaration(); while (token_type() == FUN) { read_token(); definition(); if (token_type()!= END_OF_INPUT) { error(); 5: statement 6 4

5 program VAR IDENT(x) SEMICOLON FUN VOID IDENT(main) LPAREN RPAREN LBRACE IDENT(x) BECOMES NUMBER(5) SEMICOLON RBRACE END OF INPUT = var declaration ident ; fun definition. end of input void ident ( ) { statement ident = expression ;. number (a) (b) 6: 3.3 (code generation) (syntax-directed translation) (arithmetic expression) arithmetic 7 AOP 7 instruction PLUS, MINUS +, - term (term) 3(a) 3(b) void arithmetic() { int op; term(); op = token_type(); while (op == PLUS op == MINUS) { read_token(); term(); if (op == PLUS) instruction(aop, 0, 0); else instruction(aop, 0, 1); op = token_type(); 7: 8(a) 1 sub() main() 8(b) main() main() sub() (call) sub() 5

6 (return) main() main() var x, y; fun int sub(a) { var x, z; sub() var y; main() sub() main() (a) (b) 8: C D C A E 3.4 (symbol table) 9(a) 1 x, y x, 9(b) 9(c) XST STR, LOD 3 4 x, y var x, y; x = 5; y = x; x 0 y 1 XST 0 2 LDC 0 5 STR 0 0 LOD 0 0 STR 0 1 XST 0-2 STP 0 0 (a) (b) (c) 9: 6

7 8(a) x, y 2 sub a 3 x, z 10(a) sub() x sub() 0 2 (3.5 ) ( 3 ) sub() a x, z sub() main() z sub() main() 6 main 7 y 10(b) main() y main() main() y x y sub a x z 0 1 int int x 0 y 1 sub int int main void void y 3 (a) sub() (b) main() 10: 3.5 (activation record) (stack frame) RA (return address) OB (old base) RV (return value) RA OB RV 8 main() 12(a) sub() 12(b) sub() sub() 12(c) 7

8 t b RA OB RV 11: t sub() z x a RA OB b RV t sub() RA OB b RV t z x a z x a RA OB RV main() b y RA OB RV y x y RA OB RV y x y RA OB RV y x (a) main() (b) sub() (c) sub() 12: 8

9 (if, while) [1] A. V. M. S. R. J. D [2] A. W [3] 1989 [4] T [5] B. W. D. M. C [6] S. P. 3 G. L. C

10 A (1) output(7+8-9); (2) var in, out; in = input(); out = -in; output(out); (3) var i; i = 1; while (i < 10) { if (i%2!= 0) output(i); i = i+1; (4) var x; fun void double() { x = x*2; x = 100; double(); output(x); (5) var x, pow; fun void powself(x) { var i; i = 0; while (i < x) { pow = pow*x; i = i+1; x = input(); pow = 1; powself(x); output(pow); (6) var num; fun int gcd(m, n) { if (n == 0) return m; else return gcd(n, m%n); var m, n; num = 3; while (num > 0) { m = input(); n = input(); output(gcd(m, n)); num = num-1; 10

11 B [ var ]? [ fun ] end of input program ident, ; declaration void ident ( [ ident, ]? ) { [ var ]? definition int ident ( [ ident, ]? ) { [ var ]? ident ( [, ]? ) ; statement ident = ; if ( ) [ else ]? while ( ) { return? ; [ ==!= ] expression [ > >= < <= ] comparison [ + - ] arithmetic [ * / % ] term [ + - ]? number ( ) ident ident ( [, ]? ) factor atom [ ] α β α β α? α α ε α α 0 α β β α 1 α[βα] 11

12 C LDC 0 n load constant t t+1 ; s[t] n n LOD r a load t t+1 ; r ( 0 1) a s[t] s[base(r)+a] LDA r a load address t t+1 ; r a s[t] base(r)+a ILD 0 0 indirect load s[t] s[s[t]] STR r a store s[base(r)+a] s[t] ; t t 1 r a ISR 0 0 indirect store s[s[t 1]] s[t] ; AOP 0 n arithmetic COP 0 n comparison t t 2 s[t 1] s[t 1] op s[t] ; 2 operation t t 1 n = 0,1,2,3,4 op +,,,div,mod s[t 1] s[t 1] op s[t] ; 2 operation t t 1 (0 1) n = 0,1,2,3,4,5 op >,,<,,=, RLN 0 0 read line t t+1 ; 1 readline(s[t]) WLN 0 0 write line writeline(s[t]) ; STP 0 0 stop t t 1 UJP 0 a unconditional p a jump FJP 0 a jump on false p a if s[t] = 0 ; t t 1 XST 0 n expand stack t t+n 1 a 0 a n MST 0 0 mark stack s[t+1] 0 ; (RV) s[t+2] b ; t t+3 (OB) (RA) CAL n a call s[t n] p ; (RA) b t (3+n)+1 ; p a a (n ) RET 0 n return t b+n 1 ; p s[b+2] ; b s[b+1] RA OB (n 0 1) LDA, ILD, ISR 3 12

13 D (1) LDC AOP COP LOD STR RLN WLN (2) if ( ) 1 else 2 while ( ) FJP FJP 1 UJP 2 UJP (3) [ void int ] (, ) { [ var ]? XST RET (4) ( ) ( 1,, n ) XST UJP MST CAL main() XST STP MST 1. n CAL (5) return? ; ( ) STR ( ) RET 13

14 E var num; 0: XST 0 1 1: UJP 0 42 fun int gcd(m, n) { 2: XST 0 0 if (n == 0) 3: LOD 1 4 4: LDC 0 0 5: COP 0 4 6: FJP 0 11 return m; 7: LOD 1 3 8: STR 1 0 9: RET 0 1 else 10: UJP 0 19 return gcd(n, m%n); 11: MST : LOD : LOD : LOD : AOP : CAL : STR : RET : RET 0 1 var m, n; 20: XST 0 2 num = 3; 21: LDC : STR 0 0 while (num > 0) { 23: LOD : LDC : COP : FJP 0 41 m = input(); 27: RLN : STR 1 3 n = input(); 29: RLN : STR 1 4 output(gcd(m, n)); 31: MST : LOD : LOD : CAL : WLN 0 0 num = num-1; 36: LOD : LDC : AOP : STR : UJP : RET : MST : CAL : XST : STP

( ) ( ) 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

main.dvi

main.dvi 20 II 7. 1 409, 3255 e-mail: namba@faculty.chiba-u.jp 2 1 1 1 4 2 203 2 1 1 1 5 503 1 3 1 2 2 Web http://www.icsd2.tj.chiba-u.jp/~namba/lecture/ 1 2 1 5 501 1,, \,", 2000 7. : 1 1 CPU CPU 1 Intel Pentium

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

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

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

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

More information

PL : pl0 ( ) 1 SableCC ( sablecc ) 1.1 sablecc sablecc Étienne Gagnon [1] Java sablecc sablecc ( ) Visitor DepthFirstAdapter 1 (Depth

PL : pl0 ( ) 1 SableCC ( sablecc ) 1.1 sablecc sablecc Étienne Gagnon [1] Java sablecc sablecc ( ) Visitor DepthFirstAdapter 1 (Depth PL0 2007 : 2007.05.29 pl0 ( ) 1 SableCC ( sablecc ) 1.1 sablecc sablecc Étienne Gagnon [1] Java sablecc sablecc () Visitor DepthFirstAdapter 1 (Depth First traversal) ( ) (breadth first) 2 sablecc 1.2

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

: 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

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

() () (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

( ) ( ) 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

1 Code Generation Part I Chapter 8 (1 st ed. Ch.9) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,

1 Code Generation Part I Chapter 8 (1 st ed. Ch.9) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 1 Code Generation Part I Chapter 8 (1 st ed. Ch.9) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2013 2 Position of a Code Generator in the Compiler Model Source

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

Microsoft PowerPoint - NxLec ppt

Microsoft PowerPoint - NxLec ppt MIPS R3000 Instruction Set Architecture (ISA) 計算機アーキテクチャ特論 (Advanced Computer Architectures) 2. スカラプロセッサ, スーパースカラプロセッサ Instruction Categories Computational Load/Store Jump and Branch Floating Point coprocessor

More information

r02.dvi

r02.dvi 172 2017.7.16 1 1.1? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X ( ) 1.2 1 2-0 ( ) ( ) ( ) (12) ( ) (112) (131) 281 26 1 (syntax) (semantics) ( ) 2 2.1 BNF BNF(Backus Normal Form) Joun Backus (grammer) English

More information

2 1,384,000 2,000,000 1,296,211 1,793,925 38,000 54,500 27,804 43,187 41,000 60,000 31,776 49,017 8,781 18,663 25,000 35,300 3 4 5 6 1,296,211 1,793,925 27,804 43,187 1,275,648 1,753,306 29,387 43,025

More information

ohp02.dvi

ohp02.dvi 172 2017.7.16 1 ? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X 2 ( ) 3 2-0 ( ) ( ) ( ) (12) ( ) (112) 31) 281 26 1 4 (syntax) (semantics) ( ) 5 BNF BNF(Backus Normal Form) Joun Backus (grammer) English grammer

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

program.dvi

program.dvi 2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation

More information

3 SIMPLE ver 3.2: SIMPLE (SIxteen-bit MicroProcessor for Laboratory Experiment) 1 16 SIMPLE SIMPLE 2 SIMPLE 2.1 SIMPLE (main memo

3 SIMPLE ver 3.2: SIMPLE (SIxteen-bit MicroProcessor for Laboratory Experiment) 1 16 SIMPLE SIMPLE 2 SIMPLE 2.1 SIMPLE (main memo 3 SIMPLE ver 3.2: 20190404 1 3 SIMPLE (SIxteen-bit MicroProcessor for Laboratory Experiment) 1 16 SIMPLE SIMPLE 2 SIMPLE 2.1 SIMPLE 1 16 16 (main memory) 16 64KW a (C )*(a) (register) 8 r[0], r[1],...,

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

1 911 9001030 9:00 A B C D E F G H I J K L M 1A0900 1B0900 1C0900 1D0900 1E0900 1F0900 1G0900 1H0900 1I0900 1J0900 1K0900 1L0900 1M0900 9:15 1A0915 1B0915 1C0915 1D0915 1E0915 1F0915 1G0915 1H0915 1I0915

More information

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル Instruction Manual Disk No. RE01 6th Edition: November 1999 (YK) All Rights Reserved, Copyright 1996 Yokogawa Electric Corporation 801234567 9 ABCDEF 1 2 3 4 1 2 3 4 1 2 3 4 1 2

More information

K227 Java 2

K227 Java 2 1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html

More information

Microsoft PowerPoint ppt

Microsoft PowerPoint ppt 仮想マシン (2), コード生成 http://cis.k.hosei.ac.jp/~asasaki /lect/compiler/2007-1204.pdf ( 訂正版 ) 1 概要 仮想マシン 概要 ( 復習 ) 制御命令 出力命令 コード生成 式のコード生成 文 文の列のコード生成 記号表 2 演習で作るコンパイラの例 test.hcc Int main() { int i j; i = 3;

More information

main.dvi

main.dvi 1 F77 5 hmogi-2008f@kiban.civil.saitama-u.ac.jp 2013/5/13 1 2 f77... f77.exe f77.exe CDROM (CDROM D D: setupond E E: setupone 5 C:work\T66160\20130422>f77 menseki.f -o menseki f77(.exe) f77 f77(.exe) C:work\T66160\20130422>set

More information

2005 D Pascal CASL ( ) Pascal C 3. A A Pascal TA TA TA

2005 D Pascal CASL ( ) Pascal C 3. A A Pascal TA TA TA 2005 D 1 1.1 1.2 Pascal CASL ( ) Pascal 1. 2005 10 13 2006 1 19 12 2. C 3. A A 2 1 2 Pascal 1.3 1. 2. TA TA TA sdate@ist.osaka-u.ac.jp nakamoto@image.med.osaka-u.ac.jp h-kido@ist.osaka-u.ac.jp m-nakata@ist.osaka-u.ac.jp

More information

Microsoft PowerPoint - Compiler06note.pptx

Microsoft PowerPoint - Compiler06note.pptx コンパイラ 第 6 回構文解析 構文解析プログラムの作成 http://www.info.kindai.ac.jp/compiler 38 号館 4 階 N-411 内線 5459 takasi-i@info.kindai.ac.jp コンパイラの構造 字句解析系 構文解析系 制約検査系 中間コード生成系 最適化系 目的コード生成系 処理の流れ情報システムプロジェクト I の場合 output (ab);

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

num2.dvi

num2.dvi kanenko@mbk.nifty.com http://kanenko.a.la9.jp/ 16 32...... h 0 h = ε () 0 ( ) 0 1 IEEE754 (ieee754.c Kerosoft Ltd.!) 1 2 : OS! : WindowsXP ( ) : X Window xcalc.. (,.) C double 10,??? 3 :, ( ) : BASIC,

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

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

2011 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA enshu-

2011 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA enshu- 2011 D 1 1.1 1.2 Pascal CASL II ( ) Pascal 1. 2011 10 6 2011 2 9 15 2. C 3. A A 2 1 2 Pascal 1.3 1. 2. TA enshud@fenrir.ics.es.osaka-u.ac.jp TA enshu-d@fenrir.ics.es.osaka-u.ac.jp higo@ist.osaka-u.ac.jp

More information

新版明解C言語入門編

新版明解C言語入門編 175cm 60kg ( ) 175cm 175.3cm 175.869758 cm 175cm 60kg p.177 18-1 vx - vy vx vy List -1 List -1 int vx, vy; puts(""); printf(" vx "); scanf("%d", &vx); printf(" vy "); scanf("%d", &vy); printf("vx + vy

More information

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I  Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~alse I Exercise on Programming I http://bit.ly/oitprog1 1, 2 of 14 ( RD S ) I 1, 2 of 14 1 / 44 Ruby Ruby ( RD S ) I 1, 2 of 14 2 / 44 7 5 9 2 9 3 3 2 6 5 1 3 2 5 6 4 7 8 4 5 2 7 9 6 4 7 1 3 ( RD S ) I 1, 2

More information

Microsoft PowerPoint ppt

Microsoft PowerPoint ppt コード生成 (2) http://cis.k.hosei.ac.jp/~asasaki /lect/compiler/2007-1211.pdf 1 概要 宣言文と記号表 ( 配列 ) 今日はやりません 2 宣言 a = 1; b = a+2; putint(b); int main(){ int a; int b; a = 1; b = a+2; putint(b); } PUSH 0 26 LDC

More information

明解Java入門編

明解Java入門編 1 Fig.1-1 4 Fig.1-1 1-1 1 Table 1-1 Ease of Development 1-1 Table 1-1 Java Development Kit 1 Java List 1-1 List 1-1 Chap01/Hello.java // class Hello { Java System.out.println("Java"); System.out.println("");

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

Microsoft PowerPoint - Compiler06.pptx

Microsoft PowerPoint - Compiler06.pptx コンパイラ 第 6 回構文解析 構文解析プログラムの作成 http://www.info.kindai.ac.jp/compiler 38 号館 4 階 N-411 内線 5459 takasi-i@info.kindai.ac.jp コンパイラの構造 字句解析系 構文解析系 制約検査系 中間コード生成系 最適化系 目的コード生成系 処理の流れ 情報システムプロジェクト I の場合 output (ab);

More information

コンピュータ概論

コンピュータ概論 4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For

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

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1 Java (9) 1 Lesson 7 2008-05-20 Java System.out.println() 1 Java API 1 Java Java 1 GUI 2 Java 3 1.1 5 3 1.0 10.0, 1.0, 0.5 5.0, 3.0, 0.3 4.0, 1.0, 0.6 1 2 4 3, ( 2 3 2 1.2 Java (stream) 4 1 a 5 (End of

More information

2009 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA

2009 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA 2009 D 1 1.1 1.2 Pascal CASL II ( ) Pascal 1. 2009 10 15 2010 1 29 16 2. C 3. A A 2 1 2 Pascal 1.3 1. 2. TA enshud@image.med.osaka-u.ac.jp TA enshu-d@image.med.osaka-u.ac.jp nakamoto@image.med.osaka-u.ac.jp

More information

r1.dvi

r1.dvi 2014 1 2014.4.10 0 / 1 / 2 / 3 Lisp 4 5 ( ) 1 (5 1 ) 5 1 1.1? 0 1 (bit sequence) 5 101 3 11 2 (binary system) 2 1000 8 1 ( ) ( )? ( 1) r1 1000 1001 r2 1002... r3 1: (memory) (address) CPU (instruction)

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

情報工学実験 C コンパイラ第 2 回説明資料 (2018 年度 ) 担当 : 笹倉 佐藤

情報工学実験 C コンパイラ第 2 回説明資料 (2018 年度 ) 担当 : 笹倉 佐藤 情報工学実験 C コンパイラ第 2 回説明資料 (2018 年度 ) 担当 : 笹倉 佐藤 2018.12.13 コンパイラ作成実験 非常に難しい. まず コンパイラを実装すること自体が難しい. コンパイラを指して 人工知能 と呼んだ時代もあった. 難しさは 抽象的なアイデアを元に具体的な実装を行うことにある. クヌースはこれを 計算機科学的な考え方 と呼び できる人の存在比率は 1/50 だと述べている.

More information

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC PBASIC 2.5 PBASIC 2.5 BASIC Stamp Editor / Development System Version 2.0 Beta Release 2 2.0 PBASIC BASIC StampR PBASIC PBASIC PBASIC 2.5 Parallax, Inc. PBASIC 2.5 PBASIC 2.5 support@microbot-ed.com 1

More information

Microsoft Word - problem5.doc

Microsoft Word - problem5.doc コンパイラ演習 : 作成問題 5 ( 最終課題 ) ( 担当 : 佐々木晃 ) 目的機械は hsm 仮想機械とする 昨年度までの講義資料 ( 中田先生 開先生による ) も参考にすること 演習問題 B5( 締め切り =2008/01/27) 問題番号 : B5 課題名 : コンパイラの作成 5 ( 昨年度の第 5 回とは問題が異なるので 間違わないようにしてください ) 問題 JavaCC を用いて,

More information

P05.ppt

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

More information

listings-ext

listings-ext (6) Python (2) ( ) ohsaki@kwansei.ac.jp 5 Python (2) 1 5.1 (statement)........................... 1 5.2 (scope)......................... 11 5.3 (subroutine).................... 14 5 Python (2) Python 5.1

More information

1

1 2 章 1 整数を一つ読み込み, その階乗を計算する RAM プログラムを書け f (n) = n! ( n 0) 何でもよい ( n

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

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3 1 2 2 1 2 2.1.................................................... 2 2.2.................................................... 2 2.3........................................ 2 2.4....................................................

More information

N88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5:

N88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5: BASIC 20 4 10 0 N88 Basic 1 0.0 N88 Basic..................................... 1 0.1............................................... 3 1 4 2 5 3 6 4 7 5 10 6 13 7 14 0 N88 Basic 0.0 N88 Basic 0.1: N88Basic

More information

untitled

untitled 13 Verilog HDL 16 CPU CPU IP 16 1023 2 reg[ msb: lsb] [ ]; reg [15:0] MEM [0:1023]; //16 1024 16 1 16 2 FF 1 address 8 64 `resetall `timescale 1ns/10ps module mem8(address, readdata,writedata, write, read);

More information

橡ソート手順比較

橡ソート手順比較 PAGE:1 [Page] 20 1 20 20 QuickSort 21 QuickSort 21 21 22 QuickSort 22 QuickSort 22 23 0 23 QuickSort 23 QuickSort 24 Order 25 25 26 26 7 26 QuickSort 27 PAGE:2 PAGE:3 program sort; { { type item = record

More information

Microsoft Word - problem3.doc

Microsoft Word - problem3.doc コンパイラ演習 : 作成問題 3 ( 担当 : 佐々木晃 ) 次のような言語のコンパイラを作成することが目的である 目的機械は hsm 仮想機械とする 昨年度までの講義資料 ( 中田先生 開先生による ) も参考にすること 演習問題 B3 問題番号 : B3 課題名 : コンパイラの作成 3 (1) 記号表の実装 (2) JavaCC プログラム課題 3 (1) 記号表の実装 記号表を実現するクラス

More information

kiso2-03.key

kiso2-03.key 座席指定はありません Linux を起動して下さい 第3回 計算機基礎実習II 2018 のウェブページか ら 以下の課題に自力で取り組んで下さい 計算機基礎実習II 第2回の復習課題(rev02) 第3回の基本課題(base03) 第2回課題の回答例 ex02-2.c include int main { int l int v, s; /* 一辺の長さ */ /* 体積 v

More information

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D 6 2019 5 14 6.1 Minimum C....................... 6 1 6.2....................................... 6 7 6.1 Minimum C Minimum C BNF T okenseq W hite Any Digit ::= 0 1 2... 9. Number ::= Digit Digit. Alphabet

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

Fortran90/95 [9]! (1 ) " " 5 "Hello!"! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1

Fortran90/95 [9]! (1 )   5 Hello!! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1 Fortran90/95 2.1 Fortran 2-1 Hello! 1 program example2_01! end program 2! first test program ( ) 3 implicit none! 4 5 write(*,*) "Hello!"! write Hello! 6 7 stop! 8 end program example2_01 1 program 1!

More information

新・明解Java入門

新・明解Java入門 第 1 章 画面 文字 表示 Java Java Java Java Java JRE Java JDK 21 1-1 Java Java Java Java 誕生 Fig.1-1 Oak Java Sun Microsystems 2010 Oracle Java Oracle 4 Java http://www.java.com/ http://www.alice.org/ Fig.1-1Java

More information

Microsoft PowerPoint - 05Cobol.ppt

Microsoft PowerPoint - 05Cobol.ppt 73 80 (Page) (Serial) 1 3 4 6 7 8 11 12 16 20 24 32 36 40 44 48 52 56 60 64 68 72 まずは COBOL 入門 プログラム言語論第五回 COBOL COmmon Business Oriented Language バッチ処理 ( それしかなかった ) 用に設計 データ書式 ( ファイル書式と処理途中のデータの書式 ) がまず念頭にある

More information

Microsoft PowerPoint - 04SyntaxAnalysis.ppt [互換モード]

Microsoft PowerPoint - 04SyntaxAnalysis.ppt [互換モード] 字句解析と構文解析 コンパイラ理論 4 構文解析導入 字句解析 トークンの提供 トークンの要求 構文解析 櫻井彰人 記号表 次の コンパイラ理論 5 も続けて行います なぜ分けるか? 字句解析を構文解析から分ける理由 : 設計が単純になる 効率 ( 速度等 ) の向上が図れる 可搬性がます 字句解析 構文解析それぞれによいツールが存在する トークン 字句 パターン (Tokens, Lexemes,

More information

COINS 5 2.1

COINS 5 2.1 COINS (0501699) 20 21 2 5 1 3 1.1....................................... 3 1.2..................................... 4 1.3....................................... 4 2 COINS 5 2.1 COINS..................................

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

: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

導入基礎演習.ppt

導入基礎演習.ppt Multi-paradigm Programming Functional Programming Scheme Haskell ML Scala X10 KL1 Prolog Declarative Lang. C Procedural Lang. Java C++ Python Object-oriented Programming / (root) bin home lib 08 09

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

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

研修コーナー

研修コーナー l l l l l l l l l l l α α β l µ l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l

More information

インテル® スレッドチェッカー 3.1 Linux* 版

インテル® スレッドチェッカー 3.1 Linux* 版 ... 2 1.... 3 2.... 5 3.... 7 4.... 10 Intel's Terms and Conditions of Sale IntelIntel Intel Corporation * 2007 Intel Corporation. 313445JA 001 2006 5 313445 JA 002 2006 9 2 : 313445-002JA 1. primes 1

More information

橡Pascal-Tの挙動を調べる

橡Pascal-Tの挙動を調べる PROGRAM SAMPLE01(INPUT, OUTPUT); BEGIN END. PROGRAM SAMPLE02(INPUT, OUTPUT); VAR X, Y, Z : INTEGER; BEGIN X := 1; Y := 2; Z := X + Y; WRITELN(Z); END. #!/usr/local/bin/perl #PASCAL-T OBJECT MAC FILE

More information

t 2 2 t 2 t F ( ) p- 2 2 F 2 G F ( ) 2 2 F 2 G F ( ) 2 2 2

t 2 2 t 2 t F ( ) p- 2 2 F 2 G F ( ) 2 2 F 2 G F ( ) 2 2 2 1 2 2 0 1 2 2 2 2 2 2 2 2.1 2 2 F={f ij }, G {g ij } t f ij t g ij = 1 f ij < t g ij = 0 t p- p S 0 S p = S 0 /S t p 2 t 1 t 2 2 t 2 t 2 2 3 3 1 2 F ( ) p- 2 2 F 2 G 3 2 2 F ( ) 2 2 F 2 G 3 3 2 F ( ) 2

More information

解きながら学ぶC言語

解きながら学ぶC言語 printf 2-5 37 52 537 52 printf("%d\n", 5 + 37); 5370 source program source file.c ex00.c 0 comment %d d 0 decimal -2 -p.6 3-2 5 37 5 37-22 537 537-22 printf("537%d\n", 5-37); function function call ( )argument,

More information

pptx

pptx iphone 2010 8 18 C xkozima@myu.ac.jp C Hello, World! Hello World hello.c! printf( Hello, World!\n );! os> ls! hello.c! os> cc hello.c o hello! os> ls! hello!!hello.c! os>./hello! Hello, World!! os>! os>

More information

Microsoft PowerPoint L07-Imperative Programming Languages-4-students ( )

Microsoft PowerPoint L07-Imperative Programming Languages-4-students ( ) プログラミング言語論 A (Concepts on Programming Languages) 趙建軍 (Jianjun Zhao) 1 第 7 回 命令型言語 (4) (Imperative Programming Languages) 手続き ( 関数 ) の呼び出し 2019.05.30 2 1 今日の講義 手続きとは 手続きの定義 引数渡し スコープ規則 3 今日の講義 手続きとは 手続きの定義

More information

haskell.gby

haskell.gby Haskell 1 2 3 Haskell ( ) 4 Haskell Lisper 5 Haskell = Haskell 6 Haskell Haskell... 7 qsort [8,2,5,1] [1,2,5,8] "Hello, " ++ "world!" "Hello, world!" 1 + 2 div 8 2 (+) 1 2 8 div 2 3 4 map even [1,2,3,4]

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

.,. 0. (MSB). =2, =1/2.,. MSB LSB, LSB MSB. MSB 0 LSB 0 0 P

.,. 0. (MSB). =2, =1/2.,. MSB LSB, LSB MSB. MSB 0 LSB 0 0 P , 0 (MSB) =2, =1/2, MSB LSB, LSB MSB MSB 0 LSB 0 0 P61 231 1 (100, 100 3 ) 2 10 0 1 1 0 0 1 0 0 100 (64+32+4) 2 10 100 2 5, ( ), & 3 (hardware), (software) (firmware), hardware, software 4 wired logic

More information

第10回 コーディングと統合(WWW用).PDF

第10回 コーディングと統合(WWW用).PDF 10 January 8, 2004 algorithm algorithm algorithm (unit testing) (integrated testing) (acceptance testing) Big-Bang (incremental development) (goto goto DO 50 I=1,COUNT IF (ERROR1) GO TO 60 IF (ERROR2)

More information

デジタル表現論・第4回

デジタル表現論・第4回 デジタル表現論 第 4 回 劉雪峰 ( リュウシュウフォン ) 2016 年 5 月 2 日 劉 雪峰 ( リュウシュウフォン ) デジタル表現論 第 4 回 2016 年 5 月 2 日 1 / 14 本日の目標 Java プログラミングの基礎 出力の復習 メソッドの定義と使用 劉 雪峰 ( リュウシュウフォン ) デジタル表現論 第 4 回 2016 年 5 月 2 日 2 / 14 出力 Systemoutprint()

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

Copyright c 2008 Zhenjiang Hu, All Right Reserved.

Copyright c 2008 Zhenjiang Hu, All Right Reserved. 2008 10 27 Copyright c 2008 Zhenjiang Hu, All Right Reserved. (Bool) True False data Bool = False True Remark: not :: Bool Bool not False = True not True = False (Pattern matching) (Rewriting rules) not

More information

Microsoft PowerPoint - Compiler04note.ppt [互換モード]

Microsoft PowerPoint - Compiler04note.ppt [互換モード] コンパイラ 第 4 回字句解析 字句解析プログラムの作成 http://www.info.kindai.ac.jp/compiler 38 号館 4 階 N-411 内線 5459 takasi-i@info.kindai.ac.jp コンパイラの構造 字句解析系 構文解析系 制約検査系 中間コード生成系 最適化系 目的コード生成系 処理の流れ情報システムプロジェクト I の場合 write (ab);

More information

1

1 PalmGauss SC PGSC-5G Instruction Manual PalmGauss SC PGSC-5G Version 1.01 PalmGauss SC PGSC5G 1.... 3 2.... 3 3.... 3 3.1... 3 3.2... 3 3.3 PalmGauss... 4 3.4... 4 3.4.1 (Fig. 4)... 4 3.4.2 (Fig. 5)...

More information

Gray [6] cross tabulation CUBE, ROLL UP Johnson [7] pivoting SQL 3. SuperSQL SuperSQL SuperSQL SQL [1] [2] SQL SELECT GENERATE <media> <TFE> GENER- AT

Gray [6] cross tabulation CUBE, ROLL UP Johnson [7] pivoting SQL 3. SuperSQL SuperSQL SuperSQL SQL [1] [2] SQL SELECT GENERATE <media> <TFE> GENER- AT DEIM Forum 2017 E3-1 SuperSQL 223 8522 3 14 1 E-mail: {tabata,goto}@db.ics.keio.ac.jp, toyama@ics.keio.ac.jp,,,, SuperSQL SuperSQL, SuperSQL. SuperSQL 1. SuperSQL, Cross table, SQL,. 1 1 2 4. 1 SuperSQL

More information

(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1

(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1 (Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1 17 Fortran Formular Tranlator Lapack Fortran FORTRAN, FORTRAN66, FORTRAN77, FORTRAN90, FORTRAN95 17.1 A Z ( ) 0 9, _, =, +, -, *,

More information

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou 1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() 2 double *a[ ]; double 1 malloc() double 1 malloc() free() 3 #include #include

More information