Ejemplo n.º 1
0
        public FuncDeclaration(Terminal returnType, Id name, ParamDeclaration[] parameters, Block body)
        {
            ReturnType = returnType;
            Params = parameters;
            Body = body;
            Name = name;

            AddAttribute(new TypeAttr(returnType));
            AddAttribute(new IdAttr(name));
            AddAttribute(parameters);
            AddChild(body);
        }
Ejemplo n.º 2
0
        private FuncParam[] ProcessFuncParams(ParamDeclaration[] paramDeclarations)
        {
            var pars = new FuncParam[paramDeclarations.Length];

            for (int i = 0; i < paramDeclarations.Length; i++)
            {
                var type = GetType(paramDeclarations[i].Type, paramDeclarations[i].IsArray);
                pars[i] = new FuncParam(paramDeclarations[i].NewValue, type, i);
            }

            return pars;
        }
Ejemplo n.º 3
0
 private FuncDeclaration FunDecl()
 {
     var rType = Type();
     var name = Expect(Terminals.Id) as Id;
     var parameters = new ParamDeclaration[0];
     Expect(Terminals.LPar);
     if (_la == Terminals.Int || _la == Terminals.Char)
     {
         parameters = ParamDecl();
     }
     Expect(Terminals.RPar);
     var body = Block();
     return new FuncDeclaration(rType, name, parameters, body);
 }