Exemplo n.º 1
0
        public Node Proc()
        {
            var result = new ProcDeclaration()
            {
                AnchorToken = Expect(TokenCategory.PROC)
            };

            result.Add(new Identifier()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            });
            Expect(TokenCategory.PARENTHESIS_OPEN);
            var param = new ProcParam();

            while (CurrentToken == TokenCategory.IDENTIFIER)
            {
                param.Add(ParamDeclaration());
            }
            Expect(TokenCategory.PARENTHESIS_CLOSE);
            result.Add(param);
            var type = new ProcType();

            if (CurrentToken == TokenCategory.TWOPOINTS)
            {
                Expect(TokenCategory.TWOPOINTS);
                type.Add(ChimeraType());
            }
            result.Add(type);
            var con = new ProcConst();

            Expect(TokenCategory.SEMICOL);
            if (CurrentToken == TokenCategory.CONST)
            {
                con.Add(Const());
            }
            result.Add(con);
            var va = new ProcVar();

            if (CurrentToken == TokenCategory.VAR)
            {
                va.Add(Var());
            }
            result.Add(va);
            var procStatement = new ProcStatement()
            {
                AnchorToken = Expect(TokenCategory.BEGIN)
            };

            while (firstOfStatement.Contains(CurrentToken))
            {
                procStatement.Add(Statement());
            }
            Expect(TokenCategory.END);
            Expect(TokenCategory.SEMICOL);
            result.Add(procStatement);
            return(result);
        }
Exemplo n.º 2
0
 public Type Visit(ProcVar node)
 {
     VisitChildren(node);
     return(Type.VOID);
 }
Exemplo n.º 3
0
 public string Visit(ProcVar node)
 {
     return(VisitChildren(node));
 }