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 3 4 5 6 7 Emacs 8 2 1. 2. 3. 4. 5. ML let start ::= exp (1) exp ::= (2) fn id exp (3) ::= (4) (5) ::= id (6) const (7) (exp) (8) let val id = exp in exp end (9) 2 r6, r7 (1) (3) (5) (6) (7) (8) (9) (2) (4) let val x = 1 in let val y = fn x => fn y => x y in let val z = fn x => x in y x y y ( end let x, y, z x : int y : α, β. (α β) α β z : α. α α
y y z 2 x y z 2 3 EOF let, id, val, in, end, =,, fn, (, ), const, EOF id const id x const 2 EOF id id EOF id cursor 1 let id id EOF EOF id 1 let val x = 2 in x let, val, id x, =, exp, in, 1 1 cursor id cursor
id const fn ( ) let val = in end EOF 0 s15 r6 s16 r7 s6 s1 s7 1 s15 r6 s16 r7 s6 s1 s7 2 s15 r6 s16 r7 s6 s1 s7 3 s15 r6 s16 r7 s6 s1 s7 4 s15 r6 s16 r7 s6 s1 s7 5 s15 r6 s16 r7 r2 r2 s1 r2 s7 r2 r2 r2 r2 r2 6 s9 7 s11 8 acc 9 s2 10 s20 r8 11 s12 12 s3 13 s4 14 s22 r9 15 r6 r6 r6 r6 r6 r6 r6 r6 r6 r6 r6 r6 16 r7 r7 r7 r7 r7 r7 r7 r7 r7 r7 r7 r7 17 r1 r1 r1 r1 r1 r1 r1 r1 r1 r1 r1 r1 18 r4 r4 r4 r4 r4 r4 r4 r4 r4 r4 r4 r4 19 r5 r5 r5 r5 r5 r5 r5 r5 r5 r5 r5 r5 20 r8 r8 r8 r8 r8 r8 r8 r8 r8 r8 r8 r8 21 r3 r3 r3 r3 r3 r3 r3 r3 r3 r3 r3 r3 22 r9 r9 r9 r9 r9 r9 r9 r9 r9 r9 r9 r9 start exp 0 g8 g17 r1 g5 g18 r4 1 g8 g10 g5 g18 r4 2 g8 g21 r3 g5 g18 r4 3 g8 g13 g5 g18 r4 4 g8 g14 g5 g18 r4 5 r2 r2 r2 g19 r5 6 7 8 9 10 11 12 13 14 15 r6 r6 r6 r6 16 r7 r7 r7 r7 17 r1 r1 r1 r1 18 r4 r4 r4 r4 19 r5 r5 r5 r5 20 r8 r8 r8 r8 21 r3 r3 r3 r3 22 r9 r9 r9 r9 1.
let val id x = exp in id cursor const 2 id x 1. 4 [ ] ( ) id start ::= exp exp ::= fn id exp [ ] ::= ::= id const (exp) let val id = exp in exp end [ ] start,, id id 2 ::= (1) (9) start A ( ɛ ) α s s 1,..., s n (1) s 1 start s 1 start s 1 A α α s 1 α = α 1 s 1 α 2 α 1 α 1 = s i... s 2 α 2 As i+1... s n (2) (1)
let val id x = exp in exp const 2 id cursor id x 2. 1 2 3 2 5 2,5 2 ( 1) 2 5 3 5 2 ( 2) let, val, id x, =, exp, in, exp 5 ( 3) let, val, id x, =, exp, in, 3 5 5 2 exp exp 1 3 8 9 9 9 exp 2 exp exp end ( 2) 9 let 4 5 5 4 4 2 5 5 2 exp exp exp 1 4 start
let val id x = exp in [ ] const 2 id cursor id x 3. 1 5 start exp exp exp const 2 id cursor id x 4.
2 5 5 let val f = fn x => + x 1 in f (f + int int int ) end [ ]( ) ) end 5 4 e ::= x c cursor e e λx. e let x = e in e [ ] x c e λ, let Milner W [7] 5 U Cls Γ τ τ Γ σ := α 1... α n.τ τ := int α τ τ σ τ int τ := int α (τ τ) subst (S, τ) = τ := int (τ int ) τ := S(τ) (τ α ) subst(s, τ 1 ); subst(s, τ 2 ) (τ τ 1 τ 2 )
C(Γ, e) = cursortype := nil; cursorenv := Γ; C (Γ, e); return (cursortype, cursorenv) C (Γ, cursor) = cursortype := β; (β fresh) cursorenv := Γ; return cursortype C (Γ, x) = Γ(x) = α 1... α n.τ 1 return [β 1 /α 1 ]... [β n /α n ]τ 1 (β 1,..., β n fresh) Γ(x) = τ 1 return τ 1 C (Γ, c) = return int C (Γ, e 1 e 2 ) = τ 1 = C (Γ, e 1 ); τ 2 = C (Γ, e 2 ); S = U(τ 1, (τ 2 β)); (β fresh) subst(s, τ 1 ); subst(s, τ 2 ); return S(β) C (Γ, λx.e) = τ 1 = C (Γ{x : β}, e); (β fresh) return ( β τ 1 ) C (Γ, let x = e 1 in e 2 ) = τ 1 = C (Γ, e 1 ); σ = Cls(Γ, τ 1 ); return C (Γ{x : σ}, e 2 ) C (Γ, [ ]) = return β (β fresh) 5. C 6 5 C τ 1 β 1... β n. τ 2 τ 1 τ 2 = [α 1/β 1 ] [α n /β n ]τ 2 (α 1,..., α n fresh) U (τ 1, τ 2 ) let val ya = fn x => x in let val xb = fn x => x in let val xc = 1 in (fn x => x 1) x end 3 ya, xb, xc cursor : int α ya : γ. γ γ xb : γ. γ γ xc : int 3 ya xb xc xc ya xb x xb
7 Emacs[2] Emacs lambdamode lambda-mode web (http://www.cs.ise.shibaura-it.ac. jp/complement/) 6 lambda-mode 1. 2. 3. 2 3 auto-complete.el [1] Emacs auto-complete.el 1 6 Emacs 6. auto-complete auto-complete lambda-mode auto-complete id const 0 0 9 int +, -, /, * Emacs Lisp yacc kmyacc[4] EOF 3 4 2 2 2 (1) start acc (2) s 1 start s 1
(3) s 1 s 2 s 1 s 2 (4) (2) s 2 (4-a) s 1 s 2 (2) (5) (2) s 2 (5-a) 1 s 1 1 s 1 = 2 5 2 s 2 2 5 5 2 (1) 1 s 1 2 s 2 (2) 1 s 1 2 s 2 acc (3) 1 s 1 2 s 2 s 1 s 1 (3-a) (4) (1) auto-complete.el Emacs lisp max-lisp-eval-depth maxspecpdl-size 400, 1000 lambda-mode lambda-mode 7 lambda-mode Emacs 15 6 63 OS Windows XP Professional SP3 CPU Intel Core 2 Duo E7300 2.6GHz 3.25GByte Emacs Meadow(GNU Emacs 22.2.1)
7. lambda-mode
2 id const fn ( ) let val = in end start acc acc acc acc acc acc acc acc acc acc acc acc exp 1 1 1 1 3 8 1 1 1 9 9 1 5,2 5,2 5,2 5,2 5,2 5,2 5,2 5,2 5,2 5,2 5,2 5,2 fn 3 3 3 3 3 3 3 3 3 3 3 3 id 6 6 6 3 6 6 6 6 9 6 6 6 const 7 7 7 7 7 7 7 7 7 7 7 7 1 3 ( 8 8 8 8 8 8 8 8 8 8 8 8 ) let 9 9 9 9 9 9 9 9 9 9 9 9 val 9 = 9 in end 2 exp start acc acc acc exp 1 1 1 5,2 5,2 5,2 5 fn 3 3 3 id 6 6 6 const 7 7 7 1 ( 8 8 8 ) 8 let 9 9 9 val = in 9 end 9 2.
8 let Aditya [6] Haskell ML annotation [1] EmacsWiki: Auto complete. http://www.emacswiki.org/emacs/autocomplete. [2] GNU Emacs. http://www.gnu.org/software/emacs/. [3] Java development environment for Emacs. http://jdee.sourceforge.net/. [4] kmyacc. http://www005.upp.so-net.ne.jp/kmori/kmyacc/. [5] Shail Aditya and Rishiyur S. Nikhil. Incremental polymorphism. In Proceedings of the 5th ACM Conference on Functional Programming Languages and Computer Architecture, pages 379 405, Cambridge, USA, August 1991. [6] Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348 375, 1978.