コード例 #1
0
        private void SetRecode(NonterminalToken pToken)
        {
            object fromValue  = null;
            object rangeEnd   = null;
            object equalValue = null;
            string recodeType = null;

            /*
             * <Recode> ::=      <Value> '-' <Value> '=' <Value>
             | <Value> '–' HIVALUE '=' <Value>
             | LOVALUE '-' <Value> '=' <Value>
             | <Value> '=' <Value>
             | ELSE '=' <Value>
             */
            switch (pToken.Tokens.Length)
            {
            /*
             * case 3:
             * fromValue = GetRecodeValue(pToken.Tokens[0]);
             * equalValue =  GetRecodeValue(pToken.Tokens[2]);
             * recodeType = ((TerminalToken)pToken.Tokens[1]).Text;
             *
             * RecodeRange recodeRange = new RecodeRange(recodeType, fromValue, rangeEnd, equalValue);
             * _recodeList.Ranges.Add(recodeRange);
             * break;
             *
             * default:
             * fromValue = GetRecodeValue(pToken.Tokens[0]);
             * rangeEnd = GetRecodeValue(pToken.Tokens[2]);
             * equalValue = GetRecodeValue(pToken.Tokens[4]);
             * recodeType = ((TerminalToken)pToken.Tokens[1]).Text;
             * _recodeList.Ranges.Add(new RecodeRange(recodeType, fromValue, rangeEnd, equalValue));
             * break;*/

            case 3:
                fromValue  = new Rule_Value(this.Context, pToken.Tokens[0]);
                equalValue = new Rule_Value(this.Context, pToken.Tokens[2]);
                recodeType = ((TerminalToken)pToken.Tokens[1]).Text;

                RecodeRange recodeRange = new RecodeRange(recodeType, fromValue, rangeEnd, equalValue);
                _recodeList.Ranges.Add(recodeRange);
                break;

            default:
                if (pToken.Tokens[0].ToString().Contains("-"))
                {
                    fromValue = new Rule_NegateExp(this.Context, (NonterminalToken)pToken.Tokens[0]);
                }
                else
                {
                    fromValue = new Rule_Value(this.Context, pToken.Tokens[0]);
                }

                if (pToken.Tokens[2].ToString().Contains("-"))
                {
                    rangeEnd = new Rule_NegateExp(this.Context, (NonterminalToken)pToken.Tokens[2]);
                }
                else
                {
                    rangeEnd = new Rule_Value(this.Context, pToken.Tokens[2]);
                }
                equalValue = new Rule_Value(this.Context, pToken.Tokens[4]);
                recodeType = ((TerminalToken)pToken.Tokens[1]).Text;
                _recodeList.Ranges.Add(new RecodeRange(recodeType, fromValue, rangeEnd, equalValue));
                break;
            }
        }
コード例 #2
0
ファイル: Rule_Recode.cs プロジェクト: NALSS/epiinfo-82474
        private void SetRecode(NonterminalToken pToken)
        {
            object fromValue = null;
            object rangeEnd = null;
            object equalValue = null;
            string recodeType = null;

            /*
            <Recode> ::=      <Value> '-' <Value> '=' <Value>
                | <Value> '–' HIVALUE '=' <Value>
                | LOVALUE '-' <Value> '=' <Value>
                | <Value> '=' <Value>
                | ELSE '=' <Value>
             */
            switch (pToken.Tokens.Length)
            {
                    /*
                case 3:
                    fromValue = GetRecodeValue(pToken.Tokens[0]);
                    equalValue =  GetRecodeValue(pToken.Tokens[2]);
                    recodeType = ((TerminalToken)pToken.Tokens[1]).Text;

                    RecodeRange recodeRange = new RecodeRange(recodeType, fromValue, rangeEnd, equalValue);
                    _recodeList.Ranges.Add(recodeRange);
                    break;

                default:
                    fromValue = GetRecodeValue(pToken.Tokens[0]);
                    rangeEnd = GetRecodeValue(pToken.Tokens[2]);
                    equalValue = GetRecodeValue(pToken.Tokens[4]);
                    recodeType = ((TerminalToken)pToken.Tokens[1]).Text;
                    _recodeList.Ranges.Add(new RecodeRange(recodeType, fromValue, rangeEnd, equalValue));
                    break;*/

                case 3:
                    fromValue = new Rule_Value(this.Context, pToken.Tokens[0]);
                    equalValue = new Rule_Value(this.Context, pToken.Tokens[2]);
                    recodeType = ((TerminalToken)pToken.Tokens[1]).Text;

                    RecodeRange recodeRange = new RecodeRange(recodeType, fromValue, rangeEnd, equalValue);
                    _recodeList.Ranges.Add(recodeRange);
                    break;

                default:
                    fromValue = new Rule_Value(this.Context, pToken.Tokens[0]);
                    rangeEnd = new Rule_Value(this.Context, pToken.Tokens[2]);
                    equalValue = new Rule_Value(this.Context, pToken.Tokens[4]);
                    recodeType = ((TerminalToken)pToken.Tokens[1]).Text;
                    _recodeList.Ranges.Add(new RecodeRange(recodeType, fromValue, rangeEnd, equalValue));
                    break;

            }
        }