我正在用OCamllex和Menhir编写一个Go Python编译器,但我的lexer未能导入核心包。
这是我的lex.mll文件:
{
(* Header *)
open Core.Std
open Lexing
open Parser
exception SyntaxError of string
let next_line lexbuf =
let pos = lexbuf.lex_curr_p in
lexbuf.lex_curr_p <-
{ pos with pos_bol = lexbuf.lex_curr_pos;
pos_lnum = pos.pos_lnum + 1
}
let syntaxError msg = raise (SyntaxError (msg ^ " on line " ^ (string_of_int next_line)))
(* End Header *)
}
[ lexer rules ]我有一个make,make.sh来将词法和解析器放在一起
#! /bin/bash
echo "==Creating compiler=="
echo "- OCamllex : lex.mll -> lex.ml"
ocamllex lex.mll
echo "- OCaml : lex.ml -> lex"
ocamlc lex.ml -o lex
# echo "- OCamlBuild -> main.ml"
# ocamlbuild -use-menhir main.native但是,当我运行./make.sh时,我会得到以下错误:
==Creating compiler==
- OCamllex : lex.mll -> lex.ml
1030 states, 16995 transitions, table size 74160 bytes
- OCaml : lex.ml -> lex
File "lex.mll", line 4, characters 7-15:
Error: Unbound module Core我可以通过编辑我的.ocamlinit文件在ocaml解释器中打开Core,但是如何在ocamlc编译的脚本中导入Core?
发布于 2016-02-26 00:12:36
删除脚本中的所有内容,只需使用
corebuild -use-menhir main.nativecorebuild将推断所有依赖项并编译它们,并完成所有的工作。
https://stackoverflow.com/questions/35639087
复制相似问题