Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
8914 lines (8713 sloc) 430 KB
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 11.3' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 440478, 8906]
NotebookOptionsPosition[ 427670, 8692]
NotebookOutlinePosition[ 428479, 8719]
CellTagsIndexPosition[ 428436, 8716]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell["Build an Error Explorer function for the Wolfram Language", "Title",
CellChangeTimes->{{3.770055572438499*^9, 3.7700555729498453`*^9}, {
3.770055604008165*^9, 3.7700556066618843`*^9}, 3.771675200718853*^9, {
3.7716754708240633`*^9,
3.771675487218112*^9}},ExpressionUUID->"49ab34ee-bfd5-49f5-beef-\
400d3cc456dd"],
Cell[TextData[{
StyleBox["Student",
FontSize->18,
FontVariations->{"Underline"->True}],
StyleBox[": Neofytos Themistokleous\n",
FontSize->18],
StyleBox["Mentor",
FontSize->18,
FontVariations->{"Underline"->True}],
StyleBox[": Giulio Alessandrini",
FontSize->18]
}], "Text",
CellChangeTimes->{{3.549624168509506*^9, 3.549624171985794*^9}, {
3.549624508772977*^9, 3.549624510775043*^9}, {3.5498187159613867`*^9,
3.5498187170087957`*^9}, {3.549819049020514*^9, 3.5498190533440437`*^9}, {
3.77005561844785*^9, 3.7700556489651537`*^9}, {3.771675203530005*^9,
3.7716752075693502`*^9}, {3.7716752389707317`*^9,
3.771675269487706*^9}},ExpressionUUID->"94536f76-3fd2-4bf6-b228-\
fa93ec9acae9"],
Cell[CellGroupData[{
Cell[TextData[StyleBox["Introduction",
FontSize->36]], "Section",
CellChangeTimes->{{3.771675308110199*^9,
3.77167531923485*^9}},ExpressionUUID->"f5431175-7ab9-4ca2-a61a-\
1081cd822d06"],
Cell[TextData[StyleBox["My project for the Wolfram Summer School was to \
create a basic Error Explorer function for Wolfram Language Code. That is, to \
study syntactically wrong expressions and attempt minor changes in order to \
fix it. At the current phase, the functionality to place closing brackets has \
been implemented.\n\nWhat the code does, is to convert a given expression to \
a string and iterate it while building a tree of the expression. Whenever it \
encounters a comma, it checks whether it would be syntactically correct to \
add a closing bracket before that. If it is, the function calls itself \
recursively with the altered expression as argument in order to be tested. \
The output of the function is an association containing the changes made to \
the expression and the correspondent reconstructed tree.\n",
FontSize->18]], "Text",
CellChangeTimes->{{3.771675419249761*^9, 3.771675432872304*^9}, {
3.7716755007382183`*^9, 3.771675502860224*^9}, {3.771675689804946*^9,
3.77167569307528*^9}, {3.771675916807716*^9, 3.7716759332264977`*^9}, {
3.771675967032947*^9, 3.771676406299012*^9}, {3.771703654556595*^9,
3.771703671334982*^9}, {3.771703714269658*^9,
3.771703757558601*^9}},ExpressionUUID->"71f90880-cb23-40b8-b8ec-\
7b4ef22587bd"]
}, Open ]],
Cell[CellGroupData[{
Cell[TextData[StyleBox["Code",
FontSize->36]], "Section",
CellChangeTimes->{{3.771675342978766*^9,
3.771675345865012*^9}},ExpressionUUID->"120e48b9-079b-4901-b7a0-\
6ed59792f40a"],
Cell[CellGroupData[{
Cell["treeBuilder function", "Subsection",
CellChangeTimes->{{3.7716766529430017`*^9, 3.7716766550799437`*^9}, {
3.771681122749555*^9,
3.771681123046111*^9}},ExpressionUUID->"7f9b3810-e047-4622-95a6-\
15444524375a"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"treeBuilder", " ", "is", " ", "the", " ", "main", " ", "function", " ",
"that", " ", "attempts", " ", "to", " ", "recreate", " ", "the", " ",
"expression", " ", "tree", "\n", "It", " ", "iterates", " ", "the", " ",
"string"}], ",", " ",
RowBox[{
"counts", " ", "the", " ", "number", " ", "of", " ", "arguments", " ",
"each", " ", "function", " ", "currently", " ", "has", " ", "and", " ",
"wether", " ", "a", " ", "bracket", " ", "should", " ", "be", " ",
RowBox[{"added", ".", "\n", "\n",
RowBox[{"Reccursion", ":", " ",
RowBox[{
"Every", " ", "time", " ", "there", " ", "are", " ", "more", " ",
"than", " ", "one", " ", "options"}]}]}]}], ",", " ",
RowBox[{
"the", " ", "functions", " ", "calls", " ", "itsel", " ", "with", " ",
"the", " ", "new", " ", "expression", " ", "as", " ", "argument", " ",
"in", " ", "order", " ", "to", " ", "be", " ",
RowBox[{"tested", ".", " ", "That"}], " ", "is", " ", "the", " ",
"reason"}], ",", "\n", " ",
RowBox[{
RowBox[{
"some", " ", "of", " ", "the", " ", "arguments", " ", "the", " ",
"function", " ", "accepts", " ", "are", " ", "to", " ", "describe", " ",
"at", " ", "which", " ", "stage", " ", "the", " ", "iteration", " ",
"process", " ",
RowBox[{"is", ".", "\n", "\n", "Comments"}], " ", "and", " ", "strings",
" ", "are", " ", "treated", " ",
RowBox[{"specially", ".", "\n",
RowBox[{"Arguments", ":", "\n", "\t", "str", ":", " ",
RowBox[{
"The", " ", "string", " ", "from", " ", "which", " ", "the", " ",
"syntactically", " ", "correct", " ", "expressions", " ", "will",
" ", "be", " ",
RowBox[{"created", ".", "\n", "\t",
RowBox[{"treeStructure", ":", " ",
RowBox[{
"An", " ", "association", " ", "of", " ", "associations", " ",
"of", " ", "the", " ", "form"}], ":", " ",
RowBox[{"(",
RowBox[{"level", ",", "id"}], ")"}]}]}]}]}]}]}], "\[Rule]", " ",
RowBox[{"<",
RowBox[{":", "head"}]}]}], ",", " ",
RowBox[{"number", " ", "of", " ", "arguments"}], ",", " ", "parent", ",",
" ",
RowBox[{"current", " ", "pattern", " ", "\n", "\t",
RowBox[{"level", ":", " ",
RowBox[{
"corresponds", " ", "to", " ", "how", " ", "deep", " ", "in", " ",
"the", " ", "the", " ", "iteration", " ", "process", " ", "is", " ",
RowBox[{"currently", ".", "\n", "\t", "id"}]}], ":", " ",
RowBox[{
"a", " ", "unique", " ", "number", " ", "of", " ", "each", " ",
"function", " ", "of", " ", "the", " ", "same", " ",
RowBox[{"level", ".", " ", "For"}], " ", "example", " ", "if", " ",
"to", " ",
RowBox[{"Cos", "[", "]"}], " ", "functions", " ", "exist", " ", "at",
" ", "the", " ", "same", " ", "leve"}]}]}], ",", " ",
RowBox[{
RowBox[{"they", "'"}], "ll", " ", "have", " ", "a", " ", "different",
" ", "id", " ",
RowBox[{"number", ".", "\n", "\t",
RowBox[{"head", ":", " ",
RowBox[{
"The", " ", "head", " ", "of", " ", "the", " ", "function", " ",
"currently", " ", "being", " ",
RowBox[{"iterated", "."}]}]}]}]}]}], "\n", "*)"}], "\n",
RowBox[{
RowBox[{"treeBuilder", "[",
RowBox[{
RowBox[{"currentPosition_", "?", "IntegerQ"}], ",", " ",
RowBox[{"str_", "?", "StringQ"}], ",", " ", "thisChanges_", ",", " ",
"thistreeStructure_", ",", " ",
RowBox[{"thislevel_", "?", "IntegerQ"}], ",", " ",
RowBox[{"thisid_", "?", "IntegerQ"}], ",", " ",
RowBox[{"thishead_", "?", "StringQ"}]}], "]"}], " ", ":=", "\n", "\t",
RowBox[{"Module", "[", "\n", "\t\t",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"suggestions", "=",
RowBox[{"{", "}"}]}], ",", " ", "\n", "\t\t\t",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"The", " ", "variable", " ", "that", " ", "will", " ", "be", " ",
"returned", " ", "by", " ", "the", " ",
RowBox[{"function", ".", " ", "Every"}], " ", "time", " ", "a", " ",
"full", " ", "expression", " ", "has", " ", "passed", " ", "the",
" ", "criteria"}], ",", " ",
RowBox[{
"it", " ", "is", " ", "being", " ", "added", " ", "to", " ", "this",
" ",
RowBox[{"list", ".", "\n", "\t\t\t", "Currently"}], " ", "it", " ",
"contains", " ", "full", " ",
RowBox[{"treeStructures", ".", " ", "I"}], " ", "believe", " ",
"that", " ", "in", " ", "the", " ", "end", " ", "it", " ", "will",
" ", "also", " ", "contain", " ", "the", " ", "changes", " ",
"made", " ", "and", " ", "the", " ", "final", " ", "expressino",
" ", "string"}]}], " ", "*)"}], "\n", "\t\t",
RowBox[{"changes", " ", "=", " ", "thisChanges"}], ",", " ",
RowBox[{"(*", " ",
RowBox[{
"Keeps", " ", "traxk", " ", "of", " ", "the", " ", "proposed", " ",
"changes", " ", "to", " ", "the", " ",
RowBox[{"string", ".", " ", "It"}], " ", "contains", " ", "the", " ",
"index", " ", "where", " ", "a", " ", "bracket", " ", "was", " ",
RowBox[{"added", "."}]}], " ", "*)"}], "\n", "\t\t",
RowBox[{"level", " ", "=", " ", "thislevel"}], ",", " ", "\n", "\t\t",
RowBox[{"treeStructure", " ", "=", " ", "thistreeStructure"}], ",",
" ", "\n", "\t\t",
RowBox[{"head", " ", "=", " ", "thishead"}], ",", "\n", "\t\t",
RowBox[{"commasFound", " ", "=", " ", "0"}], ",", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Commas", " ", "correspond", " ", "to", " ",
RowBox[{"arguments", ".", " ", "Keeping"}], " ", "track", " ", "of",
" ", "how", " ", "many", " ", "commas", " ", "were", " ",
"found"}], ",", " ",
RowBox[{
"serves", " ", "to", " ", "know", " ", "where", " ", "the", " ",
"iteratino", " ", "process", " ", "is"}]}], " ", "*)"}], "\n",
"\t\t",
RowBox[{"id", " ", "=", " ", "thisid"}], ",", "\n", "\t\t",
RowBox[{"commaPositions", " ", "=", " ",
RowBox[{"FindCommaPositions", "[", "str", "]"}]}], ",", " ",
RowBox[{"(*", " ",
RowBox[{
"Check", " ", "where", " ", "the", " ", "commas", " ", "are", " ",
"in", " ", "the", " ",
RowBox[{"string", ".", " ", "To"}], " ", "be", " ", "used", " ",
"with", " ", "commas", " ",
RowBox[{"found", ".", " ", "INNEFICIENT", ".", " ", "to"}], " ",
"be", " ",
RowBox[{"improved", "."}]}], " ", "*)"}], "\n", "\t\t",
RowBox[{"inComment", " ", "=", " ", "False"}], ",", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"Keep", " ", "track", " ", "of", " ", "whether", " ", "a", " ",
"part", " ", "of", " ", "an", " ", "expression", " ", "is", " ",
"a", " ", "comment"}], ",", " ",
RowBox[{
"so", " ", "that", " ", "the", " ", "contents", " ", "can", " ",
"be", " ", "ignored"}]}], " ", "*)"}], "\n", "\t\t",
RowBox[{"inString", " ", "=", " ", "False"}], ",", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"Keep", " ", "track", " ", "whether", " ", "part", " ", "of", " ",
"an", " ", "expressino", " ", "is", " ", "a", " ", "string"}], ",",
" ",
RowBox[{
"so", " ", "that", " ", "special", " ", "characters", " ", "will",
" ", "be", " ", "ignored"}]}], " ", "*)"}], "\n", "\t\t",
RowBox[{"arg", "=", "\"\<\>\""}], ",", " ",
RowBox[{"(*", " ",
RowBox[{
"Used", " ", "to", " ", "keep", " ", "track", " ", "of", " ",
"argument", " ", "functions", " ", "in", " ", "order", " ", "to",
" ", "be", " ", "added", " ", "to", " ", "the", " ", "tree"}], " ",
"*)"}], "\n", "\t\t",
RowBox[{"inPart", " ", "=", " ", "False"}]}], "\n", "\t\t",
RowBox[{"(*", " ",
RowBox[{"something", " ", "about", " ", "args"}], " ", "*)"}], "\n",
"\t\t", "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Reap", "[", "\n", "\t",
RowBox[{
RowBox[{"StringCases", "[", " ",
RowBox[{"(*", " ",
RowBox[{
"Iterate", " ", "until", " ", "some", " ", "special", " ",
"characters", " ", "are", " ", "found"}], " ", "*)"}], "\n",
"\t\t",
RowBox[{"str", ",", "\n", "\t\t",
RowBox[{"{", "\n", "\t\t",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"head", ":",
RowBox[{"WordCharacter", ".."}]}], "~~", "\"\<[\>\""}],
"\[RuleDelayed]", " ",
RowBox[{"(*", " ",
RowBox[{
"Going", " ", "down", " ", "a", " ", "level", " ", "on", " ",
"the", " ", "tree", " ", "because", " ", "a", " ", "new", " ",
"function", " ", "has", " ", "started"}], " ", "*)"}], "\n",
"\t\t\t\t",
RowBox[{"(*", " ",
RowBox[{
RowBox[{"If", " ", "level"}], " ", "\[LessEqual]", " ",
RowBox[{
"0", " ", "the", " ", "current", " ", "expression", " ", "is",
" ", "wr", "ong", " ", "except", " ", "if", " ", "the", " ",
"treeStructure", " ", "is", " ", "empty", " ",
RowBox[{"(",
RowBox[{
"which", " ", "corresponds", " ", "to", " ", "the", " ",
"first", " ", "function", " ", "call"}], ")"}]}]}], " ",
"*)"}], "\n", "\t\t\t\t",
RowBox[{"(*", " ",
RowBox[{
"The", " ", "character", " ", "is", " ", "ignored", " ", "if",
" ", "the", " ",
RowBox[{"flags", ":", " ",
RowBox[{
"inComment", " ", "or", " ", "inString", " ", "are", " ",
"activated"}]}]}], " ", "*)"}], "\n", "\t\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"level", " ", ">", " ", "0"}], " ", "||", " ",
RowBox[{"treeStructure", " ", "\[Equal]", " ",
RowBox[{"Association", "[",
RowBox[{"<|", "|>"}], "]"}]}]}], ")"}], " ", "&&", " ",
RowBox[{"inComment", "\[Equal]", "False"}], " ", "&&", " ",
RowBox[{"inString", "\[Equal]", "False"}]}], ",", "\n",
"\t\t\t\t\t",
RowBox[{
RowBox[{"DBPrint", "[", "\"\<Going Down\>\"", "]"}], ";",
"\n", "\t\t\t\t\t",
RowBox[{"level", "++"}], ";", " ",
RowBox[{"(*", " ",
RowBox[{
"goind", " ", "deeper", " ", "in", " ", "the", " ",
"expression", " ", "tree"}], " ", "*)"}],
"\[IndentingNewLine]", "\t\t\t\t\t",
RowBox[{"id", " ", "=", " ",
RowBox[{"whatismyid", "[",
RowBox[{"level", ",", "treeStructure"}], "]"}]}], ";", " ",
RowBox[{"(*", " ",
RowBox[{
"figure", " ", "out", " ", "what", " ", "the", " ",
"current", " ", "id", " ", "is"}], " ", "*)"}],
"\[IndentingNewLine]", "\t\t\t\t\t",
RowBox[{"treeStructure", " ", "=", " ",
RowBox[{"Append", "[",
RowBox[{"treeStructure", " ", ",", " ",
RowBox[{"newTreeEntry", "[",
RowBox[{
"level", ",", " ", "id", ",", " ", "head", ",", " ",
"treeStructure"}], "]"}]}], "]"}]}], ";",
RowBox[{"(*", " ",
RowBox[{
"Add", " ", "a", " ", "new", " ", "entry", " ", "to", " ",
"the", " ", "treeStructure"}], " ", "*)"}],
"\[IndentingNewLine]", "\t\t\t\t\t",
RowBox[{"DBPrint", "[",
RowBox[{
"\"\<current level, id, head is: \>\"", ",", " ", "level",
",", " ", "\"\< \>\"", ",", " ", "id", ",", " ",
"\"\< \>\"", ",", " ", "head"}], "]"}]}]}], "\n",
"\t\t\t\t\t", "]"}]}], ",", "\[IndentingNewLine]", "\t\t",
RowBox[{"\"\<]\>\"", " ", "\[RuleDelayed]", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"Going", " ", "up", " ", "one", " ", "a", " ", "level", " ",
"on", " ", "the", " ", "tree"}], ",", " ",
RowBox[{
"because", " ", "the", " ", "current", " ", "function", " ",
"has", " ", "ended", " ", "\n", "\t\t\t ", "The", " ",
"character", " ", "is", " ", "ignored", " ", "if", " ", "the",
" ",
RowBox[{"flags", ":", " ",
RowBox[{
RowBox[{
"inComment", " ", "or", " ", "inString", " ", "are", " ",
"activated", " ", "\n", "\t\t\t ", "If", " ", "level",
" ", "is"}], " ", "\[LessEqual]", " ", "0"}]}]}], ",", " ",
RowBox[{
"the", " ", "current", " ", "expression", " ", "under", " ",
"consideration", " ", "is", " ", "wrong", " ", "and", " ",
"this", " ", "part", " ", "is", " ", "skipped"}]}], " ",
"*)"}], "\n", "\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"inComment", " ", "\[Equal]", " ", "False"}], " ", "&&",
" ",
RowBox[{"inString", " ", "\[Equal]", " ", "False"}]}], ",",
" ", "\n", "\t\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{"level", " ", ">", " ", "0"}], ",", " ", "\n",
"\t\t\t\t\t",
RowBox[{
RowBox[{"DBPrint", "[", "\"\<Going Up\>\"",
RowBox[{"(*",
RowBox[{",", "treeStructure"}], "*)"}], "]"}], ";", "\n",
"\t\t\t\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"StringLength", "[", "arg", "]"}], ">", "0"}],
",", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"If", " ", "there", " ", "is", " ", "an", " ",
"argument"}], ",", " ",
RowBox[{
"add", " ", "it", " ", "to", " ", "the", " ", "tree", " ",
"before", " ", "going", " ", "up", " ", "the", " ",
"tree"}]}], " ", "*)"}], "\n", "\t\t\t\t\t\t\t",
RowBox[{
RowBox[{"treeStructure", "=",
RowBox[{"Append", "[", " ",
RowBox[{"treeStructure", ",",
RowBox[{"addArgumentToTree", "[",
RowBox[{"level", ",", "treeStructure", ",", "arg"}],
"]"}]}], "]"}]}], ";", "\n", "\t\t\t\t\t\t\t",
RowBox[{"arg", "=", "\"\<\>\""}]}]}], " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"Since", " ", "the", " ", "argument", " ", "has", " ",
"been", " ", "added", " ", "to", " ", "the", " ", "tree",
" ", "already"}], ",", " ",
RowBox[{"we", " ", "discard", " ", "it"}]}], " ", "*)"}],
"\n", "\t\t\t\t\t\t", "]"}], ";", "\n", "\t\t\t ",
RowBox[{"level", "--"}], ";", " ",
RowBox[{"(*", " ",
RowBox[{"Going", " ", "up", " ", "one", " ", "level"}],
" ", "*)"}], "\[IndentingNewLine]", "\t\t\t ",
RowBox[{"id", " ", "=", " ",
RowBox[{"whatismyid", "[",
RowBox[{"level", ",", "treeStructure"}], "]"}]}], ";",
"\[IndentingNewLine]", "\t\t\t ",
RowBox[{"If", "[",
RowBox[{
RowBox[{"level", ">", "0"}], ",", "\[IndentingNewLine]",
"\t\t\t\t ",
RowBox[{"head", "=",
RowBox[{
RowBox[{"treeStructure", "[",
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], "]"}], "[",
RowBox[{"[", "1", "]"}], "]"}]}], ",",
RowBox[{"head", "=", "\"\< \>\""}]}], "]"}], ";", " ",
RowBox[{"(*", " ",
RowBox[{
"Go", " ", "back", " ", "to", " ", "whoever", " ", "the",
" ", "parent", " ", "of", " ", "the", " ", "this", " ",
"function", " ", "was"}], " ", "*)"}],
"\[IndentingNewLine]", "\t\t\t\t ",
RowBox[{"DBPrint", "[",
RowBox[{
"\"\<current level, id, head is: \>\"", ",", "level", ",",
"\"\< \>\"", ",", "id", ",", " ", "\"\< \>\"", ",", " ",
"head"}], "]"}], ";"}], "\n", "\t\t\t ", ",",
RowBox[{"(*", " ",
RowBox[{
RowBox[{"if", " ", "level"}], " ", "\[LessEqual]", " ",
"0"}], " ", "*)"}],
RowBox[{"level", "--"}]}], "]"}]}], "\n", "\t\t\t", "]"}]}],
",", "\[IndentingNewLine]", "\t\t",
RowBox[{"\"\<,\>\"", " ", "\[RuleDelayed]", " ", "\n", "\t\t",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"Commas", " ", "are", " ", "the", " ", "way", " ", "the", " ",
"number", " ", "of", " ", "arguments", " ", "in", " ",
"functions", " ", "are", " ", "infered", " ", "\n", "\t\t ",
"With", " ", "every", " ", "comma", " ", "found"}], ",", " ",
RowBox[{"an", " ", "initial", " ", "check", " ", "whether"}],
",", " ",
RowBox[{
"a", " ", "closing", " ", "square", " ", "bracket", " ", "can",
" ", "be", " ", "positioned", " ", "here"}], ",", " ",
RowBox[{
"based", " ", "on", " ", "the", " ", "number", " ", "of", " ",
"arguments"}]}], " \t", "*)"}], "\n", "\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"level", " ", ">", " ", "0"}], " ", "&&", " ",
RowBox[{"inComment", " ", "\[Equal]", " ", "False"}], " ", "&&",
" ",
RowBox[{"inString", " ", "\[Equal]", " ", "False"}]}], ",",
" ", "\n", "\t\t\t\t\t",
RowBox[{
RowBox[{"DBPrint", "[",
RowBox[{"\"\<A comma was found at position \>\"", ",", " ",
RowBox[{"commaPositions", "[",
RowBox[{"[",
RowBox[{"commasFound", "+", "1"}], "]"}], "]"}]}], "]"}],
";", "\n", "\t\t\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"StringLength", "[", "arg", "]"}], ">", "0"}], ",",
" ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"If", " ", "there", " ", "is", " ", "an", " ",
"argument"}], ",", " ",
RowBox[{
"add", " ", "it", " ", "to", " ", "the", " ", "tree", " ",
"before", " ", "going"}]}], " ", "*)"}], "\n",
"\t\t\t\t\t\t",
RowBox[{
RowBox[{"treeStructure", "=",
RowBox[{"Append", "[",
RowBox[{"treeStructure", ",",
RowBox[{"addArgumentToTree", "[",
RowBox[{"level", ",", "treeStructure", ",", "arg"}],
"]"}]}], "]"}]}], ";", "\n", "\t\t\t\t\t\t",
RowBox[{"arg", "=", "\"\<\>\""}]}]}], " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"Since", " ", "the", " ", "argument", " ", "has", " ",
"been", " ", "added", " ", "to", " ", "the", " ", "tree",
" ", "already"}], ",", " ",
RowBox[{"we", " ", "discard", " ", "it"}]}], " ", "*)"}],
"\n", "\t\t\t\t\t", "]"}], ";", "\[IndentingNewLine]",
"\t\t\t\t\t",
RowBox[{"id", " ", "=", " ",
RowBox[{"whatismyid", "[",
RowBox[{"level", ",", "treeStructure"}], "]"}]}], ";",
"\[IndentingNewLine]", "\t\t\t\t\t",
RowBox[{"matches", "=", " ",
RowBox[{"testPatternMatch", "[",
RowBox[{"treeStructure", ",", "level", ",", "id"}], "]"}]}],
";", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Check", " ", "whether"}], ",", " ",
RowBox[{
"if", " ", "the", " ", "current", " ", "function", " ",
"ends", " ", "here"}], ",", " ",
RowBox[{
"it", " ", "will", " ", "be", " ", "syntactically", " ",
"correct"}]}], " ", "*)"}], "\[IndentingNewLine]",
"\t\t\t\t\t",
RowBox[{"If", "[",
RowBox[{"matches", ",", " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{"If", " ", "it", " ", "does"}], ",", " ",
RowBox[{
"branch", " ", "and", " ", "follow", " ", "that", " ",
"path", " ", "to", " ", "the", " ",
RowBox[{"end", ".", " ", "Append"}], " ", "the", " ",
"result", " ", "to", " ", "the", " ", "suggestions", " ",
RowBox[{"list", ".", " ", "\n", "\t\t\t\t\t\t",
RowBox[{"Note", ":", " ",
RowBox[{
"it", " ", "is", " ", "eventually", " ", "decided", " ",
"that", " ", "this", " ", "path", " ", "was", " ", "not",
" ", "corret"}]}]}]}], ",", " ",
RowBox[{
"the", " ", "output", " ", "of", " ", "the", " ",
"function", " ", "will", " ", "be", " ", "empty"}]}], " ",
"*)"}], "\n", "\t\t\t\t\t",
RowBox[{
RowBox[{"DBPrint", "[",
RowBox[{"\"\<Branching: \>\"", ",", " ",
RowBox[{"currentPosition", "+",
RowBox[{"commaPositions", "[",
RowBox[{"[",
RowBox[{"commasFound", "+", "1"}], "]"}], "]"}]}], ",",
" ", "\n", "\t\t\t\t\t",
RowBox[{"Append", "[",
RowBox[{"changes", ",", " ",
RowBox[{"currentPosition", "+",
RowBox[{"commaPositions", "[",
RowBox[{"[",
RowBox[{"commasFound", "+", "1"}], "]"}], "]"}]}]}],
"]"}]}], "]"}], ";", " ", "\n", "\t\t\t\t\t",
RowBox[{"suggestions", " ", "=", " ",
RowBox[{"Flatten", "\[NonBreakingSpace]", "@", " ",
RowBox[{"Append", "[",
RowBox[{"suggestions", ",",
RowBox[{"treeBuilder", "[",
RowBox[{
RowBox[{"currentPosition", "+",
RowBox[{"commaPositions", "[",
RowBox[{"[",
RowBox[{"commasFound", "+", "1"}], "]"}], "]"}]}], ",",
RowBox[{"createAlternativeExpr", "[",
RowBox[{
"str", ",", "commaPositions", ",", "commasFound"}], "]"}],
",",
RowBox[{"Append", "[",
RowBox[{"changes", ",",
RowBox[{"currentPosition", "+",
RowBox[{"commaPositions", "[",
RowBox[{"[",
RowBox[{"commasFound", "+", "1"}], "]"}], "]"}]}]}],
"]"}], ",", "treeStructure", ",", "level", ",", "id", ",",
"head"}], "]"}]}], "]"}]}]}]}]}], "\n", "\t\t\t\t\t",
"]"}], ";", "\n", "\t\t\t\t\t",
RowBox[{"commasFound", "++"}], ";", "\[IndentingNewLine]",
"\t\t\t\t\t",
RowBox[{"treeStructure", "=", "\n", "\t\t\t\t\t",
RowBox[{"Append", "[", "\n", "\t\t\t\t\t\t",
RowBox[{"treeStructure", ",", "\n", "\t\t\t\t\t\t",
RowBox[{"updateTreeEntry", "[",
RowBox[{
"level", ",", "id", ",", "treeStructure", ",", "arg"}],
"]"}]}], "\[IndentingNewLine]", "\t\t\t\t\t ",
"]"}]}]}]}], "\n", "\t\t\t", "]"}]}], ",", "\n", "\t\t",
RowBox[{"\"\<(*\>\"", " ", "\[RuleDelayed]", " ",
RowBox[{"{",
RowBox[{
RowBox[{"DBPrint", "[", "\"\<Start of comment\>\"", "]"}], ";",
" ",
RowBox[{"inComment", " ", "=", " ", "True"}]}], "}"}]}], ",",
"\n", "\t\t",
RowBox[{"\"\<*)\>\"", " ", "\[RuleDelayed]", " ",
RowBox[{"{",
RowBox[{
RowBox[{"DBPrint", "[", "\"\<End of comment\>\"", "]"}], ";",
" ",
RowBox[{"inComment", " ", "=", " ", "False"}]}], "}"}]}], ",",
"\n", "\t\t",
RowBox[{"\"\<\\\"\>\"", " ", "\[RuleDelayed]", " ",
RowBox[{"If", "[",
RowBox[{
RowBox[{"inComment", " ", "\[Equal]", " ", "False"}], ",", " ",
RowBox[{"Sow", "[",
RowBox[{"inString", " ", "=", " ",
RowBox[{"!", "inString"}]}], "]"}]}], "]"}]}], ",", "\n",
"\t\t",
RowBox[{
RowBox[{"text", ":",
RowBox[{"LetterCharacter", ".."}]}], " ", "\[RuleDelayed]", " ",
RowBox[{"{",
RowBox[{"arg", "=", "text"}], "}"}]}]}],
RowBox[{"(*", " ",
RowBox[{
"Find", " ", "the", " ", "head", " ", "of", " ", "each", " ",
"function"}], " ", "*)"}], "\n", "\t\t", "}"}]}],
"\[IndentingNewLine]", "\t\t", "]"}], ",", "\n", "\t", "_", ",",
"\n", "\t", "Rule"}], "\n", "\t", "]"}], ";", "\n", "\t", "\n", "\t",
RowBox[{"Which", "[", "\n", "\t\t",
RowBox[{
RowBox[{"level", " ", "<", " ", "0"}], ",", "\n", "\t\t\t",
RowBox[{"DBPrint", "[", "\"\<We do not like that one\>\"", "]"}], ",",
"\n", "\t\t",
RowBox[{"level", " ", "\[Equal]", " ", "0"}], ",", "\n", "\t\t\t",
RowBox[{"{", "\n", "\t\t\t\t",
RowBox[{
RowBox[{
RowBox[{"DBPrint", "[", "\"\<We like this one\>\"", "]"}], ";",
"\n", "\t\t\t\t",
RowBox[{"suggestions", " ", "=", " ",
RowBox[{"Append", "[",
RowBox[{"suggestions", ",",
RowBox[{"<|",
RowBox[{
RowBox[{
"\"\<tree\>\"", " ", "\[Rule]", " ", "treeStructure"}], ",",
" ",
RowBox[{"\"\<changes\>\"", "\[Rule]", "changes"}]}], "|>"}]}],
"]"}]}]}], ","}], "\n", "\t\t\t\t",
RowBox[{"(*",
RowBox[{
RowBox[{"Sow", "[",
RowBox[{"<|",
RowBox[{
RowBox[{"\"\<tree\>\"", " ", "\[Rule]", " ", "treeStructure"}],
",", " ",
RowBox[{"\"\<changes\>\"", "\[Rule]", "changes"}]}], "|>"}],
"]"}], ","}], "*)"}], "\n", "\t\t\t", "}"}], ",", "\n", "\t\t",
RowBox[{"level", " ", ">", " ", "0"}], ",", "\n", "\t\t\t",
RowBox[{
RowBox[{"DBPrint", "[", "\"\<level is too big :\>\"", "]"}], ";",
"\n", "\t\t\t",
RowBox[{"suggestions", " ", "=", " ",
RowBox[{"Flatten", "\[NonBreakingSpace]", "@", " ",
RowBox[{"Append", "[",
RowBox[{"suggestions", ",", " ",
RowBox[{"treeBuilder", "[",
RowBox[{"currentPosition", ",", " ",
RowBox[{"str", "<>", "\"\<]\>\""}], ",", " ",
RowBox[{"Append", "[",
RowBox[{"thisChanges", ",", " ",
RowBox[{"currentPosition", " ", "+", " ",
RowBox[{"StringLength", "[", "str", "]"}], "+", "1"}]}],
"]"}], ",", "thistreeStructure", ",", "thislevel", ",",
"thisid", ",", "thishead"}], "]"}]}], "]"}]}]}]}]}], "\n",
"\t\t\t", "]"}], ";", "\n", "\t", "\n", "\t",
RowBox[{"DBPrint", "[", "\"\<End of Branching \>\"", "]"}], ";", "\n",
"\t", "\n", "\t", "suggestions"}]}], "\n", "]"}]}]}]], "Code",
CellChangeTimes->{{3.771362006216511*^9, 3.771362015523728*^9},
3.771362086420603*^9, {3.771362118045649*^9, 3.771362655589736*^9}, {
3.771362756691988*^9, 3.771363173801856*^9}, {3.77136336177672*^9,
3.771363381880803*^9}, {3.7713638669874887`*^9, 3.771363876946376*^9}, {
3.77136393680691*^9, 3.771363950949457*^9}, {3.771364093071322*^9,
3.771364103279016*^9}, 3.7713641562262363`*^9, {3.771364322664548*^9,
3.7713643356909246`*^9}, {3.7713643788287373`*^9, 3.77136444236012*^9}, {
3.771364519238729*^9, 3.771364564858914*^9}, 3.771364619148706*^9, {
3.7713646913059187`*^9, 3.7713646959631453`*^9}, {3.7713650342839518`*^9,
3.77136503792929*^9}, {3.771365157230564*^9, 3.77136515865693*^9}, {
3.771366546589078*^9, 3.77136664669131*^9}, {3.771366696425791*^9,
3.7713666993871927`*^9}, {3.771366772302217*^9, 3.771366806809655*^9}, {
3.771366847213586*^9, 3.7713668555423517`*^9}, {3.771366885746833*^9,
3.7713668975512543`*^9}, {3.771366933638749*^9, 3.771366946820918*^9}, {
3.771367004416342*^9, 3.771367085355175*^9}, {3.771367139857263*^9,
3.771367143601585*^9}, {3.77136723340985*^9, 3.77136742680881*^9}, {
3.771412256080722*^9, 3.77141225704732*^9}, {3.7714123316922007`*^9,
3.771412516655488*^9}, {3.771412560596466*^9, 3.771412579003467*^9}, {
3.771412615660199*^9, 3.771412617028051*^9}, {3.771412892605502*^9,
3.771412894181807*^9}, {3.771442147996543*^9, 3.77144217407862*^9}, {
3.771442309907482*^9, 3.771442313049698*^9}, {3.7714426490814047`*^9,
3.771442719951195*^9}, 3.771442780134013*^9, {3.771442894960253*^9,
3.771442924517709*^9}, {3.771442997450091*^9, 3.77144302572785*^9}, {
3.771443079798843*^9, 3.771443140980547*^9}, {3.7714433407229357`*^9,
3.77144335942673*^9}, 3.7714437237710953`*^9, {3.771443820860186*^9,
3.771443832488925*^9}, 3.771443882755567*^9, {3.771443949968174*^9,
3.771443995797792*^9}, {3.7714440984331713`*^9, 3.771444099523315*^9}, {
3.771444605910355*^9, 3.771444612900814*^9}, {3.77144464430477*^9,
3.7714446512895737`*^9}, {3.7714447839877787`*^9, 3.771444806104825*^9}, {
3.771444913210311*^9, 3.771444914750972*^9}, {3.771445065088969*^9,
3.771445066009634*^9}, {3.771445191972951*^9, 3.771445196313753*^9}, {
3.771445274626226*^9, 3.7714452778342237`*^9}, {3.771446067365419*^9,
3.7714461058935013`*^9}, {3.7714461428162403`*^9,
3.7714461985671597`*^9}, {3.771446238214718*^9, 3.771446240659153*^9}, {
3.771446433871645*^9, 3.771446445766183*^9}, {3.7714465950939703`*^9,
3.7714466170300627`*^9}, {3.771446891907667*^9, 3.771446892278645*^9}, {
3.7714470048921127`*^9, 3.771447056060583*^9}, {3.771447174069879*^9,
3.771447179014112*^9}, {3.771447280217731*^9, 3.771447313427902*^9}, {
3.771447712381344*^9, 3.7714477184676228`*^9}, {3.771447772735381*^9,
3.771447773350482*^9}, {3.771447876082943*^9, 3.771447882692936*^9}, {
3.771447939366621*^9, 3.7714479927638063`*^9}, {3.7714480405799427`*^9,
3.771448045748268*^9}, {3.771448397578755*^9, 3.771448417229409*^9},
3.77144905587668*^9, 3.771449218705681*^9, {3.771449340424562*^9,
3.771449354871666*^9}, {3.771449409895927*^9, 3.7714494236770487`*^9}, {
3.7714494729693117`*^9, 3.771449485385104*^9}, {3.77145012388249*^9,
3.771450127216447*^9}, {3.771450161248345*^9, 3.771450163404838*^9}, {
3.771450205156763*^9, 3.771450205853251*^9}, {3.771450276362977*^9,
3.771450330328993*^9}, 3.771450556685597*^9, {3.77145066357939*^9,
3.771450700429881*^9}, {3.7714512448464622`*^9, 3.7714512463785257`*^9}, {
3.7714513898013983`*^9, 3.771451515639883*^9}, {3.771451621152474*^9,
3.7714517150604353`*^9}, {3.771451747494792*^9, 3.771451749943782*^9}, {
3.7714517831095047`*^9, 3.771451793410653*^9}, {3.771451829359967*^9,
3.77145183082666*^9}, {3.771451907717695*^9, 3.771451925894326*^9}, {
3.771452006615478*^9, 3.771452042483374*^9}, {3.7714521099552307`*^9,
3.771452118631708*^9}, {3.771452181611244*^9, 3.7714521898266163`*^9}, {
3.771452365157031*^9, 3.771452410768037*^9}, {3.771452446890223*^9,
3.77145247663116*^9}, 3.771454988045733*^9, {3.771455263114704*^9,
3.771455303405796*^9}, {3.771456484717388*^9, 3.771456519155849*^9},
3.771456689411128*^9, {3.771457198130332*^9, 3.7714572031762943`*^9}, {
3.7714573329853*^9, 3.771457333347978*^9}, {3.7714574512735863`*^9,
3.771457458367919*^9}, {3.7714575072101517`*^9, 3.7714575490324717`*^9}, {
3.771457881228486*^9, 3.771457900977796*^9}, 3.771457959374838*^9, {
3.7715000042087097`*^9, 3.7715000791413383`*^9}, {3.771500125908863*^9,
3.7715001552737083`*^9}, {3.771501484028212*^9, 3.77150148843279*^9},
3.77150153125144*^9, {3.771501733539752*^9, 3.7715018321667013`*^9}, {
3.77150186565837*^9, 3.771501869580326*^9}, {3.771501902602687*^9,
3.771501950032485*^9}, {3.7715020357475557`*^9, 3.7715020389699574`*^9}, {
3.771504521255499*^9, 3.771504537070751*^9}, 3.771511210309855*^9, {
3.7715139592122583`*^9, 3.7715139735113173`*^9}, {3.771514013863624*^9,
3.7715141772657433`*^9}, {3.7715142088747053`*^9, 3.771514301726138*^9}, {
3.771514429789418*^9, 3.7715144306713257`*^9}, {3.771514497832857*^9,
3.771514523900888*^9}, {3.771515690651322*^9, 3.77151571905551*^9}, {
3.771515890020203*^9, 3.771515923794814*^9}, {3.771516223783848*^9,
3.771516227375317*^9}, {3.771517140348637*^9, 3.771517183238338*^9}, {
3.771517402853936*^9, 3.771517462546172*^9}, {3.771518609625205*^9,
3.7715186405252037`*^9}, {3.771518711677218*^9, 3.771518717963636*^9}, {
3.771519041124344*^9, 3.771519102174617*^9}, {3.77151914801582*^9,
3.771519161467825*^9}, {3.7715208182540817`*^9, 3.7715210441687603`*^9}, {
3.7715211865410433`*^9, 3.771522019670351*^9}, {3.771522053280406*^9,
3.7715222013749113`*^9}, {3.771522248864739*^9, 3.771522370166245*^9}, {
3.7715224030967093`*^9, 3.7715224815606947`*^9}, {3.7715226997328978`*^9,
3.771522777297751*^9}, {3.771522812602989*^9, 3.771522971702385*^9}, {
3.7715230086328983`*^9, 3.7715232096012897`*^9}, {3.771523313171363*^9,
3.771523325605304*^9}, {3.771527056467519*^9, 3.771527066115438*^9}, {
3.771527265277254*^9, 3.771527299584749*^9}, {3.771527342592696*^9,
3.771527345192234*^9}, {3.771527470243064*^9, 3.771527472123252*^9}, {
3.771527729747238*^9, 3.771527731578205*^9}, {3.771527778457223*^9,
3.771527832206325*^9}, 3.771527951522047*^9, {3.7715283935214853`*^9,
3.771528486708242*^9}, {3.771528704347735*^9, 3.77152875663485*^9}, {
3.771528796930005*^9, 3.771528797973735*^9}, {3.7715288307667007`*^9,
3.771528972791039*^9}, {3.771529090608733*^9, 3.771529096395255*^9}, {
3.771529139815501*^9, 3.771529146047682*^9}, {3.771529468779215*^9,
3.771529481742841*^9}, {3.771532365374267*^9, 3.7715323656956167`*^9}, {
3.771532441780241*^9, 3.771532486600618*^9}, {3.7715326180050087`*^9,
3.771532624066293*^9}, {3.77153268156149*^9, 3.771532690355977*^9}, {
3.771532736962655*^9, 3.771532788684617*^9}, {3.771532830065049*^9,
3.771532831473065*^9}, {3.771533170038632*^9, 3.771533191425215*^9}, {
3.771533480270513*^9, 3.771533495880817*^9}, {3.7715336599631033`*^9,
3.771533664429936*^9}, {3.771533713112876*^9, 3.7715337163315077`*^9},
3.77153376752035*^9, {3.771533808153372*^9, 3.771533809900927*^9},
3.771533940712983*^9, {3.771534092513206*^9, 3.77153409893045*^9}, {
3.771534137030108*^9, 3.771534173160818*^9}, {3.771534223675332*^9,
3.771534233271624*^9}, {3.771538008019537*^9, 3.771538054880371*^9}, {
3.771538116183929*^9, 3.771538170561741*^9}, {3.771538239068591*^9,
3.7715382912588987`*^9}, 3.771538323069026*^9, {3.771538388716772*^9,
3.771538391159642*^9}, {3.7715384232437763`*^9, 3.7715384251467113`*^9}, {
3.771538532517683*^9, 3.7715385462727747`*^9}, {3.7715388164891*^9,
3.771538823681203*^9}, {3.771539181886704*^9, 3.7715391849661913`*^9}, {
3.77153928761305*^9, 3.7715393505950823`*^9}, {3.7715393985922422`*^9,
3.7715394046378098`*^9}, {3.771539549543233*^9, 3.771539552910858*^9}, {
3.771539888108399*^9, 3.771539931239846*^9}, {3.771540121793335*^9,
3.771540183418795*^9}, {3.771540293181485*^9, 3.771540358698735*^9}, {
3.7715404188635674`*^9, 3.771540445653729*^9}, {3.7715417712503357`*^9,
3.7715417817278557`*^9}, {3.771541874341683*^9, 3.771541879019367*^9}, {
3.771542102187508*^9, 3.771542108744883*^9}, {3.771542430137669*^9,
3.771542492499649*^9}, {3.77154269627182*^9, 3.7715427137372103`*^9},
3.771542797639629*^9, {3.7715429664820232`*^9, 3.771542966689588*^9}, {
3.771543030342637*^9, 3.7715430603761377`*^9}, {3.771543106403551*^9,
3.7715431562207813`*^9}, {3.7715431896847773`*^9, 3.7715432141246033`*^9},
3.771543752828794*^9, {3.771545336327952*^9, 3.77154537226488*^9}, {
3.771545495909955*^9, 3.771545504046062*^9}, {3.771545536247507*^9,
3.771545599826573*^9}, 3.771546142443473*^9, 3.7715974758596573`*^9, {
3.771597573667432*^9, 3.7715975834540167`*^9}, 3.771597824065353*^9,
3.771599065949402*^9, {3.771600327910844*^9, 3.771600339484848*^9}, {
3.771600389764298*^9, 3.771600542306033*^9}, {3.7716005755416107`*^9,
3.771600597447668*^9}, {3.771600635688847*^9, 3.771600661890339*^9}, {
3.7716007001348257`*^9, 3.771600711644875*^9}, {3.771600754872096*^9,
3.77160075687215*^9}, {3.771600799362237*^9, 3.771600914209218*^9}, {
3.771601348783737*^9, 3.771601350759107*^9}, 3.771601625074504*^9,
3.771601903258154*^9, {3.771602570098043*^9, 3.771602572201004*^9}, {
3.771603018695982*^9, 3.7716030241456833`*^9}, {3.771603101980474*^9,
3.77160311523661*^9}, {3.771605513018815*^9, 3.771605582333552*^9},
3.771605635584826*^9, {3.771605666170738*^9, 3.771605687732785*^9},
3.7716057308668613`*^9, {3.7716059076297626`*^9, 3.7716059562259197`*^9}, {
3.771606001839739*^9, 3.771606002707218*^9}, {3.7716060885053053`*^9,
3.77160613185789*^9}, {3.771606235187148*^9, 3.771606265093183*^9}, {
3.771606465547289*^9, 3.77160646568893*^9}, {3.7716065310884123`*^9,
3.771606577653039*^9}, 3.771606670168889*^9, {3.7716067525679817`*^9,
3.771606841211032*^9}, {3.771606877115036*^9, 3.771606981336666*^9}, {
3.771607022917643*^9, 3.771607166861462*^9}, {3.7716071979186287`*^9,
3.7716071983622217`*^9}, {3.771607654805031*^9, 3.771607658293332*^9}, {
3.771608142826254*^9, 3.771608210132547*^9}, {3.771608825255146*^9,
3.771608825735092*^9}, 3.771609469472764*^9, {3.771609598810821*^9,
3.771609684584504*^9}, {3.771609738775776*^9, 3.771609746500736*^9},
3.7716097929940767`*^9, {3.771609831166748*^9, 3.771609869451894*^9}, {
3.771611336572834*^9, 3.7716113437518997`*^9}, {3.7716114107653933`*^9,
3.771611415808259*^9}, 3.771611544122452*^9, 3.771611581659387*^9,
3.771611864751896*^9, {3.7716119644366817`*^9, 3.771611984032297*^9}, {
3.77161202833991*^9, 3.771612035034058*^9}, {3.771612142852289*^9,
3.771612146201132*^9}, {3.771612195893422*^9, 3.771612237268447*^9}, {
3.771612285669643*^9, 3.771612293031847*^9}, 3.771612470747573*^9, {
3.771612556666584*^9, 3.7716126092541122`*^9}, {3.7716126609722233`*^9,
3.771612666151643*^9}, 3.771612854039019*^9, {3.771612958979488*^9,
3.771613005154677*^9}, {3.771618247462775*^9, 3.771618254680395*^9}, {
3.771618297217905*^9, 3.7716183159491997`*^9}, {3.7716185896822767`*^9,
3.7716186085825253`*^9}, 3.7716188162064877`*^9, 3.771619968468833*^9,
3.7716202122531424`*^9, 3.771620285975129*^9, {3.7716203288205976`*^9,
3.771620340082171*^9}, 3.771620559295535*^9, 3.7716210764669657`*^9, {
3.771621268576709*^9, 3.771621340282134*^9}, 3.7716213947381773`*^9, {
3.771621587860312*^9, 3.771621588632451*^9}, {3.771622960474395*^9,
3.771622971886478*^9}, 3.771623026332139*^9, 3.7716230963021717`*^9, {
3.771623188309598*^9, 3.771623279441674*^9}, {3.771623349562437*^9,
3.7716233499047947`*^9}, {3.7716234163277807`*^9, 3.771623417944007*^9}, {
3.7716235383401833`*^9, 3.77162363876304*^9}, 3.771623697039543*^9, {
3.77162375846735*^9, 3.7716238774670897`*^9}, {3.77162392129071*^9,
3.771623955960684*^9}, {3.771624132175827*^9, 3.771624142579853*^9}, {
3.771624195455718*^9, 3.771624253402279*^9}, {3.7716243639164333`*^9,
3.771624374045114*^9}, {3.771624453222176*^9, 3.771624508346478*^9}, {
3.771624551753029*^9, 3.7716247549157333`*^9}, {3.771626798237255*^9,
3.771626887676627*^9}, 3.771626980205681*^9, {3.771627886540188*^9,
3.7716279649993277`*^9}, {3.771628003100092*^9, 3.771628054771658*^9}, {
3.7716285634919033`*^9, 3.771628570317274*^9}, 3.771629295177623*^9, {
3.771629558232202*^9, 3.7716295738669024`*^9}, {3.7716296953067913`*^9,
3.771629695541068*^9}, {3.771629743118561*^9, 3.771629743566019*^9}, {
3.7716297740707397`*^9, 3.771629774271854*^9}, {3.771629832226424*^9,
3.7716298648974667`*^9}, {3.77163162310797*^9, 3.771631675674676*^9}, {
3.771631732263942*^9, 3.771631825652769*^9}, {3.771676566249522*^9,
3.7716766049193983`*^9}, {3.771692379951434*^9, 3.771692465855789*^9},
3.771692551205678*^9, {3.771692608547168*^9, 3.771692629696631*^9}, {
3.771692684204432*^9, 3.7716926968754473`*^9}, {3.771692758806584*^9,
3.7716927729541397`*^9}, {3.771703785464868*^9, 3.771703790756217*^9}},
CellLabel->"In[16]:=",ExpressionUUID->"738dd1bc-b935-4873-bc91-dc41dc3d820c"]
}, Closed]],
Cell[CellGroupData[{
Cell["errorExplorer function", "Subsection",
CellChangeTimes->{{3.771676684689481*^9, 3.771676715562169*^9}, {
3.771681124684079*^9,
3.7716811248635798`*^9}},ExpressionUUID->"905b7136-4f81-4fe8-bafa-\
6355e323b3bb"],
Cell[BoxData[
RowBox[{
RowBox[{"errorExplorer", "[",
RowBox[{"str_", "?", "StringQ"}], "]"}], ":=", "\n", "\t",
RowBox[{"Module", "[", "\n", "\t",
RowBox[{
RowBox[{"{", "\n", "\t\t",
RowBox[{
RowBox[{"level", " ", "=", " ", "0"}], ",", "\[IndentingNewLine]",
"\t\t",
RowBox[{"head", " ", "=", " ", "\"\<None\>\""}], ",",
"\[IndentingNewLine]", "\t\t",
RowBox[{"treeStructure", " ", "=", " ",
RowBox[{"Association", "[",
RowBox[{"<|", " ", "|>"}], "]"}]}], ",", "\[IndentingNewLine]",
"\t\t",
RowBox[{"id", "=", "1"}], ",", "\[IndentingNewLine]", "\t\t",
RowBox[{"commasFound", " ", "=", " ", "0"}], ",", "\[IndentingNewLine]",
"\t\t",
RowBox[{"currentPosition", "=", " ", "0"}], ",", "\n", "\t\t",
RowBox[{"changes", "=",
RowBox[{"{", "}"}]}], ",", "\[IndentingNewLine]", "\t\t",
RowBox[{"commaPositions", " ", "=", " ",
RowBox[{"FindCommaPositions", "[", "str", "]"}]}]}],
"\[IndentingNewLine]", "\t", "}"}], ",", "\[IndentingNewLine]", "\t",
RowBox[{"treeBuilder", "[",
RowBox[{
"currentPosition", ",", "str", ",", "changes", ",", "treeStructure", ",",
"level", ",", "id", ",", "head"}], "]"}]}], "\[IndentingNewLine]",
"]"}]}]], "Code",
CellChangeTimes->{{3.771361136214018*^9, 3.771361229708091*^9},
3.771361313231653*^9, {3.77136186624118*^9, 3.771361874414691*^9}, {
3.771361996088681*^9, 3.771362025686351*^9}, {3.7713620682097073`*^9,
3.7713620777233257`*^9}, {3.7713634119396677`*^9, 3.771363548581706*^9}, {
3.771364736090108*^9, 3.771364777374384*^9}, {3.7713662927225723`*^9,
3.771366297321278*^9}, {3.771366350770006*^9, 3.7713664388713427`*^9}, {
3.771366516745023*^9, 3.77136651827549*^9}, {3.771366729408938*^9,
3.771366731731201*^9}, {3.7713671226822767`*^9, 3.771367123150505*^9},
3.7714492294722*^9, {3.7714500736785994`*^9, 3.771450113665509*^9}, {
3.7715273715168123`*^9, 3.7715274496684732`*^9}, {3.77153315006075*^9,
3.7715331557819767`*^9}, {3.771534071531076*^9, 3.771534081969363*^9}, {
3.771534126579603*^9, 3.771534129182218*^9}, {3.771538313031554*^9,
3.7715383134643784`*^9}, {3.7715392642393103`*^9,
3.7715392650139523`*^9}, {3.7715395652255297`*^9, 3.771539565769442*^9}, {
3.771540018694331*^9, 3.7715400305739803`*^9}, {3.77154070242553*^9,
3.7715408117974787`*^9}, {3.771624418023939*^9, 3.771624441266415*^9}},
CellLabel->"In[17]:=",ExpressionUUID->"7c11c7ec-3eae-4b7f-a10e-b73a6c92f8e6"]
}, Closed]],
Cell[CellGroupData[{
Cell["complementary functions", "Subsection",
CellChangeTimes->{3.771676724478739*^9,
3.771681125804592*^9},ExpressionUUID->"7b086643-ed0b-432f-8a8b-\
0277a1a209e3"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
"Returns", " ", "number", " ", "of", " ", "commas", " ", "in", " ", "a",
" ", "give", " ", "string", " ", "expression"}], " ", "*)"}], "\n",
RowBox[{"(*", " ",
RowBox[{
"Has", " ", "to", " ", "be", " ", "improved", " ", "so", " ", "that", " ",
"it", " ", "ignores", " ", "commas", " ", "in", " ", "comments"}], " ",
"*)"}], "\n",
RowBox[{
RowBox[{
RowBox[{"FindCommaPositions", "[",
RowBox[{"thisString_", "?", "StringQ"}], "]"}], ":=",
RowBox[{
RowBox[{"StringPosition", "[",
RowBox[{"thisString", ",", "\"\<,\>\""}], "]"}], "[",
RowBox[{"[",
RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";"}]}]], "Code",
CellChangeTimes->{{3.77135040685737*^9, 3.771350447064413*^9}, {
3.771350505406062*^9, 3.771350509760221*^9}, 3.771350640839282*^9, {
3.771361756103595*^9, 3.771361820265237*^9}, 3.7713635581525717`*^9, {
3.77152004126474*^9, 3.771520078087325*^9}, {3.771520122200695*^9,
3.771520127093384*^9}},
CellLabel->"In[18]:=",ExpressionUUID->"d4070800-ee93-4539-923a-73e24190a658"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Given", " ", "the", " ", "current", " ", "treeStructure", " ",
RowBox[{"(",
RowBox[{
"see", " ", "explanation", " ", "in", " ", "errorExplorer", " ",
"function"}], ")"}], " ", "and", " ", "the", " ", "current", " ",
"level"}], ",", " ",
RowBox[{
"it", " ", "returns", " ", "the", " ", "index", " ", "of", " ", "the",
" ", "last", " ", "item", " ", "in", " ", "that", " ",
RowBox[{"level", ".", " ", "\n", "Given"}], " ", "that", " ", "the", " ",
"expression", " ", "is", " ", "being", " ", "processed", " ", "from",
" ", "left", " ", "to", " ", "right"}], ",", " ",
RowBox[{"item", " ", "is", " ", "the", " ", "current", " ", "item"}]}],
" ", "*)"}], "\n",
RowBox[{
RowBox[{
RowBox[{"whatismyid", "[",
RowBox[{"currentlevel_", ",", "thistreeStructure_"}], "]"}], ":=",
RowBox[{"Length", "@",
RowBox[{"KeySelect", "[",
RowBox[{"thistreeStructure", ",",
RowBox[{
RowBox[{
RowBox[{"#", "[",
RowBox[{"[", "1", "]"}], "]"}], "\[Equal]", "currentlevel"}],
"&"}]}], "]"}]}]}], ";"}]}]], "Code",
CellChangeTimes->{{3.771256074968734*^9, 3.7712561304578342`*^9}, {
3.771361828631456*^9, 3.771361849324009*^9}, {3.771363605060474*^9,
3.7713636159393044`*^9}, {3.771363676646055*^9, 3.771363685750206*^9}, {
3.771520084841639*^9, 3.771520276578233*^9}, {3.771520372390399*^9,
3.771520386875601*^9}},
CellLabel->"In[19]:=",ExpressionUUID->"4c4f111f-b3f8-4b28-8ed5-dc7e7e35c265"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Given", " ", "a", " ", "treeStructure", " ",
RowBox[{"(",
RowBox[{
"see", " ", "explanation", " ", "in", " ", "errorExplorer", " ",
"function"}], ")"}]}], ",", " ",
RowBox[{"current", " ", "level", " ", "in", " ", "the", " ", "tree"}],
",", " ",
RowBox[{"unique", " ", "id"}], ",", " ",
RowBox[{"and", " ", "the", " ", "current", " ",
RowBox[{"function", "'"}], "s", " ", "head"}], ",", " ", "\n",
RowBox[{
RowBox[{
RowBox[{
RowBox[{
"it", " ", "creates", " ", "a", " ", "new", " ", "entry", " ", "in",
" ", "the", " ", "tree", " ", "with", " ", "those", " ", "details"}],
" ", "&"}], " ", "argument", " ", "cound"}], " ", "=", " ", "0"}]}],
" ", "*)"}], "\n",
RowBox[{
RowBox[{"newTreeEntry", "[",
RowBox[{"level_", ",", "id_", ",", "head_", ",", "treeStructure_"}],
"]"}], ":=", "\[IndentingNewLine]", "\t",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",",
RowBox[{"id", "+", "1"}]}], "}"}], "\[Rule]", " ", "\n", "\t\t",
RowBox[{"Association", "@@", "\[IndentingNewLine]", "\t\t",
RowBox[{"{", "\n", "\t\t\t",
RowBox[{
RowBox[{"\"\<head\>\"", "\[Rule]", " ", "head"}], ",",
"\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<argnumber\>\"", "\[Rule]", " ", "1"}], ",",
"\[IndentingNewLine]", "\t\t\t",
RowBox[{"If", "[",
RowBox[{
RowBox[{"level", ">", "1"}], ",", "\[IndentingNewLine]", "\t\t\t\t",
RowBox[{"\"\<parent\>\"", "\[Rule]", " ",
RowBox[{
RowBox[{"(",
RowBox[{"Keys", "@",
RowBox[{"KeySelect", "[",
RowBox[{"treeStructure", ",",
RowBox[{
RowBox[{
RowBox[{"#", "[",
RowBox[{"[", "1", "]"}], "]"}], "\[Equal]",
RowBox[{"(",
RowBox[{"level", "-", "1"}], ")"}]}], "&"}]}], "]"}]}],
")"}], "[",
RowBox[{"[",
RowBox[{"-", "1"}], "]"}], "]"}]}], ",", "\[IndentingNewLine]",
"\t\t\t\t",
RowBox[{"\"\<parent\>\"", "\[Rule]",
RowBox[{"{",
RowBox[{"0", ",", "0"}], "}"}]}]}], "\[IndentingNewLine]",
"\t\t\t", "]"}], ",", "\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<pattern\>\"", "\[Rule]", " ", "\"\<_\>\""}]}],
"\[IndentingNewLine]", "\t\t", "}"}]}]}]}]}]], "Code",
CellChangeTimes->{{3.771363691273745*^9, 3.771363713100438*^9}, {
3.7713637462010098`*^9, 3.771363767578844*^9}, {3.771363808999614*^9,
3.771363837877503*^9}, {3.771363932743129*^9, 3.771363933221136*^9},
3.7715044221954327`*^9, 3.7715202850733223`*^9, {3.771520356625848*^9,
3.771520445901176*^9}, {3.771522801590138*^9, 3.771522802128112*^9}, {
3.771603254032799*^9, 3.7716032616243477`*^9}, {3.771607971258841*^9,
3.7716079743302813`*^9}},
CellLabel->"In[20]:=",ExpressionUUID->"4bf7805c-49a6-481a-ba5b-291fca0b0e1e"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Given", " ", "a", " ", "treeStructure", " ",
RowBox[{"(",
RowBox[{
"see", " ", "explanation", " ", "in", " ", "errorExplorer", " ",
"function"}], ")"}]}], ",", " ",
RowBox[{"the", " ", "current", " ", "level", " ", "in", " ", "tree"}],
",", " ",
RowBox[{"and", " ", "current", " ", "id"}], ",", "\n",
RowBox[{
"It", " ", "checks", " ", "whether", " ", "the", " ", "pattern", " ",
"for", " ", "the", " ", "current", " ", "level", " ", "and", " ", "id"}],
",", " ",
RowBox[{
"matches", " ", "the", " ", "syntax", " ", "information", " ", "of", " ",
"the", " ", "head", " ", "and", " ", "returns", " ",
RowBox[{"True", "/", "False"}]}]}], "\n", " ", "*)"}], "\n",
RowBox[{
RowBox[{"testPatternMatch", "[",
RowBox[{"treeStructure_", ",", "level_", ",", "id_"}], "]"}], ":=",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{",
RowBox[{"t", "=", "0"}], "}"}], ",", "\n", "\t",
RowBox[{
RowBox[{"first", " ", "=", " ", "\n", "\t\t",
RowBox[{"ToExpression", "[", " ", "\n", "\t\t\t",
RowBox[{"StringJoin", "[", " ", "\n", "\t\t\t\t",
RowBox[{"\"\<{\>\"", ",", "\n", "\t\t\t\t",
RowBox[{"treeStructure", "[",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], ",", "\"\<pattern\>\""}],
"]"}], ",", "\n", "\t\t\t\t", "\"\<}\>\""}], " ", "\n", "\t\t\t",
"]"}], " ", "\n", "\t\t", "]"}]}], ";", " ", "\n", "\t",
RowBox[{"second", " ", "=", " ",
RowBox[{"Replace", "[", "\n", "\t\t",
RowBox[{
RowBox[{"Lookup", "[", "\n", "\t\t\t",
RowBox[{
RowBox[{"SyntaxInformation", "[", "\n", "\t\t\t\t",
RowBox[{"Symbol", "@", "\n", "\t\t\t\t\t",
RowBox[{"treeStructure", "[",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], ",", "\"\<head\>\""}],
"]"}]}], "]"}], ",", " ", "\n", "\t\t\t",
"\"\<ArgumentsPattern\>\""}], "\n", "\t\t", "]"}], ",", "\n",
"\t\t",
RowBox[{
RowBox[{
RowBox[{"Verbatim", "[", "Optional", "]"}], "[", "x_", "]"}],
"\[RuleDelayed]",
RowBox[{"Repeated", "[",
RowBox[{"x", ",",
RowBox[{"{",
RowBox[{"0", ",", "1"}], "}"}]}], "]"}]}], ",", "1"}], "\n",
"\t ", "]"}]}], ";", "\n", "\t ",
RowBox[{"result", " ", "=", " ",
RowBox[{"MatchQ", "[",
RowBox[{"first", ",", " ", "second"}], "]"}]}], ";", "\n", "\t ",
"result"}]}], "\n", "\t", "]"}]}]}]], "Code",
CellChangeTimes->{{3.771363658402822*^9, 3.77136367267804*^9}, {
3.771363735704891*^9, 3.7713637428697357`*^9}, {3.771363955309753*^9,
3.771364071239353*^9}, {3.7713641602880163`*^9, 3.771364168489171*^9}, {
3.7713642840517473`*^9, 3.771364284647542*^9}, {3.771457837038912*^9,
3.771457855674863*^9}, {3.771511928623568*^9, 3.771511931063847*^9}, {
3.771511963034408*^9, 3.771511982930648*^9}, {3.771512093086596*^9,
3.771512168782537*^9}, {3.77151220889163*^9, 3.771512315156314*^9}, {
3.7715124132316837`*^9, 3.7715124792865257`*^9}, 3.771519509256266*^9, {
3.771520458181898*^9, 3.771520536273493*^9}, {3.77162478868429*^9,
3.771624789486429*^9}},
CellLabel->"In[21]:=",ExpressionUUID->"5e01074a-1809-41f0-b93a-fb3d541db682"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Given", " ", "the", " ", "current", " ", "string"}], ",", " ",
RowBox[{"and", " ", "information", " ", "regarding", " ", "commas"}], ",",
" ",
RowBox[{
"it", " ", "returns", " ", "the", " ", "remaining", " ", "part", " ",
"of", " ", "the", " ", "expression", " ", "with", " ", "added", " ",
"\"\<],\>\"", " ", "in", " ", "prepended", " ", "in", " ", "order", " ",
"to", " ", "be", " ", "used", " ", "when", " ",
RowBox[{"branching", ".", "\n", "The"}], " ", "reason", " ", "for", " ",
"this", " ", "is", " ", "that", " ", "the", " ", "proposed", " ",
"\"\<]\>\"", " ", "will", " ", "check", " ", "if", " ", "the", " ",
"current", " ", "function", " ", "should", " ", "stop", " ", "there"}],
",", " ",
RowBox[{"while", " ", "the"}], " ", ",", " ",
RowBox[{
"acts", " ", "as", " ", "a", " ", "reminder", " ", "for", " ", "the", " ",
"function", " ", "to", " ", "check", " ", "if", " ", "more", " ",
"brackets", " ", "are", " ", "needed", " ", "\n",
RowBox[{"(",
RowBox[{
"eg", " ", "two", " ", "brackets", " ", "were", " ", "missing", " ",
"before", " ", "the", " ", "comma"}], " "}]}]}], "*)"}], "\n",
RowBox[{"(*", " ",
RowBox[{
RowBox[{
"I", " ", "believe", " ", "that", " ", "by", " ", "adding", " ", "the"}],
" ", ",", " ", "here", ",", " ",
RowBox[{"I", " ", "introduced", " ", "a", " ", "bug"}]}], " ", "*)"}],
"\n", "\n",
RowBox[{
RowBox[{"createAlternativeExpr", "[",
RowBox[{
RowBox[{
RowBox[{"str_", "?", "StringQ"}], ".."}], ",", "commaPositions_", ",",
"commasFound_"}], "]"}], ":=", "\n",
RowBox[{"\"\<]\>\"", "<>",
RowBox[{"StringTake", "[",
RowBox[{"str", ",",
RowBox[{
RowBox[{
RowBox[{"commaPositions", "[",
RowBox[{"[",
RowBox[{"commasFound", "+", "1"}], "]"}], "]"}], "+", "1"}],
";;"}]}], "]"}]}]}]}]], "Code",
CellChangeTimes->{{3.7713641775852222`*^9, 3.771364302898178*^9}, {
3.7713666737739162`*^9, 3.771366679178141*^9}, {3.7713707664973927`*^9,
3.771370767985564*^9}, {3.771371075199223*^9, 3.771371079971534*^9}, {
3.771501494132326*^9, 3.771501513038288*^9}, 3.771511751268634*^9, {
3.771512406988819*^9, 3.771512407902957*^9}, {3.771520541160372*^9,
3.7715207434684362`*^9}, {3.771532880393689*^9, 3.771532932269122*^9}, {
3.771532963122829*^9, 3.771532980088702*^9}, 3.771596758500476*^9},
CellLabel->"In[22]:=",ExpressionUUID->"bbcbb9c0-5cd7-4a5c-9ab4-1c9be5dd92ad"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{"Returns", " ", "the", " ", "treeStructure"}], ",", " ",
RowBox[{
"with", " ", "the", " ", "argument", " ", "count", " ", "and", " ", "the",
" ", "pattern", " ", "count", " ", "of", " ", "the", " ",
RowBox[{"(",
RowBox[{"level", ",", "id"}], ")"}], " ", "position", " ", "both", " ",
"incremented"}]}], " ", "*)"}], "\n",
RowBox[{
RowBox[{"updateTreeEntry", "[",
RowBox[{"level_", ",", "id_", ",", "treeStructure_", ",", "thisarg_"}],
"]"}], ":=", "\n", "\t",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], "\[Rule]", "\n", "\t\t",
RowBox[{"Association", "@@", "\[IndentingNewLine]", "\t\t",
RowBox[{"{", "\n", "\t\t\t",
RowBox[{
RowBox[{"\"\<head\>\"", "\[Rule]", " ",
RowBox[{"treeStructure", "[",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], ",", "\"\<head\>\""}],
"]"}]}], ",", "\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<argnumber\>\"", "\[Rule]", " ",
RowBox[{
RowBox[{"treeStructure", "[",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], ",", "\"\<argnumber\>\""}],
"]"}], "+", "1"}]}], ",", "\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<parent\>\"", "\[Rule]", " ",
RowBox[{"treeStructure", "[",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], ",", "\"\<parent\>\""}],
"]"}]}], ",", "\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<pattern\>\"", "\[Rule]", " ",
RowBox[{"StringJoin", "[",
RowBox[{
RowBox[{"treeStructure", "[",
RowBox[{
RowBox[{"{",
RowBox[{"level", ",", "id"}], "}"}], ",", "\"\<pattern\>\""}],
"]"}], ",", "\"\<,_\>\""}], "]"}]}]}], "\[IndentingNewLine]",
"\t\t", "}"}]}]}]}]}]], "Code",
CellChangeTimes->{{3.771364594343007*^9, 3.7713646691583853`*^9}, {
3.771520746804092*^9, 3.77152080670232*^9}, {3.771602584611771*^9,
3.7716026215612183`*^9}, {3.771602893534398*^9, 3.771602897113986*^9}, {
3.771607218633128*^9, 3.7716072228302393`*^9}, {3.771607925066556*^9,
3.771607934822942*^9}},
CellLabel->"In[23]:=",ExpressionUUID->"d9c63917-759c-4b47-8f19-459a9520aa41"],
Cell[BoxData[
RowBox[{
RowBox[{"addArgumentToTree", "[",
RowBox[{"level_", ",", "treeStructure_", ",", "thisarg_"}], "]"}], ":=",
" ", "\n", "\t",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"level", "+", "1"}], ",", " ",
RowBox[{
RowBox[{"whatismyid", "[",
RowBox[{
RowBox[{"level", "+", "1"}], ",", "treeStructure"}], "]"}], "+",
"1"}]}], "}"}], "\[Rule]", "\n", "\t\t",
RowBox[{"Association", "@@", "\[IndentingNewLine]", "\t\t",
RowBox[{"{", "\n", "\t\t\t",
RowBox[{
RowBox[{"\"\<head\>\"", "\[Rule]", " ", "thisarg"}], ",",
"\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<argnumber\>\"", "\[Rule]", " ", "0"}], ",",
"\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<parent\>\"", "\[Rule]", " ",
RowBox[{"(*",
RowBox[{
RowBox[{"(",
RowBox[{"Keys", "@",
RowBox[{"KeySelect", "[",
RowBox[{"treeStructure", ",",
RowBox[{
RowBox[{
RowBox[{"#", "[",
RowBox[{"[", "1", "]"}], "]"}], "\[Equal]",
RowBox[{"(", "level", ")"}]}], "&"}]}], "]"}]}], ")"}], "[",
RowBox[{"[",
RowBox[{"-", "1"}], "]"}], "]"}], "*)"}],
RowBox[{"{",
RowBox[{"level", ",",
RowBox[{"whatismyid", "[",
RowBox[{"level", ",", "treeStructure"}], "]"}]}], "}"}]}], ",",
"\[IndentingNewLine]", "\t\t\t",
RowBox[{"\"\<pattern\>\"", "\[Rule]", " ", "\"\<\>\""}]}],
"\[IndentingNewLine]", "\t\t", "}"}]}]}]}]], "Code",
CellChangeTimes->CompressedData["
1:eJwdzT1IQgEcBPCnBVq4FNmHQeXS4NASpFNk2NIUkplEEZboVIOLBUXY0JKQ
VkhFRIuSERKJBC2FZNmrwRwKkRJNzTJ6KII5SO/+w/HjhuPkxkWtScgwTCcf
+D3Xun7bUVC3P/VsQOOReA/K4jPkiD7vh6ba1iW8OghdQ2uEJdk6VxhqPhOk
siZ5hH53GzkpmI/C6eWbGLSnHS9wdMUUh33dQxn6Z6s5WO/8+oFZQ4kUvR8W
Yc7nLcM3R6BKe0GI1FfOJGFeqS5IGjbcTVDUf0yqpDUzTMcEFjh7KrNC+7Oc
TBkVXuqSiA+uBRq0d7zNCTMZ5P52oGeV2YVcwJJ54P14LWYhd+4pwJjtguxV
KctwoHRPjnOeGlRohoUsb7Qy1gi3T3Tkgji/CatJmwMuTe074URq0AXzxZZf
mOxSk/8nCOfz
"],
CellLabel->"In[24]:=",ExpressionUUID->"55904a83-5452-4d50-8b7a-17b513c1f785"],
Cell[BoxData[{
RowBox[{
RowBox[{"SetAttributes", "[",
RowBox[{"DBPrint", ",", "HoldFirst"}], "]"}], ";"}], "\n",
RowBox[{
RowBox[{
RowBox[{"DBPrint", "[", "expr_", "]"}], "/;", "$Debug"}], ":=",
RowBox[{"Print", "[",
RowBox[{
RowBox[{"Unevaluated", "[", "expr", "]"}], ",", "\"\<: \>\"", ",",
"expr"}], "]"}]}]}], "Code",
CellChangeTimes->{{3.771631544160295*^9, 3.771631544168214*^9}},
CellLabel->"In[25]:=",ExpressionUUID->"5a5bc201-8909-42f2-b7d5-3aaf8d89f964"]
}, Closed]],
Cell[CellGroupData[{
Cell["Error visualisation functions", "Subsection",
CellChangeTimes->{{3.7716811022724953`*^9,
3.771681119019837*^9}},ExpressionUUID->"b1b5f8e5-a347-427f-b0dd-\
497bb1484960"],
Cell[BoxData[
RowBox[{
RowBox[{"suggestionsProperties", "[", "suggestions_", "]"}], ":=",
RowBox[{"Grid", "[",
RowBox[{
RowBox[{"{",
RowBox[{"Map", "[",
RowBox[{
RowBox[{
RowBox[{"Dataset", "[",
RowBox[{"#", "[", "\"\<tree\>\"", "]"}], "]"}], "&"}], ",",
"suggestions"}], "]"}], "}"}], ",",
RowBox[{"AllowedDimensions", "\[Rule]",
RowBox[{"{",
RowBox[{"2", ",", "Automatic"}], "}"}]}]}], "]"}]}]], "Code",
CellChangeTimes->{{3.771680732924992*^9, 3.771680750642145*^9}, {
3.771680795493677*^9, 3.771680810505589*^9}, {3.771680917914999*^9,
3.7716809197852917`*^9}, {3.771682461352522*^9, 3.771682469011627*^9}, {
3.7716825272501*^9, 3.771682535441815*^9}, {3.7716826210152073`*^9,
3.7716826784464293`*^9}, {3.771682740115704*^9, 3.771682795621698*^9}, {
3.7716828638102207`*^9, 3.771682865685713*^9}, {3.771682904513905*^9,
3.7716829357680798`*^9}, {3.771682966498571*^9, 3.7716829707058163`*^9}, {
3.771683002751068*^9, 3.771683016316864*^9}, {3.771683569240131*^9,
3.77168360350671*^9}},
CellLabel->"In[27]:=",ExpressionUUID->"8b7a9c52-264d-4b58-9b4b-2058172e1ede"],
Cell[BoxData[
RowBox[{
RowBox[{"suggestionsExplorer", "[",
RowBox[{"str_", ",", "suggestions_"}], "]"}], ":=", "\n",
RowBox[{"Manipulate", "[", "\n", "\t",
RowBox[{
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"Length", "@",
RowBox[{"Flatten", "@",
RowBox[{"suggestions", "[",
RowBox[{"[",
RowBox[{"All", ",", "2"}], "]"}], "]"}]}]}], ">", "0"}], ",", "\n",
"\t\t",
RowBox[{"Grid", "[", "\n", "\t\t",
RowBox[{
RowBox[{"{", "\n", "\t\t\t",
RowBox[{
RowBox[{"{", "\n", "\t\t\t", "\n", "\t\t\t\t",
RowBox[{"{", "\n", "\t\t\t\t\t",
RowBox[{
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<changes\>\"", "]"}],
",", "\n", "\t\t\t\t\t",
RowBox[{"Row", "[", "\n", "\t\t\t\t\t",
RowBox[{"{", "\n", "\t\t\t\t\t\t",
RowBox[{
RowBox[{"StringTake", "[",
RowBox[{"str", ",",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<changes\>\"",
"]"}], "[",
RowBox[{"[", "1", "]"}], "]"}], "-", "1"}]}], "]"}], ",",
"\n", "\t\t\t\t\t\t",
RowBox[{"Style", "[",
RowBox[{"\"\<]\>\"", ",", "Bold", ",", "Orange", ",", "18"}],
"]"}], ",", "\n", "\t\t\t\t\t\t",
RowBox[{"StringDrop", "[",
RowBox[{"str", ",",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<changes\>\"",
"]"}], "[",
RowBox[{"[", "1", "]"}], "]"}], "-", "1"}]}], "]"}]}],
"\n", "\t\t\t\t\t", "}"}], "\n", "\t\t\t\t\t", "]"}]}], "\n",
"\t\t\t\t", "}"}], "\n", "\t\t", "}"}], ",", "\n", "\t\t",
RowBox[{"{", "\n", "\t\t\t",
RowBox[{"Quiet", "@", "\n", "\t\t\t",
RowBox[{"ToExpression", "[", "\n", "\t\t\t",
RowBox[{"StringInsert", "[",
RowBox[{"str", ",", "\"\<]\>\"", ",",
RowBox[{
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<changes\>\"",
"]"}], "[",
RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "]"}]}], "\n",
"\t\t\t", "}"}]}], "\n", "\t\t\t", "}"}], ",", "\n", "\t\t",
RowBox[{"ItemSize", "\[Rule]", "All"}]}], "]"}], ",", "\n", "\t\t",
"\"\<No suggestion\>\""}], "]"}], ",", "\n", "\t",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"ii", ",", "1", ",", "\"\<Suggestion\>\""}], "}"}], ",", "1",
",",
RowBox[{"Length", "[", "suggestions", "]"}], ",", "1"}], "}"}], ",",
RowBox[{"ControlType", "\[Rule]", "RadioButton"}], ",",
RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "]"}]}]], "Code",
CellChangeTimes->{{3.771680925297817*^9, 3.771680937474552*^9}, {
3.771683925250306*^9, 3.771684057727429*^9}, {3.771684125076023*^9,
3.771684212317563*^9}, {3.771684843802114*^9, 3.771684890384787*^9}, {
3.771684925612973*^9, 3.771684929932994*^9}, {3.771684964272547*^9,
3.7716850096042023`*^9}, {3.77168601054012*^9, 3.77168601204941*^9}, {
3.771686375150227*^9, 3.771686400833956*^9}, {3.7716864633691597`*^9,
3.7716864956082973`*^9}, {3.771686539836274*^9, 3.771686675961039*^9}, {
3.771701885504031*^9, 3.7717018881129436`*^9}},
CellLabel->"In[28]:=",ExpressionUUID->"73421ea2-a697-4b96-a878-f4858056293a"],
Cell[BoxData[
RowBox[{
RowBox[{"suggestionTrees", "[", "suggestions_", "]"}], ":=", "\n",
RowBox[{"Manipulate", "[",
RowBox[{"(*", " ",
RowBox[{"add", " ", "module"}], " ", "*)"}], "\n", "\t",
RowBox[{
RowBox[{
RowBox[{"keys", "=",
RowBox[{"Keys", "[",
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<tree\>\"", "]"}], "]"}]}],
";", "\n", "\t",
RowBox[{"names", "=",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<tree\>\"", "]"}], "//",
"Values"}], ")"}], "[",
RowBox[{"[",
RowBox[{"All", ",", "\"\<head\>\""}], "]"}], "]"}]}], ";", "\n", "\t",
RowBox[{"forgraph", "=",
RowBox[{
RowBox[{"AssociationThread", "[",
RowBox[{"keys", "\[Rule]", "names"}], "]"}], "//", "Normal"}]}], ";",
"\n", "\t",
RowBox[{"Graph", "[", "\n", "\t\t",
RowBox[{
RowBox[{"Reverse", "[", "\n", "\t\t\t",
RowBox[{
RowBox[{"Normal", "@", "\n", "\t\t\t\t",
RowBox[{"(",
RowBox[{
RowBox[{"Lookup", "[", "\"\<parent\>\"", "]"}], "/@",
RowBox[{
RowBox[{"suggestions", "[",
RowBox[{"[", "ii", "]"}], "]"}], "[", "\"\<tree\>\"", "]"}]}],
")"}]}], "\n", "\t\t\t", ",", "2"}], "]"}], " ", "\n", "\t\t", ",",
RowBox[{"VertexLabels", "\[Rule]", "forgraph"}], ",", "\n", "\t\t",
RowBox[{"VertexSize", "\[Rule]", "Large"}], ",", "\n", "\t\t",
RowBox[{"VertexShapeFunction", "\[Rule]", "\"\<Rectangle\>\""}], ",",
"\n", "\t\t",
RowBox[{"GraphLayout", "\[Rule]",
RowBox[{"{",
RowBox[{"\"\<LayeredEmbedding\>\"", ",",
RowBox[{"\"\<RootVertex\>\"", "\[Rule]", " ",
RowBox[{"{",
RowBox[{"0", ",", "0"}], "}"}]}]}], "}"}]}]}], "]"}]}], ",", "\n",
"\t",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"ii", ",", "1", ",", "\"\<Suggestion\>\""}], "}"}], ",", "1",
",",
RowBox[{"Length", "@", "suggestions"}], ",", "1"}], "}"}], ",", "\n",
"\t",
RowBox[{"ControlType", "\[Rule]", "RadioButton"}]}], "]"}]}]], "Code",
CellChangeTimes->{{3.771680990406313*^9, 3.77168102475458*^9}, {
3.771685250372835*^9, 3.771685335605768*^9}, {3.771685882925708*^9,
3.7716858873791647`*^9}},
CellLabel->"In[29]:=",ExpressionUUID->"373ad193-55bb-4228-ae76-e25e4c877783"],
Cell[BoxData[
RowBox[{
RowBox[{"suggestionsCount", "[", "suggestions_", "]"}], ":=", "\n",
RowBox[{"Length", "@", "\n", "\t", "suggestions"}]}]], "Code",
CellChangeTimes->{{3.771681142434752*^9, 3.7716811640036993`*^9}, {
3.771685340976325*^9, 3.771685343857633*^9}},
CellLabel->"In[30]:=",ExpressionUUID->"018b8ea6-1ee8-417f-b06d-42f5eacaf13b"]
}, Closed]]
}, Open ]],
Cell[CellGroupData[{
Cell[TextData[StyleBox["Recommended Function usage (Quick Start Guide)",
FontSize->36]], "Section",
CellChangeTimes->{{3.771681062476972*^9, 3.771681083329701*^9}, {
3.771693765185562*^9,
3.7716937741839647`*^9}},ExpressionUUID->"7b829027-517e-4087-89c8-\
a214c4753a06"],
Cell[TextData[StyleBox["The function takes the argument in question as string \
for input:",
FontSize->18]], "Text",
CellChangeTimes->{{3.771681721922996*^9, 3.77168178530847*^9}, {
3.771704657090769*^9,
3.7717046573416777`*^9}},ExpressionUUID->"a477e2e4-f3ed-42d9-9136-\
b003fcaf047b"],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"str", " ", "=", " ", "\"\<Sin[Cos[a]\>\""}], ";"}],
" "}]], "Input",
CellChangeTimes->{
3.7716818159652557`*^9, 3.771683876775386*^9, 3.771684227257259*^9, {
3.77168428813312*^9, 3.771684299672964*^9}},
CellLabel->"In[31]:=",ExpressionUUID->"d9768cb5-a7be-48d7-a8b2-895abf9eeaf6"],
Cell[TextData[StyleBox["For example, the above simple user case is lacking \
the closing bracket for Sin.",
FontSize->18]], "Text",
CellChangeTimes->{{3.771681767585032*^9,
3.771681812170546*^9}},ExpressionUUID->"ff49f6b1-5dee-4e87-80b0-\
0b3907a21fe6"],
Cell[BoxData[
RowBox[{
RowBox[{"simplecase", "=",
RowBox[{"errorExplorer", "[", "str", "]"}]}], ";"}]], "Input",
CellChangeTimes->{
3.77168122641714*^9, {3.7716843306607122`*^9, 3.7716843569587603`*^9}, {
3.7716939417091293`*^9, 3.7716939439659357`*^9}, {3.7717038765590773`*^9,
3.771703878599636*^9}},
CellLabel->"In[32]:=",ExpressionUUID->"cd751a8a-47ab-4e3f-8442-08679898898c"],
Cell[TextData[StyleBox["The following function counts the number of \
suggestions from the function. In this case one.",
FontSize->18]], "Text",
CellChangeTimes->{{3.771681871242091*^9,
3.771681897189616*^9}},ExpressionUUID->"d4a7314d-acc8-4d17-8a88-\
7cab72dfc931"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"suggestionsCount", "[", "simplecase", "]"}]], "Input",
CellChangeTimes->{3.771693948368102*^9},
CellLabel->"In[33]:=",ExpressionUUID->"464f9c4e-298e-4bda-a351-b045ae5541cf"],
Cell[BoxData["1"], "Output",
CellChangeTimes->{3.7717046459821167`*^9},
CellLabel->"Out[33]=",ExpressionUUID->"261f3450-793e-428f-9181-8ea648fa9a4a"]
}, Open ]],
Cell[TextData[StyleBox["In case the user wants to check how the suggestions \
compare between them, it is possible to execute:",
FontSize->18]], "Text",
CellChangeTimes->{{3.771681903181138*^9,
3.771681925494179*^9}},ExpressionUUID->"224acaf0-3fb2-4cb0-858a-\
8feb249b57d1"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"suggestionsProperties", "[", "simplecase", "]"}]], "Input",
CellChangeTimes->{3.771693949983308*^9},
CellLabel->"In[34]:=",ExpressionUUID->"664bdf77-8919-420e-abe5-67f9b38a2477"],
Cell[BoxData[
TagBox[GridBox[{
{
TemplateBox[{TagBox[
DynamicModuleBox[{
TypeSystem`NestedGrid`PackagePrivate`$state$$ =
Data`UnorderedAssociation[
"RowCount" -> 3, "Length" -> 3, "InitialType" -> TypeSystem`Assoc[
TypeSystem`Vector[
TypeSystem`Atom[Integer], 2],
TypeSystem`Struct[{"head", "argnumber", "parent", "pattern"}, {
TypeSystem`Atom[String],
TypeSystem`Atom[Integer],
TypeSystem`Vector[
TypeSystem`Atom[Integer], 2],
TypeSystem`Atom[String]}], 3], "Shape" ->
TypeSystem`PackageScope`HeaderShape[
Association[{All,
TypeSystem`PackageScope`KeyDummy[0]} -> 1, {All, "head"} ->
1, {All, "argnumber"} -> 1, {All, "parent"} ->
1, {All, "pattern"} -> 1],
TypeSystem`PackageScope`Limited[
TypeSystem`PackageScope`ColumnShape[
TypeSystem`PackageScope`KeyValueShape[
TypeSystem`PackageScope`UnknownShape,
TypeSystem`PackageScope`RowShape[
Association[
"head" -> TypeSystem`PackageScope`AtomShape[
28.800000000000004`], "argnumber" ->
TypeSystem`PackageScope`AtomShape[34], "parent" ->
TypeSystem`PackageScope`UnknownShape, "pattern" ->
TypeSystem`PackageScope`AtomShape[28.800000000000004`]]]]],
3, {}]], "InitialData" ->
TypeSystem`PackageScope`CacheHandle[294046499], "Type" ->
TypeSystem`Assoc[
TypeSystem`Vector[
TypeSystem`Atom[Integer], 2],
TypeSystem`Struct[{"head", "argnumber", "parent", "pattern"}, {
TypeSystem`Atom[String],
TypeSystem`Atom[Integer],
TypeSystem`Vector[
TypeSystem`Atom[Integer], 2],
TypeSystem`Atom[String]}], 3], "HandleQ" -> True, "RowTarget" ->
20, "Data" -> TypeSystem`PackageScope`CacheHandle[294046499]],
TypeSystem`NestedGrid`PackagePrivate`$path$$ = {},
TypeSystem`NestedGrid`PackagePrivate`$pos$$ = 1,
TypeSystem`NestedGrid`PackagePrivate`$grid$$ =
DynamicModule[{
TypeSystem`NestedGrid`PackagePrivate`renderedGrid = Deploy[
Style[
Grid[{{
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Pane[
Style[
RawBoxes[
StyleBox["\"\"", FontColor -> GrayLevel[0.4]]], Italic,
GrayLevel[0.7]], {{20, Full}, 15}],
Style[
Pane[
Style[
RawBoxes[
StyleBox[
"\"\"", FontColor ->
RGBColor[0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], Italic,
GrayLevel[0.7]], {{20, Full}, 15}], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
All, Keys}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[All, Keys]], "Mouse"], Background ->
GrayLevel[0.95], Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Pane[
RawBoxes[
StyleBox["\"head\"", FontColor -> GrayLevel[0.4]]], {{
20, Full}, 15}],
Style[
Pane[
RawBoxes[
StyleBox[
"\"head\"", FontColor ->
RGBColor[0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], {{20, Full}, 15}], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
All, "head"}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[All, "head"]], "Mouse"],
Background -> GrayLevel[0.95],
Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Pane[
RawBoxes[
StyleBox[
"\"argnumber\"", FontColor -> GrayLevel[0.4]]], {{
20, Full}, 15}],
Style[
Pane[
RawBoxes[
StyleBox[
"\"argnumber\"", FontColor ->
RGBColor[0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], {{20, Full}, 15}], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
All, "argnumber"}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[All, "argnumber"]], "Mouse"],
Background -> GrayLevel[0.95],
Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Pane[
RawBoxes[
StyleBox["\"parent\"", FontColor -> GrayLevel[0.4]]], {{
20, Full}, 15}],
Style[
Pane[
RawBoxes[
StyleBox[
"\"parent\"", FontColor ->
RGBColor[0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], {{20, Full}, 15}], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
All, "parent"}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[All, "parent"]], "Mouse"],
Background -> GrayLevel[0.95],
Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Pane[
RawBoxes[
StyleBox["\"pattern\"", FontColor -> GrayLevel[0.4]]], {{
20, Full}, 15}],
Style[
Pane[
RawBoxes[
StyleBox[
"\"pattern\"", FontColor ->
RGBColor[0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], {{20, Full}, 15}], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
All, "pattern"}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[All, "pattern"]], "Mouse"],
Background -> GrayLevel[0.95],
Alignment -> {Left, Baseline}]}, {
Item[
Pane[
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Style[{1, 1}, ShowStringCharacters -> False],
Style[
Style[{1, 1}, ShowStringCharacters -> False], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
Key[{1, 1}]}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{1, 1}]]], "Mouse"]],
ImageSize -> {{60, Full}, Automatic}], Background ->
GrayLevel[0.95], Alignment -> {Left, Baseline}],
Pane[
Annotation["Sin",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{1, 1}],
Key["head"]]], "Mouse"],
ImageSize -> {{28.800000000000004`, Full}, Automatic},
Alignment -> {Left, Baseline}],
Pane[
Annotation[
RawBoxes["1"],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{1, 1}],
Key["argnumber"]]], "Mouse"],
ImageSize -> {{34, Full}, Automatic},
Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Style[{0, 0}, ShowStringCharacters -> False],
Style[
Style[{0, 0}, ShowStringCharacters -> False], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
Key[{1, 1}],
Key["parent"]}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{1, 1}],
Key["parent"]]], "Mouse"]],
Pane[
Annotation["_",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{1, 1}],
Key["pattern"]]], "Mouse"],
ImageSize -> {{28.800000000000004`, Full}, Automatic},
Alignment -> {Left, Baseline}]}, {
Item[
Pane[
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Style[{2, 1}, ShowStringCharacters -> False],
Style[
Style[{2, 1}, ShowStringCharacters -> False], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
Key[{2, 1}]}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{2, 1}]]], "Mouse"]],
ImageSize -> {{60, Full}, Automatic}], Background ->
GrayLevel[0.95], Alignment -> {Left, Baseline}],
Pane[
Annotation["Cos",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{2, 1}],
Key["head"]]], "Mouse"],
ImageSize -> {{28.800000000000004`, Full}, Automatic},
Alignment -> {Left, Baseline}],
Pane[
Annotation[
RawBoxes["1"],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{2, 1}],
Key["argnumber"]]], "Mouse"],
ImageSize -> {{34, Full}, Automatic},
Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Style[{1, 1}, ShowStringCharacters -> False],
Style[
Style[{1, 1}, ShowStringCharacters -> False], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
Key[{2, 1}],
Key["parent"]}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{2, 1}],
Key["parent"]]], "Mouse"]],
Pane[
Annotation["_",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{2, 1}],
Key["pattern"]]], "Mouse"],
ImageSize -> {{28.800000000000004`, Full}, Automatic},
Alignment -> {Left, Baseline}]}, {
Item[
Pane[
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Style[{3, 1}, ShowStringCharacters -> False],
Style[
Style[{3, 1}, ShowStringCharacters -> False], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
Key[{3, 1}]}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{3, 1}]]], "Mouse"]],
ImageSize -> {{60, Full}, Automatic}], Background ->
GrayLevel[0.95], Alignment -> {Left, Baseline}],
Pane[
Annotation["a",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{3, 1}],
Key["head"]]], "Mouse"],
ImageSize -> {{28.800000000000004`, Full}, Automatic},
Alignment -> {Left, Baseline}],
Pane[
Annotation[
RawBoxes["0"],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{3, 1}],
Key["argnumber"]]], "Mouse"],
ImageSize -> {{34, Full}, Automatic},
Alignment -> {Left, Baseline}],
Item[
Annotation[
EventHandler[
MouseAppearance[
Mouseover[
Style[{2, 1}, ShowStringCharacters -> False],
Style[
Style[{2, 1}, ShowStringCharacters -> False], FontColor ->
RGBColor[
0.27450980392156865`, 0.5372549019607843,
0.792156862745098]]], "LinkHand"], {"MouseClicked", 1} :>
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][{
Key[{3, 1}],
Key["parent"]}]],
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{3, 1}],
Key["parent"]]], "Mouse"]],
Pane[
Annotation["",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[
608474961][
GeneralUtilities`Slice[
Key[{3, 1}],
Key["pattern"]]], "Mouse"],
ImageSize -> {{28.800000000000004`, Full}, Automatic},
Alignment -> {Left, Baseline}]}},
BaseStyle -> {ContextMenu -> {
MenuItem["Copy position to clipboard",
KernelExecute[
TypeSystem`NestedGrid`PackagePrivate`toCurrentPosition[
TypeSystem`NestedGrid`PackagePrivate`copyClip]],
MenuEvaluator -> Automatic],
MenuItem["Copy data to clipboard",
KernelExecute[
TypeSystem`NestedGrid`PackagePrivate`toCurrentData[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`copyClip]],
MenuEvaluator -> Automatic], Delimiter,
MenuItem["Paste position in new cell",
KernelExecute[
TypeSystem`NestedGrid`PackagePrivate`toCurrentPosition[
TypeSystem`NestedGrid`PackagePrivate`cellPaste]],
MenuEvaluator -> Automatic],
MenuItem["Paste data in new cell",
KernelExecute[
TypeSystem`NestedGrid`PackagePrivate`toCurrentData[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`cellPaste]],
MenuEvaluator -> Automatic]}, FontFamily -> "Verdana",
FontSize -> 12}, Alignment -> Left, RowMinHeight -> 1.5,
Dividers -> All, FrameStyle -> GrayLevel[0.85],
BaseStyle -> {FontFamily -> "Verdana", FontSize -> 12}],
LineBreakWithin -> False, ContextMenu -> {}, NumberMarks ->
False, ShowAutoStyles -> False]],
TypeSystem`NestedGrid`PackagePrivate`initialQ = True,
TypeSystem`NestedGrid`PackagePrivate`self = $Failed},
Dynamic[
TypeSystem`NestedGrid`PackagePrivate`setupViewPath[
TypeSystem`NestedGrid`PackagePrivate`$path$$, If[
Not[TypeSystem`NestedGrid`PackagePrivate`initialQ],
Module[{
TypeSystem`NestedGrid`PackagePrivate`tmpGrid$ = $Failed,
TypeSystem`NestedGrid`PackagePrivate`tmpData$ =
TypeSystem`NestedGrid`PackagePrivate`LookupCacheValue[
TypeSystem`NestedGrid`PackagePrivate`$state$$["Data"]]},
TypeSystem`NestedGrid`PackagePrivate`tmpGrid$ =
If[TypeSystem`NestedGrid`PackagePrivate`tmpData$ ===
TypeSystem`NestedGrid`PackagePrivate`$NotCached,
TypeSystem`NestedGrid`PackagePrivate`renderedGrid,
TypeSystem`NestedGrid`PackagePrivate`renderGrid[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961][
TypeSystem`NestedGrid`PackagePrivate`tmpData$]]; If[
Not[
FailureQ[TypeSystem`NestedGrid`PackagePrivate`tmpGrid$]],
TypeSystem`NestedGrid`PackagePrivate`renderedGrid =
TypeSystem`NestedGrid`PackagePrivate`tmpGrid$]; Null]];
TypeSystem`NestedGrid`PackagePrivate`initialQ = False;
TypeSystem`NestedGrid`PackagePrivate`$pos$$; If[
FailureQ[TypeSystem`NestedGrid`PackagePrivate`renderedGrid],
TypeSystem`SparseGrid[
TypeSystem`H["(data no longer present)"]],
If[GeneralUtilities`$DebugMode,
Row[{TypeSystem`NestedGrid`PackagePrivate`renderedGrid, " ",
TypeSystem`NestedGrid`PackagePrivate`formatState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$]}],
TypeSystem`NestedGrid`PackagePrivate`renderedGrid]]],
TrackedSymbols :> {TypeSystem`NestedGrid`PackagePrivate`$pos$$}],
DynamicModuleValues :> {}],
TypeSystem`NestedGrid`PackagePrivate`$posCell$$,
TypeSystem`NestedGrid`PackagePrivate`$topBar$$ = Dynamic[
TypeSystem`NestedGrid`PackagePrivate`alignBar[
TypeSystem`NestedGrid`PackagePrivate`$state$$][
TypeSystem`NestedGrid`PackagePrivate`makeFramedBar[
TypeSystem`PackageScope`Pathbar[
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`updateState[
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$path$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$, 608474961]]]],
TrackedSymbols :> {TypeSystem`NestedGrid`PackagePrivate`$path$$}],
TypeSystem`NestedGrid`PackagePrivate`$bottomBar$$ = Framed[
Dynamic[
Replace[
MouseAnnotation[Null], {
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[608474961][
Null] -> "",
TypeSystem`NestedGrid`PackagePrivate`$SliceMarker[608474961][
Pattern[TypeSystem`NestedGrid`PackagePrivate`path,
Blank[]]] :> (
TypeSystem`NestedGrid`PackagePrivate`$lastPath =
TypeSystem`NestedGrid`PackagePrivate`path;
TypeSystem`NestedGrid`PackagePrivate`makePathTrail[
TypeSystem`NestedGrid`PackagePrivate`path,
TypeSystem`NestedGrid`PackagePrivate`makePathElements]),
Null :> Spacer[10], Blank[] :> Spacer[10]}],
TrackedSymbols :> {}], FrameStyle -> None, ImageMargins -> 0,
FrameMargins -> 0, Alignment -> Top,
ImageSize -> {Automatic, 14}]},
DynamicBox[
ToBoxes[
Column[
If[TypeSystem`NestedGrid`PackagePrivate`$path$$ == {}, {
TypeSystem`NestedGrid`PackagePrivate`displayScrollBar[
TypeSystem`NestedGrid`PackagePrivate`$grid$$,
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$],
TypeSystem`NestedGrid`PackagePrivate`onDesktopShow[
TypeSystem`NestedGrid`PackagePrivate`alignBar[
TypeSystem`NestedGrid`PackagePrivate`$state$$][
TypeSystem`NestedGrid`PackagePrivate`$bottomBar$$]]}, {
TypeSystem`NestedGrid`PackagePrivate`$topBar$$,
TypeSystem`NestedGrid`PackagePrivate`displayScrollBar[
TypeSystem`NestedGrid`PackagePrivate`$grid$$,
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$pos$$],
TypeSystem`NestedGrid`PackagePrivate`onDesktopShow[
TypeSystem`NestedGrid`PackagePrivate`alignBar[
TypeSystem`NestedGrid`PackagePrivate`$state$$][
TypeSystem`NestedGrid`PackagePrivate`$bottomBar$$]]}],
Spacings ->
If[TypeSystem`NestedGrid`PackagePrivate`$path$$ == {},
0, {{}, {0, 0.05, 0}}]], StandardForm],
ImageSizeCache -> {285., {54.634033203125, 60.365966796875}},
TrackedSymbols :> {
TypeSystem`NestedGrid`PackagePrivate`$state$$,
TypeSystem`NestedGrid`PackagePrivate`$grid$$}],
BaseStyle -> {LineBreakWithin -> False}, Deinitialization :>
TypeSystem`NestedGrid`PackagePrivate`deleteState[
TypeSystem`NestedGrid`PackagePrivate`$state$$],
DynamicModuleValues :> {}, Initialization :>
Block[{$ContextPath = $ContextPath},
Needs["TypeSystem`"]]], Deploy, DefaultBaseStyle -> "Deploy"]},
"CopyTag",
DisplayFunction->(#& ),
InterpretationFunction->("Dataset[<>]"& )]}
},
AllowedDimensions->{2, Automatic},
AutoDelete->False,
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
"Grid"]], "Output",
CellChangeTimes->{3.771704646478311*^9},
CellLabel->"Out[34]=",ExpressionUUID->"f83320c7-da3c-4fd9-bed2-9b337f989d4a"]
}, Open ]],
Cell[TextData[StyleBox["An association containing the tree for this \
suggestion is shown. The keys for this association show correspond to the \
depth of the tree each function or argument was placed, and a unique id for \
it. The rest of the arguments ...",
FontSize->18]], "Text",
CellChangeTimes->{{3.771682074299521*^9,
3.771682075737266*^9}},ExpressionUUID->"c92c0b7f-b552-46cc-8235-\
bdc60995acb2"],
Cell[TextData[StyleBox["while one can also execute",
FontSize->18]], "Text",
CellChangeTimes->{{3.771681931352785*^9,
3.771681957977194*^9}},ExpressionUUID->"267b5246-d819-4df2-a86e-\
5426db034e47"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"suggestionsExplorer", "[",
RowBox[{"str", ",", "simplecase"}], "]"}]], "Input",
CellChangeTimes->{{3.771686038581962*^9, 3.7716860396683903`*^9}, {
3.771693971235899*^9, 3.771693971920446*^9}},
CellLabel->"In[35]:=",ExpressionUUID->"40c4cf13-661f-4493-b919-e6a87c8023bf"],
Cell[BoxData[
TagBox[
StyleBox[
DynamicModuleBox[{$CellContext`ii$$ = 1, Typeset`show$$ = True,
Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu",
Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ =
"\"untitled\"", Typeset`specs$$ = {{{
Hold[$CellContext`ii$$], 1, "Suggestion"}, 1, 1, 1}},
Typeset`size$$ = {150., {17.634033203125, 23.365966796875}},
Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ =
True, $CellContext`ii$2692$$ = 0},
DynamicBox[Manipulate`ManipulateBoxes[
1, StandardForm, "Variables" :> {$CellContext`ii$$ = 1},
"ControllerVariables" :> {
Hold[$CellContext`ii$$, $CellContext`ii$2692$$, 0]},
"OtherVariables" :> {
Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$,
Typeset`animator$$, Typeset`animvar$$, Typeset`name$$,
Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$,
Typeset`skipInitDone$$}, "Body" :> If[Length[
Flatten[
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]], "changes" -> {11}]}, All, 2]]] > 0,
Grid[{{{
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]], "changes" -> {11}]}, $CellContext`ii$$][
"changes"],
Row[{
StringTake["Sin[Cos[a]", Part[
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]],
"changes" -> {11}]}, $CellContext`ii$$]["changes"], 1] -
1],
Style["]", Bold, Orange, 18],
StringDrop["Sin[Cos[a]", Part[
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]],
"changes" -> {11}]}, $CellContext`ii$$]["changes"], 1] -
1]}]}}, {
Quiet[
ToExpression[
StringInsert["Sin[Cos[a]", "]",
Part[
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]],
"changes" -> {11}]}, $CellContext`ii$$]["changes"], 1]]]]}},
ItemSize -> All], "No suggestion"],
"Specifications" :> {{{$CellContext`ii$$, 1, "Suggestion"}, 1, 1, 1}},
"Options" :> {ControlType -> RadioButton}, "DefaultOptions" :> {}],
ImageSizeCache->{195., {61., 67.}},
SingleEvaluation->True],
Deinitialization:>None,
DynamicModuleValues:>{},
SynchronousInitialization->True,
UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$},
UnsavedVariables:>{Typeset`initDone$$},
UntrackedVariables:>{Typeset`size$$}], "Manipulate",
Deployed->True,
StripOnInput->False],
Manipulate`InterpretManipulate[1]]], "Output",
CellChangeTimes->{3.771704646618539*^9},
CellLabel->"Out[35]=",ExpressionUUID->"9c920c19-d452-4bdf-9bd3-b2443d967dc0"]
}, Open ]],
Cell[TextData[StyleBox["in order to track changes and how they alter the \
initial expression. In this case, a square bracket was added to position 11 \
of the string.",
FontSize->18]], "Text",
CellChangeTimes->{{3.771681963872925*^9,
3.771681998050825*^9}},ExpressionUUID->"4aac7ac3-93ca-4d3f-a924-\
0bcedfc55c04"],
Cell[TextData[StyleBox["Finally, it is possible to visualise the tree \
structure of each suggestions by doing:",
FontSize->18]], "Text",
CellChangeTimes->{{3.771682004369301*^9,
3.771682034774295*^9}},ExpressionUUID->"c93c230b-e2a3-40d3-ba62-\
a3a045cc235e"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"suggestionTrees", "[", "simplecase", "]"}]], "Input",
CellChangeTimes->{{3.771693976204482*^9, 3.7716939770173693`*^9}},
CellLabel->"In[36]:=",ExpressionUUID->"56ab4131-4b19-4cf6-980d-d1b5bf585b73"],
Cell[BoxData[
TagBox[
StyleBox[
DynamicModuleBox[{$CellContext`ii$$ = 1, Typeset`show$$ = True,
Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu",
Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ =
"\"untitled\"", Typeset`specs$$ = {{{
Hold[$CellContext`ii$$], 1, "Suggestion"}, 1, 1, 1}},
Typeset`size$$ = {76., {214., 218.}}, Typeset`update$$ = 0,
Typeset`initDone$$, Typeset`skipInitDone$$ =
True, $CellContext`ii$2732$$ = 0},
DynamicBox[Manipulate`ManipulateBoxes[
1, StandardForm, "Variables" :> {$CellContext`ii$$ = 1},
"ControllerVariables" :> {
Hold[$CellContext`ii$$, $CellContext`ii$2732$$, 0]},
"OtherVariables" :> {
Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$,
Typeset`animator$$, Typeset`animvar$$, Typeset`name$$,
Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$,
Typeset`skipInitDone$$}, "Body" :> ($CellContext`keys = Keys[
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]], "changes" -> {11}]}, $CellContext`ii$$][
"tree"]]; $CellContext`names = Part[
Values[
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]], "changes" -> {11}]}, $CellContext`ii$$][
"tree"]], All, "head"]; $CellContext`forgraph = Normal[
AssociationThread[$CellContext`keys -> $CellContext`names]]; Graph[
Reverse[
Normal[
Map[
Lookup["parent"],
Part[{
Association[
"tree" -> Association[{1, 1} ->
Association[
"head" -> "Sin", "argnumber" -> 1, "parent" -> {0, 0},
"pattern" -> "_"], {2, 1} ->
Association[
"head" -> "Cos", "argnumber" -> 1, "parent" -> {1, 1},
"pattern" -> "_"], {3, 1} ->
Association[
"head" -> "a", "argnumber" -> 0, "parent" -> {2, 1},
"pattern" -> ""]], "changes" -> {11}]}, $CellContext`ii$$][
"tree"]]], 2], VertexLabels -> $CellContext`forgraph, VertexSize ->
Large, VertexShapeFunction -> "Rectangle",
GraphLayout -> {"LayeredEmbedding", "RootVertex" -> {0, 0}}]),
"Specifications" :> {{{$CellContext`ii$$, 1, "Suggestion"}, 1, 1, 1}},
"Options" :> {ControlType -> RadioButton}, "DefaultOptions" :> {}],
ImageSizeCache->{121., {256., 262.}},
SingleEvaluation->True],
Deinitialization:>None,
DynamicModuleValues:>{},
SynchronousInitialization->True,
UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$},
UnsavedVariables:>{Typeset`initDone$$},
UntrackedVariables:>{Typeset`size$$}], "Manipulate",
Deployed->True,
StripOnInput->False],
Manipulate`InterpretManipulate[1]]], "Output",
CellChangeTimes->{3.7717046467445908`*^9},
CellLabel->"Out[36]=",ExpressionUUID->"e27b3ce6-8490-4aa5-860d-1e9eab88fbbc"]
}, Open ]],
Cell[TextData[StyleBox["After the errorExplorer function has been called, the \
rest of the above can be called independently of each other.",
FontSize->18]], "Text",
CellChangeTimes->{{3.7716822495306673`*^9,
3.7716822977168493`*^9}},ExpressionUUID->"f154b337-0a46-4511-a83d-\
dbdb386fc7b1"]
}, Open ]],
Cell[CellGroupData[{
Cell[TextData[StyleBox["Implementation examples",
FontSize->36]], "Section",
CellChangeTimes->{{3.771675351807987*^9, 3.771675354092957*^9}, {
3.7716764335575743`*^9,
3.7716764455822573`*^9}},ExpressionUUID->"cda61173-68a3-468b-a1e7-\
a9e256a4b103"],
Cell[CellGroupData[{
Cell[TextData[StyleBox["Missing bracket for single argument function",
FontSize->24]], "Subsection",
CellChangeTimes->{{3.771684442573765*^9,
3.771684450971607*^9}},ExpressionUUID->"78de9cd3-2598-4ed8-94cd-\
77a8a077431b"],
Cell["\<\
In the following string, a bracket has been removed from Prime[i].\
\>", "Text",
CellChangeTimes->{{3.771695982534383*^9, 3.771695992694398*^9}, {
3.771704275931902*^9,
3.7717043053928747`*^9}},ExpressionUUID->"84d3c02e-26ba-4f88-8634-\
8d72eb3f7218"],
Cell[BoxData[
StyleBox[
RowBox[{
RowBox[{
RowBox[{"str", " ", "=", " ", "\"\<ListPlot[Table[Prime[i,{i,50}]]\>\""}],
";"}], " "}],
FontSize->14]], "Input",
CellChangeTimes->{
3.771682334788825*^9, {3.7716824891860943`*^9, 3.7716825067761927`*^9}, {
3.77168288697665*^9, 3.7716828892042217`*^9}, 3.771683030251321*^9, {
3.771683160775201*^9, 3.771683166399993*^9}, 3.7716834539905577`*^9,
3.771684261165802*^9},
CellLabel->"In[37]:=",ExpressionUUID->"8df5085d-0863-411d-a9fd-b078e21120c7"],
Cell[BoxData[
StyleBox[
RowBox[{
RowBox[{"onearg", " ", "=", " ",
RowBox[{"errorExplorer", "[", "str", "]"}]}], ";"}],
FontSize->14]], "Input",
CellChangeTimes->{{3.771682221554286*^9, 3.7716822316368313`*^9}, {
3.7716843801473618`*^9, 3.7716843999912043`*^9}, {3.771684553832547*^9,
3.771684555431913*^9}, {3.771693983615241*^9, 3.771693986033883*^9}, {
3.7716940190851107`*^9, 3.771694019474353*^9}},
CellLabel->"In[38]:=",ExpressionUUID->"16e82f76-b499-424d-9b36-6607873cd600"],
Cell[CellGroupData[{
Cell[BoxData[
StyleBox[
RowBox[{"suggestionsProperties", "[", "onearg", "]"}],
FontSize->14]], "Input",
CellChangeTimes->{{3.771682301496256*^9, 3.7716823177629004`*^9}, {
3.7716823508280497`*^9, 3.77168237652302*^9}, {3.77168254199419*^9,
3.7716825560723333`*^9}, 3.771684407919923*^9, {3.7716860565867987`*^9,
3.771686078955615*^9}, {3.771693996835273*^9, 3.771694024194676*^9}},
CellLabel->"In[39]:=",ExpressionUUID->"77100e04-c64b-4c93-93a7-a9b41fbc057e"],
Cell[BoxData[
TagBox[GridBox[{
{
TemplateBox[{TagBox[
DynamicModuleBox[{
TypeSystem`NestedGrid`PackagePrivate`$state$$ =
Data`UnorderedAssociation[
"RowCount" -> 5, "Length" -> 5, "InitialType" -> TypeSystem`Assoc[
TypeSystem`Vector[
TypeSystem`Atom[Integer], 2],
TypeSystem`Struct[{"head", "argnumber", "parent", "pattern"}, {
TypeSystem`Atom[String],
TypeSystem`Atom[Integer],
TypeSystem`Vector[
TypeSystem`Atom[Integer], 2],
TypeSystem`Atom[
TypeSystem`Enumeration["", "_", "_,_"]]}], 5], "Shape" ->
TypeSystem`PackageScope`HeaderShape[
Association[{All,
TypeSystem`PackageScope`KeyDummy[1]} -> 1, {All, "head"} ->
1, {All, "argnumber"} -> 1, {All, "parent"} ->
1, {All, "pattern"} -> 1],
TypeSystem`PackageScope`Limited[
TypeSystem`PackageScope`ColumnShape[
TypeSystem`PackageScope`KeyValueShape[
TypeSystem`