예제 #1
0
 public void Visit(IridioSyntax boundScript)
 {
     boundScript.Procedures.ForEach(function =>
     {
         function.Accept(this);
     });
 }
예제 #2
0
파일: Binder.cs 프로젝트: SuperJMN/Iridio
        public Either <Errors, Script> Bind(IridioSyntax syntax)
        {
            procedures.Clear();
            initializedVariables.Clear();
            errors.Clear();

            var procs           = syntax.Procedures.Select(Bind);
            var boundProcedures = procs.ToList();
            var main            = boundProcedures.FirstOrNone(b => b.Name == "Main");

            main.MatchNone(() => errors.Add(new Error(ErrorKind.UndefinedMainFunction, "Main procedure is undefined")));

            if (errors.Any())
            {
                return(Either.Error <Errors, Script>(new Errors(errors)));
            }

            var script = new Script(boundProcedures, main.ValueOrFailure());

            return(Either.Success <Errors, Script>(script));
        }