forked from ForNeVeR/xaml-math
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate the parser for cases to a separate class (ForNeVeR#100)
- Loading branch information
Showing
3 changed files
with
32 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using WpfMath.Atoms; | ||
using WpfMath.Exceptions; | ||
|
||
namespace WpfMath.Parsers | ||
{ | ||
/// <summary>A parser for matrix-like constructs.</summary> | ||
internal class MatrixCommandParser : ICommandParser | ||
{ | ||
public CommandProcessingResult ProcessCommand(CommandContext context) | ||
{ | ||
var position = context.ArgumentsStartPosition; | ||
var source = context.CommandSource; | ||
|
||
if (position == source.Length) | ||
throw new TexParseException("illegal end!"); | ||
|
||
var matrixSource = TexFormulaParser.ReadElement(source, ref position); | ||
|
||
var cells = context.Parser.GetMatrixData(context.Formula, matrixSource); | ||
var matrix = new MatrixAtom(matrixSource, cells, MatrixCellAlignment.Left); | ||
var atom = new FencedAtom( | ||
matrixSource, | ||
matrix, | ||
TexFormulaParser.GetDelimiterSymbol("lbrace", null), | ||
null); | ||
return new CommandProcessingResult(atom, position); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters