2
나는 내 AST를 가져 와서 OCaml AST를 출력하는 컴파일러를 작성하고있다. 때 컴파일 :손으로 작성한 언 바운드 값 OCaml AST
(List.length '(1 2 3))
List.length [1; 2; 3]
에 나는 다음과 같은 출력 AST 얻을 : 검사시
[
structure_item (_none_[1,0+-1]..[1,0+-1]) ghost
Pstr_eval
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_apply
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_ident "List.length" (_none_[1,0+-1]..[1,0+-1]) ghost
[
<label> ""
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_construct "::" (_none_[1,0+-1]..[1,0+-1]) ghost
Some
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_tuple
[
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_constant Const_int 1
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_construct "::" (_none_[1,0+-1]..[1,0+-1]) ghost
Some
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_tuple
[
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_constant Const_int 2
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_construct "::" (_none_[1,0+-1]..[1,0+-1]) ghost
Some
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_tuple
[
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_constant Const_int 3
expression (_none_[1,0+-1]..[1,0+-1]) ghost
Pexp_construct "[]" (_none_[1,0+-1]..[1,0+-1]) ghost
None
]
]
]
]
]
, 이것은 위의 OCaml의 프로그램에 대한 ocamlc -dparsetree
의 출력과 거의 동일한 것을, 성공적으로 컴파일됩니다.
대신, 내 프로그램은 다음과 같은 오류와 함께 컴파일되지 않습니다 :
Error: Unbound value List.length
을 내가 잘못 뭐하는 거지?
당신은 완전히 옳습니다. 내가 한번 볼게. – tekknolagi
출력 위치 관련 - 불행히도 AST에서 지원하지 않습니다. 아직. – tekknolagi
나는 그것을 빨리 할 것을 권고한다. 디버깅 유형 오류는 그렇지 않으면 악몽이 될 것입니다. : p – Drup