Skip to content

Commit

Permalink
Replace ValueTuple with Tuple in the new code (ForNeVeR#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jan 6, 2020
1 parent 9ba0fd6 commit 1df3915
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/WpfMath/TexFormulaParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Media;
using WpfMath.Atoms;
using WpfMath.Colors;
using WpfMath.Exceptions;
using WpfMath.Parsers;
using WpfMath.Utils;

namespace WpfMath
{
Expand Down Expand Up @@ -446,7 +446,7 @@ private TexFormula ReadScript(
Parse(ReadElement(value, ref position), formula.TextStyle, environment.CreateChildEnvironment());

/// <remarks>May return <c>null</c> for commands that produce no atoms.</remarks>
private (AtomAppendMode, Atom) ProcessCommand(
private Tuple<AtomAppendMode, Atom> ProcessCommand(
TexFormula formula,
SourceSpan value,
ref int position,
Expand All @@ -471,7 +471,13 @@ private TexFormula ReadScript(
formula.TextStyle,
environment.CreateChildEnvironment());
source = value.Segment(start, position - start);
return (AtomAppendMode.Add, new FractionAtom(source, numeratorFormula.RootAtom, denominatorFormula.RootAtom, true));
return Tuple.Create(
AtomAppendMode.Add,
(Atom)new FractionAtom(
source,
numeratorFormula.RootAtom,
denominatorFormula.RootAtom,
true));
}
case "left":
{
Expand All @@ -483,7 +489,9 @@ private TexFormula ReadScript(
var internals = ParseUntilDelimiter(value, ref position, formula.TextStyle, environment);
var closing = internals.ClosingDelimiter;
source = value.Segment(start, position - start);
return (AtomAppendMode.Add, new FencedAtom(source, internals.Body, opening, closing));
return new Tuple<AtomAppendMode, Atom>(
AtomAppendMode.Add,
new FencedAtom(source, internals.Body, opening, closing));
}
case "overline":
{
Expand All @@ -492,7 +500,9 @@ private TexFormula ReadScript(
formula.TextStyle,
environment.CreateChildEnvironment());
source = value.Segment(start, position - start);
return (AtomAppendMode.Add, new OverlinedAtom(source, overlineFormula.RootAtom));
return new Tuple<AtomAppendMode, Atom>(
AtomAppendMode.Add,
new OverlinedAtom(source, overlineFormula.RootAtom));
}
case "right":
{
Expand All @@ -506,7 +516,7 @@ private TexFormula ReadScript(
var closing = ParseDelimiter(value, start, ref position);

closedDelimiter = true;
return (AtomAppendMode.Add, closing);
return new Tuple<AtomAppendMode, Atom>(AtomAppendMode.Add, closing);
}
case "sqrt":
{
Expand All @@ -529,7 +539,9 @@ private TexFormula ReadScript(
environment.CreateChildEnvironment());

source = value.Segment(start, position - start);
return (AtomAppendMode.Add, new Radical(source, sqrtFormula.RootAtom, degreeFormula?.RootAtom));
return new Tuple<AtomAppendMode, Atom>(
AtomAppendMode.Add,
new Radical(source, sqrtFormula.RootAtom, degreeFormula?.RootAtom));
}
case "color":
{
Expand All @@ -539,7 +551,9 @@ private TexFormula ReadScript(
var bodyFormula = Parse(bodyValue, formula.TextStyle, environment.CreateChildEnvironment());
source = value.Segment(start, position - start);

return (AtomAppendMode.Add, new StyledAtom(source, bodyFormula.RootAtom, null, new SolidColorBrush(color)));
return new Tuple<AtomAppendMode, Atom>(
AtomAppendMode.Add,
new StyledAtom(source, bodyFormula.RootAtom, null, new SolidColorBrush(color)));
}
case "colorbox":
{
Expand All @@ -549,7 +563,9 @@ private TexFormula ReadScript(
var bodyFormula = Parse(bodyValue, formula.TextStyle, environment.CreateChildEnvironment());
source = value.Segment(start, position - start);

return (AtomAppendMode.Add, new StyledAtom(source, bodyFormula.RootAtom, new SolidColorBrush(color), null));
return new Tuple<AtomAppendMode, Atom>(
AtomAppendMode.Add,
new StyledAtom(source, bodyFormula.RootAtom, new SolidColorBrush(color), null));
}
}

Expand All @@ -563,7 +579,7 @@ private TexFormula ReadScript(
$"Incorrect parser behavior for command {command}: NextPosition = {parseResult.NextPosition}, position = {position}. Parser did not made any progress.");

position = parseResult.NextPosition;
return (parseResult.AppendMode, parseResult.Atom);
return Tuple.Create(parseResult.AppendMode, parseResult.Atom);
}

throw new TexParseException("Invalid command.");
Expand Down

0 comments on commit 1df3915

Please sign in to comment.