Beispiel #1
0
        public Node FunDef()
        {
            var node = new FunctionDefinition()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            Expect(TokenCategory.OPENEDPAR);
            if (CurrentToken != TokenCategory.CLOSEDPAR)
            {
                node.Add(VarList());
            }
            Expect(TokenCategory.CLOSEDPAR);
            Expect(TokenCategory.OPENEDCURLY);
            while (CurrentToken == TokenCategory.VAR)
            {
                node.Add(VarDef());
            }
            if (firstOfStmt.Contains(CurrentToken))
            {
                node.Add(StmtList());
            }
            Expect(TokenCategory.CLOSEDCURLY);
            return(node);
        }
        public Node FuncDef()
        {
            var functionDefinition = new FunctionDefinition()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            Expect(TokenCategory.OPEN_PARENTHESIS);
            functionDefinition.Add(ParamList());
            Expect(TokenCategory.CLOSE_PARENTHESIS);
            Expect(TokenCategory.OPEN_BRACKET);
            functionDefinition.Add(VarDefList());
            functionDefinition.Add(StmtList());
            Expect(TokenCategory.CLOSE_BRACKET);
            return(functionDefinition);
        }
Beispiel #3
0
        public Node FunDef()
        {
            var funDef = new FunctionDefinition()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            Expect(TokenCategory.PARENTHESIS_OPEN);
            funDef.Add(ParamList());
            Expect(TokenCategory.PARENTHESIS_CLOSE);

            Expect(TokenCategory.BRACKETS_OPEN);
            funDef.Add(VarDefList());
            funDef.Add(StmtList());
            Expect(TokenCategory.BRACKETS_CLOSE);

            return(funDef);
        }
Beispiel #4
0
        public Node FunctionDefinition()
        {
            var fundef = new FunctionDefinition();

            fundef.AnchorToken = Expect(TokenType.IDENTIFIER);
            Expect(TokenType.PARENTHESIS_OPEN);
            if (CurrentToken != TokenType.PARENTHESIS_CLOSE)
            {
                fundef.Add(ParameterList());
            }
            Expect(TokenType.PARENTHESIS_CLOSE);
            Expect(TokenType.BLOCK_BEGIN);
            while (CurrentToken == TokenType.VAR)
            {
                fundef.Add(VariableDefinition());
            }
            while (firstOfStatement.Contains(CurrentToken))
            {
                fundef.Add(Statement());
            }
            return(fundef);
        }