コード例 #1
0
ファイル: Parser.cs プロジェクト: karloconk/Compiladores
        //<stmt-list>//
        public Node StmtList()
        {
            var stmtList = new StmtList();

            while (firstOfStatement.Contains(CurrentToken))
            {
                switch (CurrentToken)
                {
                case TokenCategory.IDENTIFIER:
                    stmtList.Add(stmtId());
                    break;

                case TokenCategory.IF:
                    stmtList.Add(If());
                    break;

                case TokenCategory.LOOP:
                    var LooperLupe = new Loop()
                    {
                        AnchorToken = Expect(TokenCategory.LOOP)
                    };
                    Expect(TokenCategory.CURLY_BRACKET_OPEN);
                    LooperLupe.Add(StmtList());
                    stmtList.Add(LooperLupe);
                    Expect(TokenCategory.CURLY_BRACKET_CLOSE);
                    break;

                case TokenCategory.BREAK:

                    stmtList.Add(new Break()
                    {
                        AnchorToken = Expect(TokenCategory.BREAK)
                    });

                    Expect(TokenCategory.SEMICOLON);
                    break;

                case TokenCategory.RETURN:
                    var myreturn = new Return()
                    {
                        AnchorToken = Expect(TokenCategory.RETURN)
                    };
                    myreturn.Add(Expression());
                    stmtList.Add(myreturn);
                    Expect(TokenCategory.SEMICOLON);
                    break;

                case TokenCategory.SEMICOLON:
                    Expect(TokenCategory.SEMICOLON);
                    break;

                default:
                    throw new SyntaxError(firstOfStatement,
                                          tokenStream.Current);
                }
            }
            return(stmtList);
        }
コード例 #2
0
        /****************************************************************
         *                       Subroutine Node
         ***************************************************************/

        public Node Subroutine()
        {
            var subroutToken = Expect(TokenCategory.SUBROUTINE);
            var subroutName  = new Identifier()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            Expect(TokenCategory.PARENTHESIS_OPEN);
            var args = new ArgumentList();

            if (CurrentToken != TokenCategory.PARENTHESIS_CLOSE)
            {
                args.Add(new Identifier()
                {
                    AnchorToken = Expect(TokenCategory.IDENTIFIER)
                });

                while (CurrentToken == TokenCategory.COMMA)
                {
                    Expect(TokenCategory.COMMA);
                    args.Add(new Identifier()
                    {
                        AnchorToken = Expect(TokenCategory.IDENTIFIER)
                    });
                }
            }
            Expect(TokenCategory.PARENTHESIS_CLOSE);

            var declList = EvaluateDeclarations();
            var stmtList = EvaluateStatements();

            var ret = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            if (this.labelCache != null)
            {
                ret.Add(this.labelCache);
                this.labelCache = null;
            }

            var end = new End()
            {
                AnchorToken = Expect(TokenCategory.END)
            };

            var subroutResult = new Subroutine()
            {
                subroutName, args, declList, stmtList, ret, end
            };

            subroutResult.AnchorToken = subroutToken;
            return(subroutResult);
        }
コード例 #3
0
        public Node StmtReturn()
        {
            var statementReturn = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            statementReturn.Add(Expr());
            Expect(TokenCategory.SEMICOLON);
            return(statementReturn);
        }
コード例 #4
0
        public Node Return()
        {
            var node = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            node.Add(Expr());
            Expect(TokenCategory.SEMICOLON);
            return(node);
        }
コード例 #5
0
ファイル: Parser.cs プロジェクト: danielsada/deep-lingo
        public Node Return()
        {
            var n1 = new Return()
            {
                AnchorToken = Expect(TokenType.RETURN)
            };

            n1.Add(Expression());
            Expect(TokenType.INSTRUCTION_END);
            return(n1);
        }
コード例 #6
0
        public Node StmtReturn()
        {
            var returnStatement = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            returnStatement.Add(Expr());
            Expect(TokenCategory.SEMICOLON);
            return(returnStatement);
        }
コード例 #7
0
        public Node StatementReturn()
        {
            var n1 = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };
            var result = Expression();

            n1.Add(result);
            Expect(TokenCategory.SEMICOL);
            return(n1);
        }
コード例 #8
0
ファイル: Parser.cs プロジェクト: k3ll3x/chimera-compiler
        public Node Return()
        {
            var result = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            if (firstOfSimpleExpression.Contains(CurrentToken))
            {
                result.Add(Expression());
            }
            Expect(TokenCategory.SEMICOL);
            return(result);
        }
コード例 #9
0
ファイル: Parser.cs プロジェクト: BetoVas97/chimera
        public Node Return()
        {
            var result = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            if (CurrentToken != TokenCategory.SEMICOLON)
            {
                result.Add(Expression());
            }

            Expect(TokenCategory.SEMICOLON);
            return(result);
        }
コード例 #10
0
        public override void SetReturnValue(GDBMIParser.GDBMIResponse resp)
        {
            foreach (GDBMIParser.GDBMIStreamRecord sr in resp.stream)
            {
                if (sr.type != GDBMIParser.GDBMIStreamRecord.GDBMIStreamRecordType.console)
                {
                    continue;
                }

                Match match = regexDecl.Match(sr.str);
                if (match.Success)
                {
                    ThreadInfo ti = new ThreadInfo();
                    ti.raw = match.Groups[0].Value;
                    ti.pid = match.Groups[1].Value;
                    ti.tid = match.Groups[2].Value;
                    Return.Add(ti);
                }
            }
        }
コード例 #11
0
        /****************************************************************
         *                         Function Node
         ***************************************************************/

        public Node Function()
        {
            var funcType = new FunctionType()
            {
                AnchorToken = Type()
            };
            var funcToken = Expect(TokenCategory.FUNCTION);

            var funcId = new Identifier()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            var args = new ArgumentList();

            Expect(TokenCategory.PARENTHESIS_OPEN);

            if (CurrentToken != TokenCategory.PARENTHESIS_CLOSE)
            {
                args.Add(new Identifier()
                {
                    AnchorToken = Expect(TokenCategory.IDENTIFIER)
                });

                while (CurrentToken == TokenCategory.COMMA)
                {
                    Expect(TokenCategory.COMMA);
                    args.Add(new Identifier()
                    {
                        AnchorToken = Expect(TokenCategory.IDENTIFIER)
                    });
                }
            }
            Expect(TokenCategory.PARENTHESIS_CLOSE);

            var declList = EvaluateDeclarations();
            var stmtList = EvaluateStatements();

            var ret = new Return()
            {
                AnchorToken = Expect(TokenCategory.RETURN)
            };

            if (this.labelCache != null)
            {
                ret.Add(this.labelCache);
                this.labelCache = null;
            }

            var end = new End()
            {
                AnchorToken = Expect(TokenCategory.END)
            };

            var funcResult = new Function()
            {
                funcType, funcId, args, declList, stmtList, ret, end
            };

            funcResult.AnchorToken = funcToken;
            return(funcResult);
        }