public override bool Parse(SyntacticState state) { int innerIndex = state.InnerPosition; int outerIndex = state.OuterPosition; // non-assignment-expression is required if (!NonAssignmentExpression.S.Parse(state)) { return(false); } // if unary-expression has been captured // we should try to capture rest parts of assignment if (state.CheckEntry(UnaryExpression.S.Key, innerIndex)) { int inner = state.InnerPosition; int outer = state.OuterPosition; // the rest parts of assigment are assignment-operator if (AssignmentOperator.S.Parse(state)) { // and another expression (recursive call here) if (S.Parse(state)) { } else { state.Reset(inner, outer); } } } state.AddBack(Key, innerIndex, outerIndex); return(true); }
public override bool Parse(SyntacticState state) { int innerIndex = state.InnerPosition; int outerIndex = state.OuterPosition; // non-assignment-expression is required if (!NonAssignmentExpression.S.Parse(state)) return false; // if unary-expression has been captured // we should try to capture rest parts of assignment if (state.CheckEntry(UnaryExpression.S.Key, innerIndex)) { int inner = state.InnerPosition; int outer = state.OuterPosition; // the rest parts of assigment are assignment-operator if (AssignmentOperator.S.Parse(state)) { // and another expression (recursive call here) if (S.Parse(state)) { } else { state.Reset(inner, outer); } } } state.AddBack(Key, innerIndex, outerIndex); return true; }
public override bool Parse(SyntacticState state) { // this is a special case when we are trying to // catch null-coalescing-expression without trailing "?" int innerIndex = state.InnerPosition; int outerIndex = state.OuterPosition; // ensure that usual null-coalescing-expression can be parsed if (!NullCoalescingExpression.S.Parse(state)) { return(false); } // we should not do anything if captured expression // doesn't end with a "?" LexicalEntry entry = state.GetInner(state.InnerPosition - 1); if (state.GetOuter(entry) != "?") { return(true); } // get a position of the last type entry int lastTypeIndex = 0; for (int i = innerIndex; i <= state.InnerPosition; i++) { if (state.CheckEntry(Type.S.Key, i)) { lastTypeIndex = i; } } // reset parsing and make another attempt // ignoring nullable types after specified index state.Reset(innerIndex, outerIndex); state.SetFlag(StateFlags.IgnoreNullableAfterPosition, lastTypeIndex - 1); bool parsed = ParseMany( state, ConditionalOrExpression.S, DoubleQuestionTerminal.S); state.ResetFlag(StateFlags.IgnoreNullableAfterPosition); return(parsed); }
public override bool Parse(SyntacticState state) { // this is a special case when we are trying to // catch null-coalescing-expression without trailing "?" int innerIndex = state.InnerPosition; int outerIndex = state.OuterPosition; // ensure that usual null-coalescing-expression can be parsed if (!NullCoalescingExpression.S.Parse(state)) return false; // we should not do anything if captured expression // doesn't end with a "?" LexicalEntry entry = state.GetInner(state.InnerPosition - 1); if (state.GetOuter(entry) != "?") return true; // get a position of the last type entry int lastTypeIndex = 0; for (int i = innerIndex; i <= state.InnerPosition; i++) { if (state.CheckEntry(Type.S.Key, i)) lastTypeIndex = i; } // reset parsing and make another attempt // ignoring nullable types after specified index state.Reset(innerIndex, outerIndex); state.SetFlag(StateFlags.IgnoreNullableAfterPosition, lastTypeIndex - 1); bool parsed = ParseMany( state, ConditionalOrExpression.S, DoubleQuestionTerminal.S); state.ResetFlag(StateFlags.IgnoreNullableAfterPosition); return parsed; }