public void AddJsonValue(string key, JsonValue value) { if (!Values.ContainsKey(key)) { Values.Add(key, value); } else { throw new Exception("This key already contain value"); } }
void GenerateAstJson(AstBuilder astBuilder, ITextOutput output) { var visitor = new AstCsToJsonVisitor(output); astBuilder.SyntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); astBuilder.SyntaxTree.AcceptVisitor(visitor); AstCsToJsonVisitor visit = visitor as AstCsToJsonVisitor; if (visit != null) { result = visit.LastValue; } else { result = null; } }
public void AddJsonValue(JsonValue value) { ValueList.Add(value); }
private void Push(JsonValue value) { jsonValueStack.Push(value); }
public void VisitSyntaxTree(SyntaxTree syntaxTree) { JsonArray arr = new JsonArray(); arr.Comment = "VisitSyntaxTree"; int counter = 0; CreateGlobalSymbolTable(); foreach (AstNode node in syntaxTree.Children) { node.AcceptVisitor(this); arr.AddJsonValue(Pop()); counter++; } //----------- //type reference table JsonObject symbolInformations = new JsonObject(); JsonArray typerefs = new JsonArray(); symbolInformations.AddJsonValue("typerefs", typerefs); foreach (string k in this.typeReferences.Keys) { //type reference typerefs.AddJsonValue(new JsonElement(k)); } arr.AddJsonValue(symbolInformations); //----------- if (counter == 1) { LastValue = arr.ValueList[0]; } else { LastValue = arr; } }