Exemple #1
0
        private StmtRaw ParseForeach()   //例:循环每一个(子弹管理器的子弹群,ZD)
        {
            StmtForeachRaw foreachStmt = new StmtForeachRaw();

            foreachStmt.LoopToken = (LexTokenText)currLineTokenTape.Current;
            currLineTokenTape.MoveNext();
            foreachStmt.EachToken = (LexTokenText)currLineTokenTape.Current;
            currLineTokenTape.MoveNext();
            currLineTokenTape.Match(TokenKindSymbol.LBS);
            foreachStmt.ListExp = ParseRawExpLineComma();
            currLineTokenTape.Match(TokenKindSymbol.Comma);
            foreachStmt.ItemToken = (LexTokenText)currLineTokenTape.Current;
            currLineTokenTape.MoveNext();
            currLineTokenTape.Match(TokenKindSymbol.RBS);
            TapeMoveNext();
            foreachStmt.Body = ParseStmtBlockRaw(foreachStmt.LoopToken.Position.Col);
            return(foreachStmt);
        }
Exemple #2
0
        public SectionProcRaw Parse(IEnumerable <LexToken> tokens, ContextFile fileContext, SectionProcRaw procAST)
        {
            this.fileContext = fileContext;
            this.ast         = procAST;

            List <LexToken> tokens2 = new List <LexToken>(tokens);

            tape         = new TokenTape(tokens2.ToArray(), fileContext);
            ast.NamePart = ParseProcName();
            tape.Match(TokenKindSymbol.Colon);
            ast.RetToken = ParseRetProc();

            return(ast);
        }