[Omake] scanning of .mly files

Jason Hickey jyh at cs.caltech.edu
Mon Jun 12 12:45:41 PDT 2006


Benjamin Pierce wrote:
 > Yes.  A good readable way of displaying all the dependencies that  *do*
 > exist, and why, would go a long way in the right direction, though.

This has been committed to subversion on the 0.9.8.x branch.

--all-dependencies
     If either of the options --print-dependencies or 
--show-dependencies is in effect, print transitive dependencies. That 
is, print all dependencies recursively. If neither option 
--print-dependencies, --show-dependencies is specified, this option has 
no effect.

--verbose-dependencies
     If either of the options --print-dependencies or 
--show-dependencies is in effect, also print listings for each 
dependency. The output is very verbose, consider redirecting to a file. 
If neither option --print-dependencies, --show-dependencies is 
specified, this option has no effect.

> I guess the fly in the ointment here is that "foo.ml" may *not* be in  
> the project because it is to be generated automatically (and gets  
> tidied away by "make clean").

By "in the project" I mean $(target-exists ...) -- the file exists or 
can be built.

> I'd prefer something more eager/aggressive: I wish we could interpret
> 
>        .PREBUILD: %.ml: %.mly
> 
> as "If foo.mly [n.b.] is in the project, then generate foo.ml before  
> scanning other things."
> 
> But I worry that both of these approaches may lead to difficulties,  
> since it is not very clear exactly what "before scanning" means.   E.g., 
> in the case of Harmony, the file parser.mly is itself generated  from 
> yet another file, parser.srcy, using a little OCaml program that  must, 
> in turn, get built before it can be used...

I see what you mean:(  We have a case like this in omake; the .mly is 
generated.  Here is what we do, though I would not claim this is a great 
solution.  It does work, but more thought needs to be devoted to this 
general issue.

#
# The yacc parser file is generated.
# The omake_gen_parse command produces the omake_ast_parse.mly file.
#
GENPARSE = omake_gen_parse

OCamlProgram($(GENPARSE), $(GENPARSE))

# Do _not_ use a scanner for omake_gen_parse
.SCANNER: scan-ocaml-omake_gen_parse.ml:

# Explicitly target the generator now,
# so we don't pick up the LocalOCamlGeneratedFiles(...) below.
$(GENPARSE)$(EXE):

#
# All generated files
#
GENERATED_FILES[] =
     omake_ast_lex.ml
     omake_ast_parse.mly
     omake_ast_parse.mli
     omake_ast_parse.ml

#
# Use the local, scoped version to specify the generated files.
#
LocalOCamlGeneratedFiles($(GENERATED_FILES))

omake_ast_parse.mly: $(GENPARSE)$(EXE) omake_ast_parse.input
     ./$(GENPARSE) -o $@ omake_ast_parse.input

Jason

-- 
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257


More information about the Omake mailing list