From c4caf5352a7cffe55d66f1b5c351011f9d4c9154 Mon Sep 17 00:00:00 2001 From: "Evgeniy Andreev (gsomix)" Date: Sat, 25 Feb 2017 20:17:58 +0400 Subject: [PATCH 1/2] TexFormulaParser: Empty groups should be empty RowAtom --- src/WpfMath/TexFormulaParser.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WpfMath/TexFormulaParser.cs b/src/WpfMath/TexFormulaParser.cs index 3445d2eb..0fe33f2c 100644 --- a/src/WpfMath/TexFormulaParser.cs +++ b/src/WpfMath/TexFormulaParser.cs @@ -201,7 +201,8 @@ private TexFormula Parse(string value, ref int position, bool allowClosingDelimi { var groupValue = ReadGroup(formula, value, ref position, leftGroupChar, rightGroupChar); var parsedGroup = Parse(groupValue, textStyle); - var groupAtom = new TypedAtom(parsedGroup.RootAtom, TexAtomType.Ordinary, TexAtomType.Ordinary); + var innerGroupAtom = parsedGroup.RootAtom ?? new RowAtom(); + var groupAtom = new TypedAtom(innerGroupAtom, TexAtomType.Ordinary, TexAtomType.Ordinary); formula.Add(AttachScripts(formula, value, ref position, groupAtom)); } else if (ch == rightGroupChar) From 17dad77399ed9ea07c3e7326f98cb4681e87d183 Mon Sep 17 00:00:00 2001 From: "Evgeniy Andreev (gsomix)" Date: Sat, 25 Feb 2017 20:21:56 +0400 Subject: [PATCH 2/2] Add test for parsing empty groups --- src/WpfMath.Tests/ParserTests.fs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/WpfMath.Tests/ParserTests.fs b/src/WpfMath.Tests/ParserTests.fs index 72402cca..b26ed947 100644 --- a/src/WpfMath.Tests/ParserTests.fs +++ b/src/WpfMath.Tests/ParserTests.fs @@ -127,4 +127,10 @@ type ParserTests() = <| (formula <| row [ op (symbolOp "int") (System.Nullable ()) char 'f' - ]) \ No newline at end of file + ]) + + [] + let ``{} should be parsed properly`` () = + assertParseResult + <| @"{}" + <| (formula <| group (row [])) \ No newline at end of file