/// <summary> /// Evaluates the expression when formatting a message. /// </summary> /// <param name="field"> /// It's the field to format. /// </param> /// <param name="formatterContext"> /// It's the context of formatting to be used by the method. /// </param> /// <returns> /// A boolean value. /// </returns> public override bool EvaluateFormat(Field field, ref FormatterContext formatterContext) { return(GetSubstring(MessageExpression.GetLeafFieldValueString(ref formatterContext, null)) == _valueExpression.Constant); }
/// <summary> /// Evaluates the expression when parsing a message. /// </summary> /// <param name="parserContext"> /// It's the parser context. /// </param> /// <returns> /// A boolean value. /// </returns> public override bool EvaluateParse(ref ParserContext parserContext) { return(GetSubstring(MessageExpression.GetLeafFieldValueString(ref parserContext, null)) == _valueExpression.Constant); }
/// <summary> /// Evaluates the expression when parsing a message. /// </summary> /// <param name="parserContext"> /// It's the parser context. /// </param> /// <returns> /// A boolean value. /// </returns> public override bool EvaluateParse(ref ParserContext parserContext) { return(CompareByteArrays(GetSet(MessageExpression.GetLeafFieldValueBytes( ref parserContext, null)), _valueExpression.GetValue())); }
/// <summary> /// Evaluates the expression when formatting a message. /// </summary> /// <param name="field"> /// It's the field to format. /// </param> /// <param name="formatterContext"> /// It's the context of formatting to be used by the method. /// </param> /// <returns> /// A boolean value. /// </returns> public override bool EvaluateFormat(Field field, ref FormatterContext formatterContext) { return(CompareByteArrays(GetSet(MessageExpression.GetLeafFieldValueBytes( ref formatterContext, null)), _valueExpression.GetValue())); }
/** the generated parser. * Maintains a state and a value stack, currently with fixed maximum size. * @param yyLex scanner. * @return result of the last reduction, if any. * @throws ExpressionCompileException on irrecoverable parse error. */ public Object yyparse(yyInput yyLex) { if (yyMax <= 0) { yyMax = 256; // initial size } int yyState = 0; // state stack ptr int [] yyStates = new int[yyMax]; // state stack Object yyVal = null; // value stack ptr Object [] yyVals = new Object[yyMax]; // value stack int yyToken = -1; // current input int yyErrorFlag = 0; // #tks to shift int yyTop = 0; goto skip; yyLoop: yyTop++; skip: for (;; ++yyTop) { if (yyTop >= yyStates.Length) // dynamically increase { int[] i = new int[yyStates.Length + yyMax]; System.Array.Copy(yyStates, i, 0); yyStates = i; Object[] o = new Object[yyVals.Length + yyMax]; System.Array.Copy(yyVals, o, 0); yyVals = o; } yyStates[yyTop] = yyState; yyVals[yyTop] = yyVal; if (debug != null) { debug.push(yyState, yyVal); } yyDiscarded : for (;;) // discarding a token does not change stack { int yyN; if ((yyN = yyDefRed[yyState]) == 0) // else [default] reduce (yyN) { if (yyToken < 0) { yyToken = yyLex.advance() ? yyLex.token() : 0; if (debug != null) { debug.lex(yyState, yyToken, GetTokenName(yyToken), yyLex.value()); } } if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0) && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) { if (debug != null) { debug.shift(yyState, yyTable[yyN], yyErrorFlag - 1); } yyState = yyTable[yyN]; // shift to yyN yyVal = yyLex.value(); yyToken = -1; if (yyErrorFlag > 0) { --yyErrorFlag; } goto yyLoop; } if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0 && yyN < yyTable.Length && yyCheck[yyN] == yyToken) { yyN = yyTable[yyN]; // reduce (yyN) } else { switch (yyErrorFlag) { case 0: yyerror("syntax error", yyExpecting(yyState)); if (debug != null) { debug.error("syntax error"); } goto case 1; case 1: case 2: yyErrorFlag = 3; do { if ((yyN = yySindex[yyStates[yyTop]]) != 0 && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length && yyCheck[yyN] == Token.yyErrorCode) { if (debug != null) { debug.shift(yyStates[yyTop], yyTable[yyN], 3); } yyState = yyTable[yyN]; yyVal = yyLex.value(); goto yyLoop; } if (debug != null) { debug.pop(yyStates[yyTop]); } } while (--yyTop >= 0); if (debug != null) { debug.reject(); } try { yyVal = yyLex.value(); } catch { throw new ExpressionCompileException("Syntax error.", yyLex.LastParsedTokenIndex); } throw new ExpressionCompileException(string.Format("Syntax error: {0}", yyVal), yyLex.LastParsedTokenIndex); case 3: if (yyToken == 0) { if (debug != null) { debug.reject(); } try { yyVal = yyLex.value(); } catch { throw new ExpressionCompileException("Syntax error at the end of the file.", yyLex.LastParsedTokenIndex); } throw new ExpressionCompileException(string.Format("Syntax error at the end of the file: {0}", yyVal), yyLex.LastParsedTokenIndex); } if (debug != null) { debug.discard(yyState, yyToken, GetTokenName(yyToken), yyLex.value()); } yyToken = -1; goto yyDiscarded; // leave stack alone } } } int yyV = yyTop + 1 - yyLen[yyN]; if (debug != null) { debug.reduce(yyState, yyStates[yyV - 1], yyN, yyRule[yyN], yyLen[yyN]); } yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { case 1: #line 41 "Expressions.jay" { yyVal = new ConditionalOrOperator(yyVals[-2 + yyTop] as IBooleanExpression, yyVals[0 + yyTop] as IBooleanExpression); } break; case 2: #line 45 "Expressions.jay" { yyVal = new ConditionalAndOperator(yyVals[-2 + yyTop] as IBooleanExpression, yyVals[0 + yyTop] as IBooleanExpression); } break; case 3: #line 49 "Expressions.jay" { yyVal = new NegationOperator(yyVals[0 + yyTop] as IBooleanExpression); } break; case 5: #line 57 "Expressions.jay" { yyVal = yyVals[-1 + yyTop]; } break; case 9: #line 71 "Expressions.jay" { yyVal = new FieldValueEqualsStringOperator(yyVals[-2 + yyTop] as IMessageExpression, yyVals[0 + yyTop] as StringConstantExpression); } break; case 10: #line 76 "Expressions.jay" { yyVal = new MidEqualsStringOperator(yyVals[-7 + yyTop] as IMessageExpression, yyVals[0 + yyTop] as StringConstantExpression, ( int )yyVals[-5 + yyTop], ( int )yyVals[-3 + yyTop]); } break; case 11: #line 81 "Expressions.jay" { yyVal = new FieldValueEqualsBinaryOperator(yyVals[-2 + yyTop] as IMessageExpression, yyVals[0 + yyTop] as BinaryConstantExpression); } break; case 12: #line 86 "Expressions.jay" { yyVal = new MidEqualsBinaryOperator(yyVals[-7 + yyTop] as IMessageExpression, yyVals[0 + yyTop] as BinaryConstantExpression, ( int )yyVals[-5 + yyTop], ( int )yyVals[-3 + yyTop]); } break; case 13: #line 91 "Expressions.jay" { yyVal = new MtiEqualsExpression(( int )yyVals[0 + yyTop], yyVals[-2 + yyTop] as IMessageExpression); } break; case 14: #line 99 "Expressions.jay" { yyVal = new MessageExpression(( int )yyVals[0 + yyTop]); } break; case 17: #line 109 "Expressions.jay" { yyVal = new MessageExpression(); } break; case 20: #line 118 "Expressions.jay" { yyVal = new SubMessageExpression(( int )yyVals[-2 + yyTop], new MessageExpression()); } break; case 21: #line 122 "Expressions.jay" { yyVal = new SubMessageExpression(( int )yyVals[-2 + yyTop], yyVals[0 + yyTop] as SubMessageExpression); } break; case 22: #line 129 "Expressions.jay" { yyVal = new ParentMessageExpression(new MessageExpression()); } break; case 23: #line 133 "Expressions.jay" { yyVal = new ParentMessageExpression(yyVals[0 + yyTop] as SubMessageExpression); } break; case 24: #line 137 "Expressions.jay" { yyVal = new ParentMessageExpression(yyVals[0 + yyTop] as ParentMessageExpression); } break; case 25: #line 145 "Expressions.jay" { yyVal = new IsSetExpression(new MessageExpression(( int )yyVals[-1 + yyTop])); } break; case 26: #line 149 "Expressions.jay" { yyVal = new IsSetExpression(yyVals[-1 + yyTop] as SubMessageExpression); } break; case 27: #line 153 "Expressions.jay" { yyVal = new IsSetExpression(yyVals[-1 + yyTop] as ParentMessageExpression); } break; case 28: #line 160 "Expressions.jay" { yyVal = new SubMessageExpression(( int )yyVals[-2 + yyTop], new MessageExpression(( int )yyVals[0 + yyTop])); } break; case 29: #line 164 "Expressions.jay" { yyVal = new SubMessageExpression(( int )yyVals[-2 + yyTop], yyVals[0 + yyTop] as SubMessageExpression); } break; case 30: #line 171 "Expressions.jay" { yyVal = new ParentMessageExpression(new MessageExpression(( int )yyVals[0 + yyTop])); } break; case 31: #line 175 "Expressions.jay" { yyVal = new ParentMessageExpression(yyVals[0 + yyTop] as SubMessageExpression); } break; case 32: #line 179 "Expressions.jay" { yyVal = new ParentMessageExpression(yyVals[0 + yyTop] as ParentMessageExpression); } break; #line 433 "-" } yyTop -= yyLen[yyN]; yyState = yyStates[yyTop]; int yyM = yyLhs[yyN]; if (yyState == 0 && yyM == 0) { if (debug != null) { debug.shift(0, yyFinal); } yyState = yyFinal; if (yyToken < 0) { yyToken = yyLex.advance() ? yyLex.token() : 0; if (debug != null) { debug.lex(yyState, yyToken, GetTokenName(yyToken), yyLex.value()); } } if (yyToken == 0) { if (debug != null) { debug.accept(yyVal); } return(yyVal); } goto yyLoop; } if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0) && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState)) { yyState = yyTable[yyN]; } else { yyState = yyDgoto[yyM]; } if (debug != null) { debug.shift(yyStates[yyTop], yyState); } goto yyLoop; } } }