1 (2 * 3) 1 2 * 3 Preorder In order Post order 1 * 1 * Breadth-first Depth-first * * 3 Preorder: 1 * 2 3 In order: 1 2 * 3 Post orde
|
|
- おさむ ありはら
- 5 years ago
- Views:
Transcription
1 5 LL recursive descent LL(1) <sentence> ::= <noun-phrase><verb-phrase> <noun-phrase> ::= <cmplx-noun> <cmplx-noun><prep-phrase> <verb-phrase> ::= <cmplx-verb> <cmplx-verb><prep-phrase> <prep-phrase> ::= <prep><cmplx-noun> <cmplx-noun> ::= <article><noun> <cmplx-verb> ::= <verb> <verb><noun-phrase> <article> ::= a the <noun> ::= boy girl flower <verb> ::= touches likes sees <prep> ::= with ::= ::= * <factor> <factor> <factor> ::= '(' <expr ')' <num> <num> ::= * 3 <sentence> ::= <noun-phrase><verb-phrase> ::= <cmplx-noun><verb-phrase> ::= <article><noun><verb-phrase> ::= a <noun><verb-phrase> ::= a boy <cmplx-verb> ::= a boy <verb> ::= a boy sees <factor> <num> 1 * <factor> <factor> <num> 2 <num> 1 2 * * 3 <expr expr> <factor> 1 (2 * 3) 1 * 2 3 <factor> <num> 1 * <factor> <factor> <num> 2 <num> 1 ( 2 * 3 ) 3
2 1 (2 * 3) 1 2 * 3 Preorder In order Post order 1 * 1 * Breadth-first Depth-first * * 3 Preorder: 1 * 2 3 In order: 1 2 * 3 Post order: * ::= * '(' ')' ::= * '(' ')' ? 1 2 * 3 7
3 ::= * '(' ')' ::= * '(' ')' * *! 1 2 * * * (ambiguous)! 9 <C-PROG> MAIN OPENPAR <PARAMS> CLOSEPAR <MAIN-BODY> <PARAMS> NULL <PARAMS> VAR <VAR-LIST> <VARLIST>, <VAR> <VARLIST> <VARLIST> NULL <MAIN-BODY> CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT> <TYPE><VAR><VAR-LIST>; <ASSIGN-STMT> <VAR> = <EXPR>; <EXPR> <VAR> <EXPR> <VAR><OP><EXPR> <OP> <OP> - <TYPE> INT <TYPE> FLOAT main() { int a,b; a = b; Scanner Parser token " main() { int a,b; a = b; Scanner Token: ';' Parser? semantic actions semantic checks symbol tables <C-PROG> MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY> CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT> <TYPE><VAR><VAR-LIST>; <VARLIST>, <VAR> <VARLIST> <VARLIST> NULL
4 int a,b; a b integer a b? a b int "main" int "main" a b c t1 = a b t2 = t1 c <decl-stmt> <type>#put-type<var-list>#do-decl <var-list> <var>, <var-list>#add-decl <var-list> <var> <var> ID#proc-decl #put-type (,,, etc.) #proc-decl #add-decl (decl-chain) translation (, #do-decl ). id3 id2 #type #do-decl Name Type Scope id1 1 3 id2 1 3 id3 1 3
5 ( translation) : a = b c d; process-id: "c" : <ASSGNSTMT> <VAR> = <EXPR>#do-assign; <EXPR> <VAR><EXPRTAIL> <VAR> ID#process-id <EXPRTAIL> <OP>#process-op<VAR>#do-infix<EXPRTAIL> <EXPTAIL> NULL "c" "" "b" "=" "a" recursive descent : CFG Top-down Bottom-up 1. root node leaves 1. leaves root node : A bb cc tree *A () { switch (nexttoken()) { case TOK_b: { tree *t = B(); " const(maketree(b), t); predictive parsing case TOK_c: { tree *t = C(); const(maketree(c), t); default:... error... return return ::= ::= * <factor> <factor> <factor> ::= '(' ')' num ident : num ident 1 2 * 3
6 !? ::= ::= * <factor> <factor> <factor> ::= '(' ')' num ident ::= ::= * <factor> <factor> <factor> ::= '(' ')' num ident <factor> <factor> <ident>... <num> 1 2 * * 3 recursion left-recursive ::= ::= * <factor> <factor> <factor> ::= '(' ')' num ident right-recursive
7 ::= BNF Extended Backus-Naur Form EBNF { 0 ::= { : Num ::= [0-9][0-9]* ::= { head tail BNF ::= <e_tail> <e_tail> ::= <e_tail> ε leftmost derivation <e_tail> ε <e_tail> <e_tail> ε rightmost derivation ::= * <factor> <factor> <e_tail> <e_tail> <e_tail> ε EBNF ::= <factor> { * <factor> BNF ::= <factor><t_tail> <t_tail> ::= * <factor><t_tail> ε!
8 ::= <e_tail> <e_tail> ::= <e_tail> ε ::= <factor> <t_tail> <t_tail> ::= * <factor> <t_tail> ε <factor> ::= '(' ')' num id Recursive Descent Parsing top-down token? scanner : gettok() token enum {PLUS, MULT, LPAREN, RPAREN, NUM, ID; enum {SUCCESS, FAILURE; enum {SUCCESS, FAILURE; int Succeed(int arg) { if(arg == SUCCESS) return 1; else if(arg == FAILURE) return 0; else /* */ int expr(void) { if( Succeed(term()) && Succeed(e_tail()) ) else return FAILURE; ::= <e_tail> <e_tail> ::= <e_tail> ε ::= <factor> <t_tail> <t_tail> ::= * <factor> <t_tail> ε <factor> ::= '(' ')' num id int e_tail(void) { if( gettok() == PLUS && Succeeds(term()) && Succeeds(e_tail()) ) else /* epsilon! */ ::= <e_tail> <e_tail> ::= <e_tail> ε ::= <factor> <t_tail> <t_tail> ::= * <factor> <t_tail> ε <factor> ::= '(' ')' num id int term(void) { if(succeed(factor()) && Succeed(t_tail())) else return FAILURE; ::= <e_tail> <e_tail> ::= <e_tail> ε ::= <factor> <t_tail> <t_tail> ::= * <factor> <t_tail> ε <factor> ::= '(' ')' num id
9 int t_tail(void) { if( gettok() == MULT && Succeeds(factor()) && Succeeds(t_tail()) ) else /* epsilon! */ ::= <e_tail> <e_tail> ::= <e_tail> ε ::= <factor> <t_tail> <t_tail> ::= * <factor> <t_tail> ε <factor> ::= '(' ')' num id int factor(void) { if( gettok() == LPAREN && Succeeds(expr()) && gettok() == RPAREN) ) else if (gettok() == NUM) else if (gettok() == ID) else return FAILURE;? ::= <e_tail> <e_tail> ::= <e_tail> ε ::= <factor> <t_tail> <t_tail> ::= * <factor> <t_tail> ε <factor> ::= '(' ')' num id /* Version 2 */ int factor(void) { int TokType; if( (TokType = gettok()) == LPAREN && Succeeds(expr()) && gettok() == RPAREN ) else if( TokType == NUM TokType == ID ) else return FAILURE;!!! i.e. : unget if(something with factor) return Success; else if(something else with factor) return Success else if(another thing with factor) etc.
10 unget (T1=token) T1==( Yes No <factor> ::= '(' ')' num id T1==ID No T1==NUM No Recover T1 Save T1 T1=token Yes Recover T1 Yes Yes Failure <factor> <t-tail> ε <e_tail> <e_tail> <factor> <t-tail> ε ) Failure num num * <factor> <t_tail> Yes Success? Success Success num 1 2 * 3 ε LL(1)
11 LL(1) S ( S ) S ε S ( S ) S ( ( S ) S ) S ( ( S ) S ) ( S ) S ( ( ) ) ( ) parse table, : A α β A α A β?? α β First First : parse table α β First LL(1) LL(1) First A ε A A entry, A Follow A Follow A ε
12 ( ) $ S S ( S ) S S ε S ε First Follow LL(1) exp exp' ε First Follow - term factor term' exp exp term term term' mulop factor term' ε - mulop * term term mulop factor factor factor ( exp ) number mulop * factor ( exp ) number? exp exp' - term factor term' term' mulop factor term' mulop * factor ( exp ) factor number A B first(a)=first(b) first(exp ) = first(term) first(exp' ) = first() {ε first() = {,- first(term ) = first(factor) first(term') = first(mulop) {ε first(mulop) = {* first(factor)= {(, number exp exp' - term factor term' term' mulop factor term' mulop * factor ( exp ) factor number
13 A B first(a)=first(b) first(a) first(b) B ε A BCD B ε C ε first(a)=first(b) first(c) first(d) first(exp ) first(term) first(exp' ) first() {ε first() {,- exp' term' first(term ) first(factor) first(term') first(mulop) {ε first(mulop) {* first(factor) {(, number exp exp' - term factor term' term' mulop factor term' mulop * factor ( exp ) factor number first(exp) = { (, number first(exp') = {, -, ε first(exp') = {, -, ε first() = {, - first() = {, - first(term) = { (, number first(term') = { *, ε first(term') = { *, ε first(mulop) = { * first(factor) = { (, number first(factor) = { (, number Follow First A Follow A A ε A A follow A ε Follow A, $ Follow(A) 1. A, $ Follow(A) 2. B αaγ, First(γ) - {ε Follow(A) 3. B αaγ,, ε First(γ), Follow(B) Follow(A) : B αa Follow(B) Follow(A) exp exp' - term factor term' term' mulop factor term' mulop * factor ( exp ) factor number
14 exp exp' - term factor term' term' mulop factor term' mulop * factor ( exp ) follow factor number follow exp exp' term factor term' term' mulop factor term' factor ( exp ) (1) exp (2) exp' (3) term factor term' (4) term' mulop factor term' (5) factor ( exp ) Follow(term) = First(exp') Follow(exp') = Follow(exp) Follow(term) = Follow(exp) Follow() = First(term) Follow(term) = First(exp') Follow(term) = Follow(exp') Follow(factor) = First(term') Follow(factor) = Follow(term) Follow(term') = Follow(term) Follow(mulop) = First(factor) Follow(factor) = First(term') Follow(factor) = Follow(term') Follow(exp) = { ) Follow(exp) = { Follow(exp') = { Follow() = { Follow(term) = { Follow(term') = { Follow(mulop) = { Follow(factor) = { Follows Follow(term) = First(exp') Follow(exp') = Follow(exp) Follow(term) = Follow(exp) Follow() = First(term) Follow(term) = First(exp') Follow(term) = Follow(exp') Follow(factor) = First(term') Follow(factor) = Follow(term) Follow(term') = Follow(term) Follow(mulop) = First(factor) Follow(factor) = First(term') Follow(factor) = Follow(term') Follow(exp) = { ) Follow(exp) = { $ ) Follow(exp') = { $ ) Follow() = { ( number Follow(term) = { - $ ) Follow(term') = { - $ ) Follow(mulop) = { ( number Follow(factor) = { * - $ ) No change! First(exp) = { ( number First(exp') = { - ε First() = { - First(term) = { ( number First(term') = { * ε First(mulop) = { * First(factor) { ( number Follow(exp) = { $ ) Follow(exp') = { $ ) Follow() = { ( number Follow(term) = { - $ ) Follow(term') = { - $ ) Follow(mulop) = { ( number Follow(factor) = { * - $ )
15 LL(1) A A α 1. First(α) a, Table[A][a] A α. 2. ε First(α), Follow(A) ( $) a, Table[A][a] A α. entry, : exp : exp First(term) = { ( number exp term exp Table[exp][(] Table[exp][number] [N][T] exp exp' term term' mulop factor ( exp term factor term' factor ( exp ) number exp term factor term' factor number ) exp' - * exp' - term' mulop factor term' mulop * $ A A α 1. First(α) a, Table[A][a] A α. 2. ε First(α), Follow(A) ( $) a, Table[A][a] A α. : term' : term' mulop factor term' First(term') = { * ε term mulop factor term [term ][*] [N][T] exp exp' term term' mulop factor ( exp term factor term' factor ( exp ) number exp term factor term' factor number ) exp' - * exp' - term' mulop factor term' mulop * $ A A α 1. First(α) a, Table[A][a] A α. 2. ε First(α), Follow(A) ( $) a, Table[A][a] A α. : term' : Follow(term') = { - $ ) term ε [term ][], [term ][-], [term ][$] [term ][)]
16 [N][T] ( number ) - * $ exp exp exp exp' exp' exp' - term term factor term' term factor term' term' mulop term' mulop factor term' mulop * factor factor ( exp ) factor number
Microsoft PowerPoint - 05LLprint.ppt [互換モード]
このスライドの内容 コンパイラ理論 6 LL 構文解析 下降型構文解析を詳しく 再帰下降型 (recursive descent) LL(1) 櫻井彰人 ::= ::= ::=
More informationMicrosoft PowerPoint - 3.ppt [互換モード]
3. プッシュダウンオートマトンと文脈自由文法 1 3-1. プッシュダウンオートマトン オートマトンはメモリがほとんど無かった この制限を除いた機械を考える 理想的なスタックを利用できるようなオートマトンをプッシュダウンオートマトン (Push Down Automaton,PDA) という 0 1 入力テープ 1 a 1 1 0 1 スタッb 入力テープを一度走査したあと ク2 入力テプを度走査したあと
More informationcompiler-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( ) ( ) 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 informationuntitled
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: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 informationohp07.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
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 informationMicrosoft 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 informationMicrosoft 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 informationI. 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 informationr02.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 informationohp02.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( ) ( ) 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 informationuntitled
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 informationI. 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 informationMicrosoft PowerPoint - Compiler05.pptx
コンパイラ 第 5 回下降型構文解析 http://www.info.kindai.ac.jp/compiler 38 号館 4 階 N-411 内線 5459 takasi-i@info.kindai.ac.jp コンパイラの構造 字句解析系 構文解析系 制約検査系 中間コード生成系 最適化系 目的コード生成系 処理の流れ 情報システムプロジェクト I の場合 output (ab); 字句解析系
More informationMicrosoft PowerPoint - 04SyntaxAnalysis.ppt [互換モード]
字句解析と構文解析 コンパイラ理論 4 構文解析導入 字句解析 トークンの提供 トークンの要求 構文解析 櫻井彰人 記号表 次の コンパイラ理論 5 も続けて行います なぜ分けるか? 字句解析を構文解析から分ける理由 : 設計が単純になる 効率 ( 速度等 ) の向上が図れる 可搬性がます 字句解析 構文解析それぞれによいツールが存在する トークン 字句 パターン (Tokens, Lexemes,
More informationII 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プログラミング言語処理系論 (4) Design and Implementation of Programming Language Processors
プログラミング言語処理系論 (4) Design and Implementation of Programming Language Processors 佐藤周行 ( 情報基盤センター / 電気系専攻融合情報学コース ) 今回の予定 言語規格を読むことの続き BNF だけでできることは限られてくる 文法の定義 + 制約 という記述の発明 文法から パーサを作る BNF をそのまま解釈する BISON,YACC
More information# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n
II 6 / : 2001 11 21 (OCaml ) 1 (field) name id type # type student = {name : string; id : int};; type student = { name : string; id : int; } student {} type = { 1 : 1 ;...; n : n } { 1 = 1 ;...; n = n
More information: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 informationyacc.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(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 informationPL : 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(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 informationr9.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 information2005 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「プログラミング言語」 SICP 第4章 ~超言語的抽象~ その6
SICP 4 6 igarashi@kuis.kyoto-u.ac.jp July 21, 2015 ( ) SICP 4 ( 6) July 21, 2015 1 / 30 4.3: Variations on a Scheme Non-deterministic Computing 4.3.1: amb 4.3.2: 4.3.3: amb ( ) SICP 4 ( 6) July 21, 2015
More information() / (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 informationjssst-ocaml.mgp
Objective Caml Jacques Garrigue Kyoto University garrigue@kurims.kyoto-u.ac.jp Objective Caml? 2 Objective Caml GC() Standard MLHaskell 3 OCaml () OCaml 5 let let x = 1 + 2 ;; val x : int = 3 ;; val-:
More information2009 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 informationLIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP : 1
2007 7 17 2 1 1.1 LIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP 2 2 5 5 5 1: 1 2 データの追加 データの取り出し 5 2 5 2 5 2: 1.2 [1] pp.199 217 2 (binary tree) 2 2.1 (three: ) ( ) 秋田高専 校長 準学士課程学生
More information1 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 information2011 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 informationO1-1 O1-2 O1-3 O1-4 O1-5 O1-6
O1-1 O1-2 O1-3 O1-4 O1-5 O1-6 O1-7 O1-8 O1-9 O1-10 O1-11 O1-12 O1-13 O1-14 O1-15 O1-16 O1-17 O1-18 O1-19 O1-20 O1-21 O1-22 O1-23 O1-24 O1-25 O1-26 O1-27 O1-28 O1-29 O1-30 O1-31 O1-32 O1-33 O1-34 O1-35
More information1 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 informationMicrosoft PowerPoint - Compiler05note.pptx
コンパイラ 第 5 回下降型構文解析 http://www.info.kindai.a.jp/ompiler 38 号館 4 階 N-411 内線 5459 takasi-i@info.kindai.a.jp コンパイラの構造 字句解析系 構文解析系 制約検査系 中間コード生成系 最適化系 目的コード生成系 処理の流れ情報システムプロジェクト I の場合 output (ab); 字句解析系 output
More informationP03.ppt
(2) Switch case 5 1 1 2 1 list0317.c if /*/ intnum; printf(""); scanf("%d", &num); 2 if (num % 3 == 0) puts( 0"); else if (num % 3 == 1) puts(" 1"); else puts( 32"); 3 if list0318.c /*/ intnum; printf("");
More informationJacques Garrigue
Jacques Garrigue Garrigue 1 Garrigue 2 $ print_lines () > for i in $1; do > echo $i > done $ print_lines "a b c" a b c Garrigue 3 Emacs Lisp (defun print-lines (lines) (dolist (str lines) (insert str)
More information4 (induction) (mathematical induction) P P(0) P(x) P(x+1) n P(n) 4.1 (inductive definition) A A (basis ) ( ) A (induction step ) A A (closure ) A clos
4 (induction) (mathematical induction) P P(0) P(x) P(x+1) n P(n) 4.1 (inductive definition) A A (basis ) ( ) A (induction step ) A A (closure ) A closure 81 3 A 3 A x A x + A A ( A. ) 3 closure A N 1,
More informationアルゴリズムとデータ構造1
1 200972 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi ://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2009/index.html 29 20 32 14 24 30 48 7 19 21 31 Object public class
More information: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
1 2 3 4 1 1 2 1 2.1 : : : : : : : : : : : : : : : : : : : : : : : : 1 2.2 : : : : : : : : : : : : : : : : : : : 1 2.3 : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 2.4 : : : : : : : : : : : :
More informationプログラミング言語 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 informationALG ppt
2012614 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 2 2 3 29 20 32 14 24 30 48 7 19 21 31 4 N O(log N) 29 O(N) 20 32 14 24 30 48 7 19 21 31 5
More information言語プロセッサ2005 -No.6-
言語プロセッサ 2014 -No.5- 東京工科大学 コンピュータサイエンス学部 亀田弘之 お知らせ ( 確認 ) 平成 26 年 11 月 17 日 ( 月 ) は休講 平成 26 年 12 月 20 日 ( 土 ) に補講の予定 ( 注 ) 平成 26 年 1 月 21 日 ( 水 ) も台風補講の予定 言語プロセッサ 2014 担当 : 亀田弘之 ( 東京工科大学 ) 2 これからの内容 1.
More information2
2011.11.11 1 2 MapReduce 3 4 5 6 Functional Functional Programming 7 8 9 10 11 12 13 [10, 20, 30, 40, 50] 0 n n 10 * 0 + 20 * 1 + 30 * 2 + 40 * 3 + 50 *4 = 400 14 10 * 0 + 20 * 1 + 30 * 2 + 40 * 3 + 50
More informationCopyright c 2006 Zhenjiang Hu, All Right Reserved.
1 2006 Copyright c 2006 Zhenjiang Hu, All Right Reserved. 2 ( ) 3 (T 1, T 2 ) T 1 T 2 (17.3, 3) :: (Float, Int) (3, 6) :: (Int, Int) (True, (+)) :: (Bool, Int Int Int) 4 (, ) (, ) :: a b (a, b) (,) x y
More informationuntitled
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 informationMicrosoft PowerPoint - IntroAlgDs-05-4.ppt
アルゴリズムとデータ構造入門 2005 年 0 月 25 日 アルゴリズムとデータ構造入門. 手続きによる抽象の構築.2 Procedures and the Processes They generate ( 手続きとそれが生成するプロセス ) 奥乃 博. TUT Scheme が公開されました. Windows は動きます. Linux, Cygwin も動きます. 0 月 25 日 本日のメニュー.2.
More informationorg/ghc/ Windows Linux RPM 3.2 GHCi GHC gcc javac ghc GHCi(ghci) GHCi Prelude> GHCi :load file :l file :also file :a file :reload :r :type expr :t exp
3 Haskell Haskell Haskell 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 6. C Java 3.1 Haskell Haskell GHC (Glasgow Haskell Compiler 1 ) GHC Haskell GHC http://www.haskell. 1 Guarded Horn Clauses III - 1 org/ghc/ Windows
More informationC¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç
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 informationmemo
計数工学プログラミング演習 ( 第 6 回 ) 2016/05/24 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : 再帰呼び出し 2 分探索木 深さ優先探索 課題 : 2 分探索木を用いたソート 2 再帰呼び出し 関数が, 自分自身を呼び出すこと (recursive call, recursion) 再帰を使ってアルゴリズムを設計すると, 簡単になることが多い
More informationlexex.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 informationParametric Polymorphism
ML 2 2011/04/19 Parametric Polymorphism Type Polymorphism ? : val hd_int : int list - > int val hd_bool : bool list - > bool val hd_i_x_b : (int * bool) list - > int * bool etc. let hd_int = function (x
More informationMicrosoft Word - NonGenTree.doc
ジェネリクスとコンパレータを使用しない 2 分探索木のプログラム例 BinTreeNG.java: 2 分探索木のクラス BinTreeNG BinTreeTesterNG.java: BinTreeNG を利用するプログラム例 === BinTreeNG.java =========================================================================
More information連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) 文字列の分解 1 1 Haskell lines Prelude lines :: String -> [String] lines "" = [] lines s = let (l,s'
連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) nobsun@sampou.org 文字列の分解 1 1 Haskell lines Prelude lines :: String -> [String] lines "" = [] lines s = let (l,s') = break ('\n'==) s in l : case s' of [] -> [] (_:s'')
More informationr1.dvi
Ruby 2009.9.7 1 ( ) --- ( ( ) ( ) 1 --- ( ) 1 ( ) (?) IT 7K( )?? ( ) ( )? IT ( ) --- ( ) 1 ( ) --- ( ) (?) 2-3% Top-Level ICT Professional 5% ICT Professional 10% 100% 50% 20% Devl. Experiment Adv. ICT
More informationMicrosoft Word - Javacc.docx
JavaCC 実習レポート課題について以下の実習のために コンパイラのページ http://www.info.kindai.ac.jp/compiler/ から javacc.zip をダウンロードしてください javacc.zip は以下のファイルから成ります javacc/ sample0.k, sample1.k, samplell2.k : k 言語の例プログラム sample0.asm,
More information1: JX-model XML File Package Import Class Intf Ctor Method SInit Field Param Local ExtdOpt ImplOpt ThrwOpt Members QName Type Stmt Label Expr ident li
Sapid JX-model ver. 1.3.13 2003 2 27 1 JX-model Java XML JX-model JX-model Java (Java 2 ver. 1.4) 20 7 JX-model 1 ^ $ Child nodes JX-model / ( ) JX-model @ @id @sort 1.1 File File JX-model XML /Package,
More information今回の予定 文法から パーサを作る BNF をそのまま解釈する BISON,YACC を動かしてみます 電卓 ( もどき ) を離れ本格的なプログラミング言語を記述するのに必要な構成要素を考えます 正常系だけを相手にするなら ( エラー処理を考えないなら ) 言語の実装はとても簡単 ( 課題ではない
プログラミング言語処理系論 (5) Design and Implementation of Programming Language Processors 佐藤周行 ( 情報基盤センター / 電気系専攻融合情報学コース ) 今回の予定 文法から パーサを作る BNF をそのまま解釈する BISON,YACC を動かしてみます 電卓 ( もどき ) を離れ本格的なプログラミング言語を記述するのに必要な構成要素を考えます
More informationfp.gby
1 1 2 2 3 2 4 5 6 7 8 9 10 11 Haskell 12 13 Haskell 14 15 ( ) 16 ) 30 17 static 18 (IORef) 19 20 OK NG 21 Haskell (+) :: Num a => a -> a -> a sort :: Ord a => [a] -> [a] delete :: Eq a => a -> [a] -> [a]
More informationMicrosoft PowerPoint - 03BNFScanner.ppt [互換モード]
コンパイラ理論 3 BNF と EBNF そして構文解析へ 3 章ステップ 1: 問題の把握 櫻井彰人 と文法 と EBNF 言語仕様 プログラムと言語仕様との関係 コンパイラ入門 C# で学ぶ理論と実践 より 3.2 BNF(Backus Naur Form) 文法 を記述する表記法 コンピュータ言語を表す為に使われることが多い 英文法 単語と単語の構成 関係を表す 5 文型は単語の品詞から英文の型を表現している
More informationCondition DAQ condition condition 2 3 XML key value
Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................
More informationC言語によるアルゴリズムとデータ構造
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 informationMicrosoft 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 informationMicrosoft PowerPoint - IntroAlgDs-06-8.ppt
アルゴリズムとデータ構造入門 2006 年 11 月 21 日 アルゴリズムとデータ構造入門 2. データによる抽象の構築 2.2 階層データ構造と閉包性 奥乃博大学院情報学研究科知能情報学専攻知能メディア講座音声メディア分野 http://winnie.kuis.kyoto-u.ac.jp/~okuno/lecture/06/introalgds/ okuno@i.kyoto-u.ac.jp 12
More informationMicrosoft 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研修コーナー
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 informationML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1
More Logic More Types ML/OCaml GADT Jacques Garrigue ( ) Jacques Le Normand (Google) Didier Rémy (INRIA) @garriguejej ocamlgadt ML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1 ( ) ML type nebou and
More informationMicrosoft PowerPoint - 03BNFScanner-print.ppt
コンパイラ理論 3 BNF と EBNF の復習そして構文解析へ 3 章問題の把握ステップ 1 櫻井彰人 と文法 と EBNF 言語仕様 プログラムと言語仕様との関係 コンパイラ入門 C# で学ぶ理論と実践 より 3.2 BNF(Backus Naur Form) 文法 を記述する表記法 コンピュータ言語を表す為に使われることが多い 英文法 単語と単語の構成 関係を表す 5 文型は単語の品詞から英文の型を表現している
More informationMinimum 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 informationhaskell.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 informationCodeIgniter Con 2011, Tokyo Japan, February
CodeIgniter Con 2011, Tokyo Japan, February 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 http://www.iviking.org/fx.php/ 25 26 10 27 28 29 30 31
More information05-01.知的文書処理技術.doc
31 5.1 5.1.1 FEP [76], [78], [88]-[92] [75] AI [76] [78], [92]. 5.1.2 5.1.2.1 JFK JFK grouping Table 5-1-1 Table 5-1-1Category of JFK Type Group G0 GJ GF GB JFK Type K J or JK F or FK JF or JFK parsing
More informationMicrosoft Word - problem5.doc
コンパイラ演習 : 作成問題 5 ( 最終課題 ) ( 担当 : 佐々木晃 ) 目的機械は hsm 仮想機械とする 昨年度までの講義資料 ( 中田先生 開先生による ) も参考にすること 演習問題 B5( 締め切り =2008/01/27) 問題番号 : B5 課題名 : コンパイラの作成 5 ( 昨年度の第 5 回とは問題が異なるので 間違わないようにしてください ) 問題 JavaCC を用いて,
More informationMicrosoft PowerPoint - kougi10.ppt
C プログラミング演習 第 10 回二分探索木 1 例題 1. リストの併合 2 つのリストを併合するプログラムを動かしてみる head1 tail1 head2 tail2 NULL NULL head1 tail1 tail1 があると, リストの併合に便利 NULL 2 #include "stdafx.h" #include struct data_list { int data;
More informationJavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2
JavaScript (2) 1 JavaScript 1.! 1. 2. 3. DOM 4. 2. 3. Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 (1) var a; a = 8; a = 3 + 4; a = 8 3; a = 8 * 2; a = 8 / 2; a = 8 % 3; 1 a++; ++a; (++
More informationparser.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_0212_68<5A66><4EBA><79D1>_<6821><4E86><FF08><30C8><30F3><30DC><306A><3057><FF09>.pdf
More information
() () (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 informatione.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 informationFor_Beginners_CAPL.indd
CAPL Vector Japan Co., Ltd. 目次 1 CAPL 03 2 CAPL 03 3 CAPL 03 4 CAPL 04 4.1 CAPL 4.2 CAPL 4.3 07 5 CAPL 08 5.1 CANoe 5.2 CANalyzer 6 CAPL 10 7 CAPL 11 7.1 CAPL 7.2 CAPL 7.3 CAPL 7.4 CAPL 16 7.5 18 8 CAPL
More informationK227 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 informationGray [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