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

Size: px
Start display at page:

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

Transcription

1 8 (lexer) (parser) 1 / 73

2 (lexer, tokenizer) (parser) Web Page (HTML XML) CSV, SVG, config file... ( )! 2 / 73

3 1 1 OCaml : ocamllex ocamlyacc 2 Python : ply 2! 3 / 73

4 ( ) 字句解析器 構文解析器 ご注文はうさぎさんですか? 文字列 接頭詞名詞助詞名詞名詞助動詞助詞記号ご注文はうさぎさんですか? 字句列 構文 名詞句 文 名詞句 動詞句 動詞句 接頭詞名詞助詞名詞名詞助動詞助詞記号ご注文はうさぎさんですか? 注 : 動詞句 などのラベルは本気にしないでください 4 / 73

5 let_expr expr expr expr expr term term term term term pr pr pr pr pr pr pr LET ID EQ ID PLUS ID PLUS NUM MUL ID IN ID ID let x = a + b + 2 * c in f x let x = a + b + 2 * c in f x 5 / 73

6 ? : : ( ) 6 / 73

7 ocamllex : ocamllex =.mll (OCaml ) (calc lex.mll) 1 { (* : OCaml *) 2 type token = 3 NUM of (int) 4 PLUS 5 EOF 6 } 7 8 (* *) 9 rule lex = parse 10 [ \t \n ] { lex lexbuf } (* *) 11 "+" { PLUS } 12 [ 0-9 ]+ as s { NUM(int_of_string s) } 13 eof { EOF } { (* OCaml *) } 7 / 73

8 .mll { OCaml } (* *) let id =... rule lex = parse { } { }... { } { OCaml } { } : (prefix) ( ) as 1 [ 0-9 ]+ as s { NUM(int_of_string s) } 1 let digit = [ 0-9 ] 1 digit+ as s { NUM(int_of_string s) } 8 / 73

9 ocamllex ( ) 1 ( ) a a [ a b c ] a, b, c [ 0-9 ] 0, 1,..., 9 "abc" abc "abc" "def" abc def "abc"* abc 0 "abc"+ abc 1 ("abc" "def")+ (abc def) 1 eof manual-ocaml-400/manual026.html ( ) manual026.html ( ) 9 / 73

10 : ( ) ( ) A A ( ) ϵ a (a A) a RS (R, S ) R S R S (R, S ) R S R (R ) R 0 ( : (abc def)+) ( ) 10 / 73

11 ocamllex ocamllex (.mll) OCaml (.ml) 1 $ ocamllex calc lex.mll 2 6 states, 267 transitions, table size 1104 bytes 3 $ ls 4 calc lex.ml calc_lex.mll.ml lex (.mll rule lex = parse... ) 1 $ ocaml -init calc_lex.ml 2 OCaml version # lex ;; 5 - : Lexing.lexbuf -> token = <fun> Lexing.lexbuf ( C FILE*) mutable record lex buf buf 11 / 73

12 Lexing.lexbuf 1 Lexing.from string "12+34* 56" 1 Lexing.from channel stdin 1 Lexing.from channel (open_in "exp.txt") 12 / 73

13 $ ocamllex calc_lex.mll 6 states, 267 transitions, table size 1104 bytes $ ocaml -init calc_lex.ml OCaml version # let b = Lexing.from_string " ";; val b : Lexing.lexbuf = {... ( )... } # lex b;; - : token = NUM 12 # lex b;; - : token = PLUS # lex b ;; - : token = NUM 34 # lex b ;; - : token = PLUS # lex b;; - : token = NUM 56 # lex b;; - : token = EOF rule lex = parse [ \t \n ] { lex lexbuf } "+" { PLUS } [ 0-9 ]+ as s { NUM(int_of_string s) } eof { EOF } 13 / 73

14 ocamlyacc : /* + OCaml */ %{ (* OCaml *) %} /* */ %token <int> NUM %token PLUS EOF /* ( ) */ %start program %type <int> program %% /* */ expr : NUM { $1 } expr PLUS NUM { $1 + $3 } program : expr EOF { $1 } %% (* OCaml *) =.mly : %% 3 + OCaml OCaml %token : %start : ( ) %type : ( ) :.mll.mly ( ) 14 / 73

15 ocamlyacc menhir ocamlyacc menhir ocaml ocamlyacc 15 / 73

16 ocamlyacc : 1 expr : expr PLUS NUM {... } : expr ( ) PLUS (1 ) NUM ( ) expr ( ) {...} ( ) : ( ) ( ) expr expr PLUS NUM } } / 73

17 ( ) : T : NT : S NT. a = b 1 b n (n 0, a NT, b i NT T ). : b 1,... bn, a : bi b i 1 ( ) ( ) 17 / 73

18 OCaml $1, $2,... : a = b 1... b n a : 1 expr : expr PLUS NUM { $1 + $3 } : expr PLUS NUM 1 expr( ) 3 NUM( ) 18 / 73

19 ocamlyacc ocamlyacc.mly 2 OCaml (.ml.mli).mli? 1 $ ocamlyacc calc_parse.mly 2 $ ls 3 calc parse.ml calc parse.mli calc_parse.mly.ml.mly %start program program 19 / 73

20 ocamlyacc ( ) 1 $ ocaml -init calc_parse.ml 2 OCaml version # program ;; 5 - : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> int = <fun> Lexing.lexbuf -> token int.mly (%type <int> parse) token token (token ) 20 / 73

21 (lex) (program) 1 # program lex (Lexing.from_string " ") : 1 2 :.mll token.mly token 21 / 73

22 token token.mll 1 $ ocaml -init calc_lex.ml 2 # lex;; 3 - : Lexing.lexbuf -> token = <fun> token calc lex.ml token.mly 1 $ ocaml -init calc_parse.ml 2 # program ;; 3 - : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> int = <fun> calc parse.ml token OCaml 22 / 73

23 token 1:.mll token.mly 2:.mly token.mll 1 23 / 73

24 token calc lex.mll : 1 { 2 (* token *) 3 (* PLUS 4 calc_parse.ml ( ) 5 *) 6 open Calc parse 7 } 8 rule lex = parse 9 [ \t \n ] { lex lexbuf } 10 "+" { PLUS } 11 [ 0-9 ]+ as s { NUM(int_of_string s) } 12 eof { EOF } 24 / 73

25 1 $ ocaml ocaml_lex.ml ocaml_parse.ml # NG 2 $ ocaml -init ocaml_lex.ml -init ocaml_parse.ml # NG : ocaml.ml ocaml.ml ocamlc (.cmo) 25 / 73

26 1 $ ocamllex calc_lex.mll 2 $ ocamlyacc calc_parse.mly 3 # ocamlc 3! 4 # parse, lex 5 $ ocamlc -c calc parse.mli calc parse.ml calc lex.ml 6 # ocaml.cmo 7 $ ocaml calc parse.cmo calc lex.cmo 8 OCaml version # Calc_parse.program;; 11 - : (Lexing.lexbuf -> Calc parse.token) -> Lexing.lexbuf -> int = <fun> 12 # Calc_lex.lex;; 13 - : Lexing.lexbuf -> Calc parse.token = <fun> 1 # Calc_parse.program Calc_lex.lex (Lexing.from_string " ");; 2 - : int = / 73

27 OCaml.ml.ml.cmo ( ) ocaml.cmo ocamlc -c ( ) : calc lex.ml calc parse.ml token calc parse.ml calc lex.ml 27 / 73

28 : ocamlbuild OCaml ( ) 1 $ ocamlbuild calc lex.byte 2 /usr/bin/ocamllex -q calc_lex.mll 3 /usr/bin/ocamldep -modules calc_lex.ml > calc_lex.ml.depends 4 /usr/bin/ocamlyacc calc_parse.mly 5 /usr/bin/ocamldep -modules calc_parse.mli > calc_parse.mli.depends 6 /usr/bin/ocamlc -c -o calc_parse.cmi calc_parse.mli 7 /usr/bin/ocamlc -c -o calc_lex.cmo calc_lex.ml 8 /usr/bin/ocamldep -modules calc_parse.ml > calc_parse.ml.depends 9 /usr/bin/ocamlc -c -o calc_parse.cmo calc_parse.ml 10 /usr/bin/ocamlc calc_parse.cmo calc_lex.cmo -o calc_lex.byte 11 $ ls 12 build/ calc lex.byte calc_lex.mll calc_parse.mly 13 # _build 14 # -I _build 15 $ ocaml -I build _build/*.cmo 16 OCaml version # 28 / 73

29 ocamlmktop *.cmo 1 $ ocaml -I _build _build/*.cmo 2 OCaml version # ocaml 1 $ ocamlmktop -o calc.top _build/*.cmo *.cmo ( calc.top) 1 $./calc.top -I build 2 OCaml version # 29 / 73

30 OCaml ( : abc.ml) ( / etc.) 1: Abc. 2: open Abc ocamlc ocaml ocamlmktop *.cmi *.cmo -I 30 / 73

31 (1) 1 expr : 2 NUM 3 expr PLUS NUM { $1 + $3 }? expr : NUM NUM PLUS expr { $1 + $3 } expr : NUM expr PLUS expr { $1 + $3 } (+) (left associative) : a + b + c = ((a + b) + c) 31 / 73

32 (2) * ( )? 1 expr : 2 NUM 3 expr PLUS NUM { $1 + $3 } 4 expr MUL NUM { $1 * $3 } = (3 + 4) 5 = = 3 + (4 5) = 23 * (term) + (expr) 32 / 73

33 : ocamlyacc %left ( ) %right ( ) 33 / 73

34 3 1 (1 ) 2 OCaml (3 ) 3 OCaml (4 ) ( ) let ( ) 34 / 73

35 ( ) + ( ) + + 0: ( ) 1: (let) 2: 35 / 73

36 1 expr : 2 NUM { $1 } 3 expr PLUS NUM { $1 +. $3 } 1 # parse_string " * 5.6" 2 - : float = ( ) ( ) : : 36 / 73

37 : * 5.6 : + * e 0 +e 1 : e0 の構文木 e1 の構文木 OCaml 1 type expr = Plus of expr * expr 37 / 73

38 ( ). + eval_expr = eval_expr + e0 の構文木 eval_expr e1 の構文木 e0 の構文木 e1 の構文木 : eval expr (e 0 + e 1 ) = (eval expr e 0 ) + (eval expr e 1 ) OCaml : 1 let rec eval_expr e = 2 match e with Plus (e0, e1) -> (eval_expr e0) + (eval_expr e1) 38 / 73

39 x + 1 ( )x NG: : let x = in x : x = 3.3 x : 39 / 73

40 : : {x 3.3, y 4.4} let x = in x : eval expr (let x = in x + 4.4) {} = eval expr (x + 4.4) {x 3.3} = eval expr x {x 3.3} + eval expr 4.4 {x 3.3} = = [ (x, 3.3); (y, 4.4) ] 40 / 73

41 f f x = x * x (f 3) {x 3} x * x eval expr (e 0 e 1 ) e = let f = eval expr e 0 in let v = eval expr e 1 in eval expr (f ) {f v} =, ( ) 41 / 73

42 ? : 1 let make_adder x = 2 let f y = x + y in f 3 ;; 4 let a11 = make_adder 1.1 in 5 a a x + y {y 2.2} (x ) x = 1.1 a11 ( ) (2 ) =, ( ), 42 / 73

43 : 2?? 43 / 73

44 ϵ A = a A = a RS A = RS R S A = R, A = S R A =, A = A R 44 / 73

45 ? ϵ A = a A = a RS A = R S R S A = R, A = S R A =, A = A R? A =, A = AR A =, A = RA (R A ) 45 / 73

46 ? : = A =, A = aab a n b n (n 0) / 73

47 A =, A = aab * ( ) * 1 k a k b k? a ( b) a ( b) aa aaa aabb bb aa aaa aaa aabb bb ab a b a aa aabbb bb aa aabbb aabbb bb 47 / 73

48 OCaml 48 / 73

49 OCaml ( ) : ocamllex, ocamlyacc OCaml (.ml ) OCaml 49 / 73

50 OCaml 3 OCaml 3 1 (ocaml) 2 (ocamlc); 3 (ocamlopt); 50 / 73

51 : (hi.ml) 1 Printf.printf "hello\n" 1 $ ocaml hi.ml 2 hello 1 $ ocaml 2 # #use "hi.ml";; 3 # 1 $ ocaml -init hi.ml 2 # 1 $ ocamlc hi.ml 2 $ ls 3 a.out* hi.cmi hi.cmo hi.ml 4 $./a.out 5 hello 1 $ ocamlopt hi.ml 2 $ ls 3 a.out* hi.cmi hi.cmx hi.ml hi.o 4 $./a.out 5 hello 51 / 73

52 ocamlc ocamlopt.cmi hi.ml ( hi.ml ).cmo hi.ml (.o ).cmx hi.ml (.o ).o a.out 52 / 73

53 -c -o ocamlc, ocamlopt C -o -c ocamlc : {.cmi,.cmo} ocamlopt : {.cmi,.cmx,.o} 53 / 73

54 : 2 msg.ml 1 let greeting = "hello" hi.ml 1 Printf.printf "%s\n" Msg.greeting hi.ml msg.ml greeting ( ) 1: (msg.ml greeting) Msg.greeting. = basename (.ml ) capitalize 54 / 73

55 open open 1 open Msg;; 2 Printf.printf "%s\n" greeting open 55 / 73

56 1: 1 $ ls 2 hi.ml msg.ml 3 $ ocamlc -o greet msg.ml hi.ml 4 $ ls 5 greet* hi.cmi hi.cmo hi.ml msg.cmi msg.cmo msg.ml 2: ( ) 1 $ ls 2 hi.ml msg.ml 3 $ ocamlc -c msg.ml # -> msg.{cmi,cmo} 4 $ ocamlc -c hi.ml # -> hi.{cmi,cmo} 5 $ ocamlc -o greet msg.cmo hi.cmo # -> greet 6 $./greet 7 hello 56 / 73

57 1: 1 $ ocamlc hi.ml msg.ml 2 File "hi.ml", line 1, characters 21-33: 3 Error: Unbound module Msg 2: 1 $ ls 2 hi.ml msg.ml 3 $ ocamlc -c hi.ml 4 File "hi.ml", line 1, characters 14-26: 5 Error: Unbound module Msg 2: ( : hi.ml).cmi ( : msg.cmi) 57 / 73

58 hi.ml msg.ml ( ) OK NG $ ocamlc msg.ml hi.ml $ ocamlc hi.ml msg.ml $ ocamlc -c msg.ml $ ocamlc -c hi.ml $ ocamlc -c hi.ml $ ocamlc -c msg.ml ( ) OK NG $ ocamlopt msg.ml hi.ml $ ocamlopt hi.ml msg.ml $ ocamlopt -c msg.ml $ ocamlopt -c hi.ml $ ocamlopt -c hi.ml $ ocamlopt -c msg.ml 58 / 73

59 (ocaml) 1: ocamlc.cmo ( ) 2: 1 $ ocaml msg.cmo hi.cmo 2 # NG 1 $ ocaml hi.cmo msg.cmo 2 File "_none_", line 1: 3 Error: Reference to undefined global Msg ocamlc.ml 59 / 73

60 ocamlmktop ocamlmktop.cmo 1 $ ocamlmktop -o greet msg.cmo hi.cmo 2 $./greet 3 hello 4 OCaml version #.cmo 60 / 73

61 : OCaml 2 (.ml.mli).ml : ( C.c).mli : ( C.h).mli.ml ( ) ( ) : msg.ml 1 let real_mind = "you a** h*le" 2 let greeting = "glad to see you" msg.mli (real mind ) 1 val greeting : string 61 / 73

62 .mli? ocamlyacc.mli 62 / 73

63 .mli.mli.cmi.ml.cmo 1 $ ocamlc a.ml 1 a.mli a.cmi, a.cmo a.cmi a.ml 2 a.mli a.cmi ( a.mli!).ml.cmi 3: ( : msg.ml) ( : msg.mli) ( : msg.cmi) 63 / 73

64 .mli : 6 a.{mli,ml}, b.{mli,ml}, c.ml, d.ml 1: 1 $ ocamlc -o program b.mli a.mli b.ml a.ml d.ml c.ml 2: 1 $ ocamlc -c b.mli 2 $ ocamlc -c a.mli 3 $ ocamlc -c b.ml 4 $ ocamlc -c a.ml 5 $ ocamlc -c d.ml 6 $ ocamlc -c c.ml 7 $ ocamlc -o program b.cmo a.cmo d.cmo c.cmo 1 $ ocaml b.cmo a.cmo d.cmo c.cmo 1 $ ocamlmktop -o program b.cmo a.cmo d.cmo c.cmo 64 / 73

65 ocamlbuild 1 $ ocamlbuild name.byte name.ml... (ocamldep) name.byte 1 $ ocamlbuild name.native 65 / 73

66 token 1:.mll token.mly.mll token 1: open Calc parse Calc parse ( ) 1 : token Calc parse.plus Calc parse.minus 2:.mly token.mll 2: ocamlyacc menhir menhir --external-tokens 1 $ menhir --external-tokens Calc_lex calc_parse.mly 66 / 73

67 : 1 ( ) calc lex.mll : Calc parse open calc parse.ml 1 { 2 open Calc_parse 3 } 4 rule lex = parse 5 [ \t \n ] { lex lexbuf } 6 "+" { PLUS } 7 "-" { MINUS } 8 [ 0-9 ]+ as s { NUM(int_of_string s) } 9 eof { EOF } 67 / 73

68 : 1 calc lex.mll calc parse.ml Calc parse.plus 1 { 2 } 3 rule lex = parse 4 [ \t \n ] { lex lexbuf } 5 "+" { Calc_parse.PLUS } 6 "-" { Calc_parse.MINUS } 7 [ 0-9 ]+ as s { Calc_parse.NUM(int_of_string s) } 8 eof { Calc_parse.EOF } 68 / 73

69 : 2 : 1 $ menhir --external-tokens Calc_lex calc_parse.mly.mll.mly token 69 / 73

70 : 1, 1 1 $ ocamllex calc_lex.mll 2 $ menhir calc_parse.mly 3 # lex parse parse, lex 4 $ ocamlc -c calc_parse.mli calc_parse.ml calc_lex.ml 5 $ ocaml calc_parse.cmo calc_lex.cmo 6 OCaml version # Calc_parse.program;; 9 - : (Lexing.lexbuf -> Calc parse.token) -> Lexing.lexbuf -> int = <fun> 10 # Calc_lex.lex;; 11 - : Lexing.lexbuf -> Calc parse.token = <fun> 70 / 73

71 : 2 1 $ ocamllex calc_lex.mll 2 6 states, 267 transitions, table size 1104 bytes 3 # calc_parse.ml token calc_lex.ml 4 $ menhir --external-tokens Calc_lex calc_parse.mly 5 # lex, parse 6 $ ocamlc -c calc_lex.ml calc_parse.mli calc_parse.ml 7 $ ocaml calc_lex.cmo calc_parse.cmo 8 OCaml version # Calc_parse.program;; 11 - : (Lexing.lexbuf -> Calc lex.token) -> Lexing.lexbuf -> int = <fun> 12 # Calc_lex.lex;; 13 - : Lexing.lexbuf -> Calc lex.token = <fun> 71 / 73

72 ocamlbuild 1, 1 calc lex.mly calc parse.mll calc lex.byte calc parse.cmo 1 $ ocamlbuild -use-menhir calc lex.byte 2 /usr/bin/ocamllex -q calc_lex.mll 3 /usr/bin/ocamldep -modules calc_lex.ml > calc_lex.ml.depends 4 menhir --raw-depend --ocamldep /usr/bin/ocamldep -modules calc_parse.mly > calc_parse.mly.depends 5 menhir --ocamlc /usr/bin/ocamlc --infer calc_parse.mly 6 /usr/bin/ocamldep -modules calc_parse.mli > calc_parse.mli.depends 7 /usr/bin/ocamlc -c -o calc_parse.cmi calc_parse.mli 8 /usr/bin/ocamlc -c -o calc_lex.cmo calc_lex.ml 9 /usr/bin/ocamldep -modules calc_parse.ml > calc_parse.ml.depends 10 /usr/bin/ocamlc -c -o calc_parse.cmo calc_parse.ml 11 /usr/bin/ocamlc calc_parse.cmo calc_lex.cmo -o calc_lex.byte 12 $ ocaml -I _build _build/*.cmo 13 OCaml version # 72 / 73

73 ocamlbuild 2 calc parse.mly calc lex.mll calc parse.byte calc lex.cmo 1 $ ocamlbuild -use-menhir -yaccflags --external-tokens,calc lex calc parse.byte 2 menhir --raw-depend --ocamldep /usr/bin/ocamldep -modules calc_parse.mly > calc_parse.mly.depends 3 menhir --ocamlc /usr/bin/ocamlc --external-tokens Calc_lex --infer calc_parse.mly 4 /usr/bin/ocamldep -modules calc_parse.mli > calc_parse.mli.depends 5 /usr/bin/ocamllex -q calc_lex.mll 6 /usr/bin/ocamldep -modules calc_lex.ml > calc_lex.ml.depends 7 /usr/bin/ocamlc -c -o calc_lex.cmo calc_lex.ml 8 /usr/bin/ocamlc -c -o calc_parse.cmi calc_parse.mli 9 /usr/bin/ocamldep -modules calc_parse.ml > calc_parse.ml.depends 10 /usr/bin/ocamlc -c -o calc_parse.cmo calc_parse.ml 11 /usr/bin/ocamlc calc_lex.cmo calc_parse.cmo -o calc_parse.byte 12 $ ocaml -I _build _build/*.cmo 13 OCaml version # 73 / 73

: 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

jssst-ocaml.mgp

jssst-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 information

ML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1

ML 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 information

Parametric Polymorphism

Parametric 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 information

第10回 モジュール

第10回 モジュール 1 FUNCTIONAL PROGRAMMING 第 10 回モジュール 萩野達也 hagino@sfc.keio.ac.jp 2 モジュール モジュールは以下のエンティティを含みます. 変数 型コンストラクタ データコンストラクタ フィールドラベル 型クラス クラスメソッド Java のパッケージに似ている 名前空間はモジュールごとに分かれている 名前 ( 識別子 ) はモジュールで一意的でなくてはいけない

More information

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

Objective Caml 3.12 Jacques Garrigue ( ) with Alain Frisch (Lexifi), OCaml developper team (INRIA)

Objective Caml 3.12 Jacques Garrigue ( )   with Alain Frisch (Lexifi), OCaml developper team (INRIA) Objective Caml 3.12 Jacques Garrigue ( ) http://www.math.nagoya-u.ac.jp/~garrigue/ with Alain Frisch (Lexifi), OCaml developper team (INRIA) Jacques Garrigue Modules in Objective Caml 3.12 1 Objective

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

ML 演習 第 4 回

ML 演習 第 4 回 ML 演習第 4 回 おおいわ Mar 6, 2003 今回の内容 補足 Ocaml のモジュールシステム structure signature functor Ocaml コンパイラの利用 2 識別子について 利用可能文字 先頭文字 : A~Z, a~z, _ ( 小文字扱い ) 2 文字目以降 : A~Z, a~z, 0~9, _, 先頭の文字の case で 2 つに区別 小文字 : 変数,

More information

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu II 4 : 2001 11 7 keywords: 1 OCaml OCaml (first-class value) (higher-order function) 1.1 1 2 + 2 2 + + n 2 sqsum 1 3 + 2 3 + + n 3 cbsum # let rec sqsum n = # if n = 0 then 0 else n * n + sqsum (n - 1)

More information

2

2 2 3 Page 4 5 6 A-1B-1 C0 D0 E0 F0 G0 A0 B0 C1 D1 E1 F1 G1 A1 B1 C2 D2 E2 F2 G2 A2 B2 C3 D3 E3 7 F3 G3 A3 B3 C4 D4 E4 F4 G4 A4 B4 C5 D5 E5 F5 G5 A5 B5 C6 D6 E6 F6 G6 A6 B6 C7 8 Page 9 1 2 3 1 2 10 1 11

More information

2

2 OCaml Web HTML5 IT PPL 2012 Web 2012 8 21 ( ) 14:30-17:30 2 Web JavaScript HTML5 3 Web JavaScript CoffeeScript Dart Haxe S2JS (Scala) JSX Ocamljs, Js_of_ocaml (OCaml) 4 OCaml 5 6 js_of_ocaml 7 OCaml Web

More information

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

Microsoft PowerPoint - 03BNFScanner.ppt [互換モード] コンパイラ理論 3 BNF と EBNF そして構文解析へ 3 章ステップ 1: 問題の把握 櫻井彰人 と文法 と EBNF 言語仕様 プログラムと言語仕様との関係 コンパイラ入門 C# で学ぶ理論と実践 より 3.2 BNF(Backus Naur Form) 文法 を記述する表記法 コンピュータ言語を表す為に使われることが多い 英文法 単語と単語の構成 関係を表す 5 文型は単語の品詞から英文の型を表現している

More information

Jacques Garrigue

Jacques 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 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

第12回 モナドパーサ

第12回 モナドパーサ 1 関数型プログラミング 第 13 回モナドパーサ 萩野達也 hagino@sfc.keio.ac.jp Slide URL https://vu5.sfc.keio.ac.jp/slide/ 2 モナドパーサ モナドを使って構文解析を行ってみましょう. data Parser a = Parser (String -> Maybe (a, String)) 字句解析も構文解析の一部に含めてしまいます.

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

# 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

連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) 文字列の分解 1 1 Haskell lines Prelude lines :: String -> [String] lines "" = [] lines s = let (l,s'

連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) 文字列の分解 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 information

坊っちゃん

坊っちゃん might is right I am glad to see you 1992 4 1 20 1 2 1987 62 10 27 1 5-86 1999

More information

ML 演習 第 4 回

ML 演習 第 4 回 ML 演習第 4 回 佐藤春旗, 山下諒蔵, 前田俊行 2006/06/20 ICFP Programming Contest 過去の O'Caml プログラムの実績 1998: 2 位 (ENS Camlist, France) 1999: 1 位 (Camls R Us, O'Caml 作者グループ ) 2000: 1 位 (PLClub, U-Penn, 米澤研住井, 細谷参加 ) 2 位 (Camls

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

1

1 0 1 2 OK NG 3 ID 4 CMS 5 CMS 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [PDF 7KB] [ ] 22 23 (HP ( pt) ) () ( 24 25 ( ) 26 27 28 29 #() URL # # 30 [PDF 7KB] [ ] 31 32 33 34 35 HTML HTML 36 37 38 39 40

More information

Terminal ocaml $ ocaml Objective Caml version # 1+2;;<ret> # 1+2;; - : int = 3 ;; OCaml <ret> - : int = 3 OC

Terminal ocaml $ ocaml Objective Caml version # 1+2;;<ret> # 1+2;; - : int = 3 ;; OCaml <ret> - : int = 3 OC Jacques Garrigue, 2013 8 8-9 OCaml 1 OCaml OCaml ML ML Haskell ML Haskell ML 70 Edinburgh LCF Robin Milner 1 Caml ML OCaml OCaml OCaml-Nagoya OCaml 2007 in OCaml 2007 (Computer Science Library 3) 2007

More information

untitled

untitled 7/67/1073,42911 15,020158,393 7/127/184,6674,913 2927 71.3 894 21.8 287 7.0 n=4108) 132 3.2 62 1.5 934 22.7 786 19.1 629 15.3 801 19.5 407 9.9 357 8.7 (n=4108) 35 35 30 25 20 15 10 153 3.7 1 0.02 23 0.6

More information

Microsoft PowerPoint - 03BNFScanner-print.ppt

Microsoft PowerPoint - 03BNFScanner-print.ppt コンパイラ理論 3 BNF と EBNF の復習そして構文解析へ 3 章問題の把握ステップ 1 櫻井彰人 と文法 と EBNF 言語仕様 プログラムと言語仕様との関係 コンパイラ入門 C# で学ぶ理論と実践 より 3.2 BNF(Backus Naur Form) 文法 を記述する表記法 コンピュータ言語を表す為に使われることが多い 英文法 単語と単語の構成 関係を表す 5 文型は単語の品詞から英文の型を表現している

More information

PR

PR 1-4 29 1-13 41 1-23 43 1-39 29 PR 1-42 28 1-46 52 1-49 47 1-51 40 1-64 52 1-66 58 1-72 28 1-74 48 1-81 29 1-93 27 1-95 30 1-97 39 1-98 40 1-100 34 2-1 41 2-5 47 2-105 38 2-108 44 2-110 55 2-111 44 2-114

More information

54 144 144 144 144 144 80 152 84 122 HTML

54 144 144 144 144 144 80 152 84 122 HTML 54 144 144 144 144 144 80 152 84 122 HTML P20 P24 P28 P40 P54 P84 P122 P138 P144 P152 P220 P234 P240 P242 1 1-1 1-2 1-3 1-4 1-5 1 1-6 1 2 2-1 2-2 A C D E F 2 G H I 2-3 2-4 C D E E A 2

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

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

Dive into Algebraic Effects

Dive into Algebraic Effects Dive into Algebraic Effects びしょ じょ ML Days #2 September 16, 2018 やること Algebraic Effects を伝道 Algebraic Effects is 何 Algebraic Effects が使える言語 Algebraic Effects の活用事例 研究のご紹介先日 JSSST でポスター発表した内容を紹介シマス 目次 自己紹介

More information

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

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

More information

オートマトンと言語

オートマトンと言語 アルゴリズムとデータ構造 III 2 回目 :10 月 15 日 文脈自由文法,CYK 法 授業資料 http://ir.cs.yamanashi.ac.jp/~ysuzuki/algorithm3/index.html 授業の予定 ( 中間試験まで ) 1 10/01 スタック ( 後置記法で書かれた式の計算 ) 2 3 4 5 6 7 8 9 10/15 文脈自由文法, 構文解析,CYK 法 10/22

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

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

untitled

untitled Fortran90 ( ) 17 12 29 1 Fortran90 Fortran90 FORTRAN77 Fortran90 1 Fortran90 module 1.1 Windows Windows UNIX Cygwin (http://www.cygwin.com) C\: Install Cygwin f77 emacs latex ps2eps dvips Fortran90 Intel

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 - 04SyntaxAnalysis.ppt [互換モード]

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

More information

r03.dvi

r03.dvi 19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---

More information

200608094-101

200608094-101 94 A O D 1 A 1 A A 1 AO 1 95 A OA 1 a r A A 1 r A R 1 A R 1 A R 1 a a A OA R 1 96 F AO 1 A O 1 A 1 A O 1 A 1 O A 1 97 b O AO 1 O AO 1 A 1 A OA 1 AO 1 AA 1 98 A AO 1 A AO 1 b b 1 b b B B A 1 Q 1 rr 1 99

More information

プログラミング言語処理系論 (4) Design and Implementation of Programming Language Processors

プログラミング言語処理系論 (4) Design and Implementation of Programming Language Processors プログラミング言語処理系論 (4) Design and Implementation of Programming Language Processors 佐藤周行 ( 情報基盤センター / 電気系専攻融合情報学コース ) 今回の予定 言語規格を読むことの続き BNF だけでできることは限られてくる 文法の定義 + 制約 という記述の発明 文法から パーサを作る BNF をそのまま解釈する BISON,YACC

More information

test.gby

test.gby Beautiful Programming Language and Beautiful Testing 1 Haskeller Haskeller 2 Haskeller (Doctest QuickCheck ) github 3 Haskeller 4 Haskell Platform 2011.4.0.0 Glasgow Haskell Compiler + 23 19 8 5 10 5 Q)

More information

untitled

untitled PPL 2006 MinCaml (myth) vs. vs. vs. Haskell (www.haskell.org) ML (www.standardml.org, caml.inria.fr) Standard ML (SML), Objective Caml (OCaml) Scheme (www.schemers.org) low level GCC C GCJ Java

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information

2018年度「プログラミング言語」配布資料 (7)

2018年度「プログラミング言語」配布資料 (7) 2018 年度 プログラミング言語 配布資料 (7) 五十嵐淳 2018 年 11 月 18 日 目次 1 モジュールと実装の隠蔽 1 1.1 階層的名前空間の提供........................................ 2 1.2 実装の隠蔽.............................................. 6 1.3 分割コンパイル (ocaml/bstmodule2)................................

More information

101NEO資料

101NEO資料 Version 1.5 Tutorial PDF ... 1. PDF... 2 -.... 2 -. PDF... 2 -.... 4 -. HTML... 4 -. PDF... 5 -.... 7 -.... 8 Tutorial PDF Tutorial PDF - Page 1 Tutorial PDF - Page 2 Tutorial PDF - Page 3 Tutorial PDF

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

Microsoft PowerPoint - 13Kadai.pptx

Microsoft PowerPoint - 13Kadai.pptx 提出 講義での説明を聞いて下さい 櫻井彰人 コンパイラ理論課題 締め切りは 8 月 1 日とします 順不同で できるものをできるだけ多く回答して下さい 電子メールで sakurai あっと ae どっと keio どっと ac どっと jp に送ってください ファイル形式は pdf か MsWord で ただし プログラムはテキストファイルで レポート課題 1 それぞれ 1 問として考えます 電卓

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

スライド タイトルなし

スライド タイトルなし LightCycler Software Ver.3.5 : 200206 1/30 Windows NT Windows NT Ctrl + Alt + Delete LightCycler 3 Front Screen 2/30 LightCycler3 Front RUN Data Analysis LightCycler Data Analysis Edit Graphics Defaults

More information

1 I EViews View Proc Freeze

1 I EViews View Proc Freeze EViews 2017 9 6 1 I EViews 4 1 5 2 10 3 13 4 16 4.1 View.......................................... 17 4.2 Proc.......................................... 22 4.3 Freeze & Name....................................

More information

Emacs ML let start ::= exp (1) exp ::= (2) fn id exp (3) ::= (4) (5) ::= id (6) const (7) (exp) (8) let val id = exp in

Emacs ML let start ::= exp (1) exp ::= (2) fn id exp (3) ::= (4) (5) ::= id (6) const (7) (exp) (8) let val id = exp in Emacs, {l06050,sasano}@sic.shibaura-it.ac.jp Eclipse Visual Studio Standard ML Haskell Emacs 1 Eclipse Visual Studio variable not found LR(1) let Emacs Emacs Emacs Java Emacs JDEE [3] JDEE Emacs Java 2

More information

Microsoft PowerPoint L03-Syntex and Semantics-1-students ( )

Microsoft PowerPoint L03-Syntex and Semantics-1-students ( ) プログラミング言語論 A (Concepts on Programming Languages) 趙建軍 (Jianjun Zhao) http://stap.ait.kyushu-u.ac.jp/~zhao/course/2018/concepts of Programming Languages.html 1 第 3 回 構文と意味 (1) (Syntax and Semantics) 2017.04.26

More information

51 Debian

51 Debian 51 Debian 2009 4 18 51 Debian 2009 4 1 Introduction Debian Debian Debian Debian Debian Developer () face-toface Debian Debian Debian Debian Package Debian 2009 1. () 2. OSC Tokyo 3. VAIO P ( )(?) 4. Git

More information

NOTE P, A,. A P ( A, P ),,.,. P A. (set) (set), (). (element), (element).,.,. ( A, B, X, Y, P ), { } (),..3 (union) A, B,A B, A B (union),. A B = {x x

NOTE P, A,. A P ( A, P ),,.,. P A. (set) (set), (). (element), (element).,.,. ( A, B, X, Y, P ), { } (),..3 (union) A, B,A B, A B (union),. A B = {x x 2. (set)............... 2.2,.... 2.3 (union)............ 2.4 (intersection)......... 2.5 (power set)......... 3.6 (cartesian product set)... 3 2, 3 2. (length)........ 3 2.2 (epsilon)............ 3 2.3

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

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

Python Speed Learning

Python   Speed Learning Python Speed Learning 1 / 76 Python 2 1 $ python 1 >>> 1 + 2 2 3 2 / 76 print : 1 print : ( ) 3 / 76 print : 1 print 1 2 print hello 3 print 1+2 4 print 7/3 5 print abs(-5*4) 4 / 76 print : 1 print 1 2

More information

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV tutimura@mist.i.u-tokyo.ac.jp kaneko@ipl.t.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 11 20 p.1/34 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20

More information

Page () &

Page () & () () Page () & Page 110kg 67kg 138kg Page Page Page Page, Page () (S3)(S1 (S2) (S1) (S2)(S1) (S3) (S1) (A2)(A1) (A3)(S1) (S3)(S1) (A2)(A1) (A3)(A1) (A3) (A1) (S2) (S1) Page () 10 () () () () () () ()

More information

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B A/B (2018/10/19) 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 10 19 A/B 1 2018 10 19 2 1 1 1.1 OHP.................................... 1

More information

WebOS aplat WebOS WebOS 3 XML Yahoo!Pipes Popfry UNIX grep awk XML GUI WebOS GUI GUI 4 CUI

WebOS aplat WebOS WebOS 3 XML Yahoo!Pipes Popfry UNIX grep awk XML GUI WebOS GUI GUI 4 CUI 7 XML Week Web WebOS WebShell WebOS WebOS GUI WebOS WebOS 2 WebOS aplat WebOS WebOS 3 XML Yahoo!Pipes Popfry UNIX grep awk XML GUI WebOS GUI GUI 4 CUI CUI JavaScript I/O CommandClass WebShell webshell

More information

Microsoft Word - Javacc.docx

Microsoft 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 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

XML ( ) XML XML jedit XML XPath XSLT jedit JAVA VM jedit Slava Pestov GNU GPL ( ) jedit jedit ( jedit XML jed

XML ( ) XML XML jedit XML XPath XSLT jedit JAVA VM jedit Slava Pestov GNU GPL ( ) jedit jedit (  jedit XML jed XML XML XML jedit XML XPath XSLT jedit JAVA VM jedit Slava Pestov GNU GPL ( jedit jedit (http://www.jedit.org/index.php jedit XML jedit Plugin Central (http://plugins.jedit.org/ jedit Java (Java VM = Java

More information

ohp08.dvi

ohp08.dvi 19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data

More information

fp.gby

fp.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 information

137

137 136 137 16 12 16 17 3 18 138 8 125 144 269 9 125 144 269 10 125 144 269 11 125 144 269 12 125 143 268 13 124 146 270 14 124 147 271 15 124 149 273 16 124 149 273 17 124 152 276 4 1 3 3 3 3 3 3 8 2,641

More information

&

& & & & c & B & c & & aa c c a a nk a a & a aa aaa & A A A A & 7 & & c og og & c c k g a og ok c c & 7 7 n & aa & & & & & & & & & & & g & & a a & & 171 1 & 1 7 1 1 6 de 666 66 6 7 6 f 6 & & c & 1 1 1 1 1

More information

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) 2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test

More information

Platypus-QM β ( )

Platypus-QM β ( ) Platypus-QM β (2012.11.12) 1 1 1.1...................................... 1 1.1.1...................................... 1 1.1.2................................... 1 1.1.3..........................................

More information

2

2 1 2 2005 15 17 21 22 24 25 67 95 3 1 2 3 4 17 4 5 6 7 8 9 PR PR PR 10 11 12 PR 419 844 1,490 950 590 20 12 50 13 12/20 2/28 3/30 14 17 349 666 15 59 6 11 15 17 14 15 15 17 3,525,992 15 59 15 17 18 910

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

LSM5Pascal Ver 3.2 GFP 4D Image VisArt Carl Zeiss Co.,Ltd.

LSM5Pascal Ver 3.2 GFP 4D Image VisArt Carl Zeiss Co.,Ltd. LSM5Pascal Ver 3.2 GFP 4D Image VisArt 2004.03 LSM5PASCAL V3.2 LSM5PASCAL SW3.2Axiovert200M 1 1 2 3 3 4 4 5 SingleTrack 9 Multi Track 10,18 5 / 21 6 3 27 7 35 8 ( OFF) 40 LSM5PASCAL V3.2 LSM5PASCAL 65

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

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

d-00

d-00 283-0105 298 TEL. 0475-76-0839 FAX. 0475-76-0838 400g 300 4950399167708 14 220g 300 4950399066780 Page 1 300g 200 4950399066766 100 400g 300 4950399167722 350g 160 4950399066735 100 600g 350 4950399167685

More information

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1 I117 II I117 PROGRAMMING PRACTICE II 2 MEMORY MANAGEMENT 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara yasu@jaist.ac.jp / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming

More information

損保ジャパンの現状2011

損保ジャパンの現状2011 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 62 63 64 65 66 67 68 69

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

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for embedded systems that use microcontrollers (MCUs)

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

1 2 3 4 5 6 X Y ABC A ABC B 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 13 18 30 P331 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ( ) 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

More information

26 2 3 4 5 8 9 6 7 2 3 4 5 2 6 7 3 8 9 3 0 4 2 4 3 4 4 5 6 5 7 6 2 2 A B C ABC 8 9 6 3 3 4 4 20 2 6 2 2 3 3 4 4 5 5 22 6 6 7 7 23 6 2 2 3 3 4 4 24 2 2 3 3 4 4 25 6 2 2 3 3 4 4 26 2 2 3 3 27 6 4 4 5 5

More information

mogiJugyo_slide_full.dvi

mogiJugyo_slide_full.dvi a 2 + b 2 = c 2 (a, b, c) a 2 a 2 = a a a 1/ 78 2/ 78 3/ 78 4/ 78 180 5/ 78 http://www.kaijo.ed.jp/ 6/ 78 a, b, c ABC C a b B c A C 90 a 2 + b 2 = c 2 7/ 78 C a b a 2 +b 2 = c 2 B c A a 2 a a 2 = a a 8/

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

(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

Functional Programming

Functional Programming PROGRAMMING IN HASKELL プログラミング Haskell Chapter 10 - Declaring Types and Classes 型とクラスの定義 愛知県立大学情報科学部計算機言語論 ( 山本晋一郎 大久保弘崇 2011 年 ) 講義資料オリジナルは http://www.cs.nott.ac.uk/~gmh/book.html を参照のこと 0 型宣言 (Type Declarations)

More information

Clipboard

Clipboard OCaml はじめの一歩 First Step to OCaml 小笠原啓 ( 有 )IT プランニング デモンストレーション DownDown(graphicsモジュールを使った簡単なプログラム ) Amthing(2Dベクトル描画ライブラリCairoを呼び出しています ) Unison(lablgtkを使っています ) ChartNaviPrime( サーバーサイドで OCaml 製 CGI やデーモンが

More information