comparison src/compiler.sml @ 834:74e9e7642f08

Do 'open constraints' automatically; fix sourceless <cselect> monoize bug; Monad library module
author Adam Chlipala <adamc@hcoop.net>
date Tue, 02 Jun 2009 11:50:53 -0400
parents 249740301a0a
children 19fdeef40ada
comparison
equal deleted inserted replaced
833:9a1026e2b3f5 834:74e9e7642f08
587 | capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE) 587 | capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
588 588
589 val parse = { 589 val parse = {
590 func = fn {database, sources = fnames, ffi, ...} : job => 590 func = fn {database, sources = fnames, ffi, ...} : job =>
591 let 591 let
592 val anyErrors = ref false
593 fun checkErrors () = anyErrors := (!anyErrors orelse ErrorMsg.anyErrors ())
592 fun nameOf fname = capitalize (OS.Path.file fname) 594 fun nameOf fname = capitalize (OS.Path.file fname)
593 595
594 fun parseFfi fname = 596 fun parseFfi fname =
595 let 597 let
596 val mname = nameOf fname 598 val mname = nameOf fname
600 first = ErrorMsg.dummyPos, 602 first = ErrorMsg.dummyPos,
601 last = ErrorMsg.dummyPos} 603 last = ErrorMsg.dummyPos}
602 604
603 val sgn = (Source.SgnConst (#func parseUrs urs), loc) 605 val sgn = (Source.SgnConst (#func parseUrs urs), loc)
604 in 606 in
607 checkErrors ();
605 (Source.DFfiStr (mname, sgn), loc) 608 (Source.DFfiStr (mname, sgn), loc)
606 end 609 end
607 610
608 fun parseOne fname = 611 fun parseOne fname =
609 let 612 let
615 if Posix.FileSys.access (urs, []) then 618 if Posix.FileSys.access (urs, []) then
616 SOME (Source.SgnConst (#func parseUrs urs), 619 SOME (Source.SgnConst (#func parseUrs urs),
617 {file = urs, 620 {file = urs,
618 first = ErrorMsg.dummyPos, 621 first = ErrorMsg.dummyPos,
619 last = ErrorMsg.dummyPos}) 622 last = ErrorMsg.dummyPos})
623 before checkErrors ()
620 else 624 else
621 NONE 625 NONE
622 626
623 val loc = {file = ur, 627 val loc = {file = ur,
624 first = ErrorMsg.dummyPos, 628 first = ErrorMsg.dummyPos,
625 last = ErrorMsg.dummyPos} 629 last = ErrorMsg.dummyPos}
626 630
627 val ds = #func parseUr ur 631 val ds = #func parseUr ur
628 in 632 in
633 checkErrors ();
629 (Source.DStr (mname, sgnO, (Source.StrConst ds, loc)), loc) 634 (Source.DStr (mname, sgnO, (Source.StrConst ds, loc)), loc)
630 end 635 end
631 636
632 val dsFfi = map parseFfi ffi 637 val dsFfi = map parseFfi ffi
633 val ds = map parseOne fnames 638 val ds = map parseOne fnames
634 in 639 in
640 if !anyErrors then
641 ErrorMsg.error "Parse failure"
642 else
643 ();
644
635 let 645 let
636 val final = nameOf (List.last fnames) 646 val final = nameOf (List.last fnames)
637 647
638 val ds = dsFfi @ ds 648 val ds = dsFfi @ ds
639 @ [(Source.DExport (Source.StrVar final, ErrorMsg.dummySpan), ErrorMsg.dummySpan)] 649 @ [(Source.DExport (Source.StrVar final, ErrorMsg.dummySpan), ErrorMsg.dummySpan)]