コード例 #1
0
ファイル: DPCOperation.cs プロジェクト: Piirtaa/Decoratid
        public static List <DPCOperation> TokenizeToDPCOperations(this string text)
        {
            var rv = new List <DPCOperation>();

            var tokens = text.Tokenize(null, new ToDotParser());

            DPCOperation currentOperation = null;

            for (int i = 0; i < tokens.Count; i++)
            {
                var each = tokens[i];

                if (!(each is IDPCToken))
                {
                    continue;
                }

                DPCDecoration eachToken = each as DPCDecoration;
                if (eachToken.TokenType == DPCTokenType.Operation)
                {
                    //create a new operation
                    currentOperation = new DPCOperation();
                    currentOperation.OperationToken = eachToken;
                    rv.Add(currentOperation); //add a ref upon creation
                }
                else if (eachToken.TokenType == DPCTokenType.Item)
                {
                    currentOperation.ArgTokens.Add(eachToken);
                }
            }

            return(rv);
        }
コード例 #2
0
ファイル: DPCOperation.cs プロジェクト: Piirtaa/Decoratid
        public static List<DPCOperation> TokenizeToDPCOperations(this string text)
        {
            var rv = new List<DPCOperation>();

            var tokens = text.Tokenize(null, new ToDotParser());

            DPCOperation currentOperation = null;
                    
            for (int i = 0; i < tokens.Count; i++)
            {
                var each = tokens[i];

                if (!(each is IDPCToken))
                    continue;

                DPCDecoration eachToken = each as DPCDecoration;
                if (eachToken.TokenType == DPCTokenType.Operation)
                {
                    //create a new operation
                    currentOperation = new DPCOperation();
                    currentOperation.OperationToken = eachToken;
                    rv.Add(currentOperation); //add a ref upon creation
                }
                else if (eachToken.TokenType == DPCTokenType.Item)
                {
                    currentOperation.ArgTokens.Add(eachToken);
                }
            }

            return rv;
        }